Merge origin/master

This commit is contained in:
fireshoes 2015-08-30 18:11:44 -05:00
commit 8f4975416e
8 changed files with 80 additions and 44 deletions

View file

@ -37,21 +37,23 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
* *
* @author LevelX2 * @author LevelX2
*/ */
public class InfectTest extends CardTestPlayerBase { public class InfectTest extends CardTestPlayerBase {
/** /**
*
702.89. Infect * 702.89. Infect 702.89a Infect is a static ability. 702.89b Damage dealt
702.89a Infect is a static ability. * to a player by a source with infect doesnt cause that player to lose
702.89b Damage dealt to a player by a source with infect doesnt cause that player to lose life. Rather, it causes the player to get that many poison counters. See rule 119.3. * life. Rather, it causes the player to get that many poison counters. See
702.89c Damage dealt to a creature by a source with infect isnt marked on that creature. Rather, it causes that many -1/-1 counters to be put on that creature. See rule 119.3. * rule 119.3. 702.89c Damage dealt to a creature by a source with infect
702.89d If a permanent leaves the battlefield before an effect causes it to deal damage, its last known information is used to determine whether it had infect. * isnt marked on that creature. Rather, it causes that many -1/-1 counters
702.89e The infect rules function no matter what zone an object with infect deals damage from. * to be put on that creature. See rule 119.3. 702.89d If a permanent leaves
702.89f Multiple instances of infect on the same object are redundant. * the battlefield before an effect causes it to deal damage, its last known
* information is used to determine whether it had infect. 702.89e The
* infect rules function no matter what zone an object with infect deals
* damage from. 702.89f Multiple instances of infect on the same object are
* redundant.
*
*/ */
@Test @Test
public void testNormalUse() { public void testNormalUse() {
addCard(Zone.BATTLEFIELD, playerB, "Tine Shrike"); // 2/1 Infect addCard(Zone.BATTLEFIELD, playerB, "Tine Shrike"); // 2/1 Infect
@ -64,16 +66,15 @@ public class InfectTest extends CardTestPlayerBase {
assertCounterCount(playerA, CounterType.POISON, 2); assertCounterCount(playerA, CounterType.POISON, 2);
assertLife(playerA, 20); assertLife(playerA, 20);
assertLife(playerB, 20); assertLife(playerB, 20);
} }
@Test @Test
public void testLoseInfectUse() { public void testLoseInfectUse() {
// Creatures your opponents control lose infect. // Creatures your opponents control lose infect.
addCard(Zone.BATTLEFIELD, playerA, "Melira, Sylvok Outcast"); addCard(Zone.BATTLEFIELD, playerA, "Melira, Sylvok Outcast");
addCard(Zone.BATTLEFIELD, playerB, "Tine Shrike"); // 2/1 Infect addCard(Zone.BATTLEFIELD, playerB, "Tine Shrike"); // 2/1 Infect
attack(2, playerB, "Tine Shrike"); attack(2, playerB, "Tine Shrike");
@ -84,23 +85,29 @@ public class InfectTest extends CardTestPlayerBase {
assertCounterCount(playerA, CounterType.POISON, 0); assertCounterCount(playerA, CounterType.POISON, 0);
assertLife(playerA, 18); assertLife(playerA, 18);
assertLife(playerB, 20); assertLife(playerB, 20);
} }
/** /**
* Inkmoth Nexus has no effect it he attacks becaus it has infect but there are no counters added * Inkmoth Nexus has no effect it he attacks becaus it has infect but there
* are no counters added
* http://www.mtgsalvation.com/forums/magic-fundamentals/magic-rulings/magic-rulings-archives/296553-melira-sylvok-outcast-vs-inkmoth-nexus * http://www.mtgsalvation.com/forums/magic-fundamentals/magic-rulings/magic-rulings-archives/296553-melira-sylvok-outcast-vs-inkmoth-nexus
*/ */
@Test @Test
public void testInkmothNexusLoseInfect() { public void testInkmothNexusLoseInfect() {
// Creatures your opponents control lose infect. // Creatures your opponents control lose infect.
addCard(Zone.BATTLEFIELD, playerA, "Melira, Sylvok Outcast"); // Creatures you control can't have -1/-1 counters placed on them.
addCard(Zone.BATTLEFIELD, playerA, "Melira, Sylvok Outcast");
addCard(Zone.BATTLEFIELD, playerB, "Plains", 1); // Put a -1/-1 counter on target creature. When that creature dies this turn, its controller gets a poison counter.
addCard(Zone.BATTLEFIELD, playerB, "Inkmoth Nexus"); addCard(Zone.HAND, playerA, "Virulent Wound"); // Instant {B}
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
// {1}: Inkmoth Nexus becomes a 1/1 Blinkmoth artifact creature with flying and infect until end of turn. It's still a land. addCard(Zone.BATTLEFIELD, playerB, "Plains", 1);
addCard(Zone.BATTLEFIELD, playerB, "Inkmoth Nexus");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Virulent Wound", "Melira, Sylvok Outcast");
// {1}: Inkmoth Nexus becomes a 1/1 Blinkmoth artifact creature with flying and infect until end of turn. It's still a land.
// (It deals damage to creatures in the form of -1/-1 counters and to players in the form of poison counters.) // (It deals damage to creatures in the form of -1/-1 counters and to players in the form of poison counters.)
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerB, "{1}: {this} becomes"); activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerB, "{1}: {this} becomes");
attack(2, playerB, "Inkmoth Nexus"); attack(2, playerB, "Inkmoth Nexus");
@ -108,13 +115,15 @@ public class InfectTest extends CardTestPlayerBase {
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN); setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
execute(); execute();
assertGraveyardCount(playerA, "Virulent Wound", 1);
assertPowerToughness(playerA, "Melira, Sylvok Outcast", 2, 2);
assertTapped("Plains", true); assertTapped("Plains", true);
assertTapped("Inkmoth Nexus", true); assertTapped("Inkmoth Nexus", true);
assertCounterCount(playerA, CounterType.POISON, 0); assertCounterCount(playerA, CounterType.POISON, 0);
assertLife(playerA, 20); assertLife(playerA, 20);
assertLife(playerB, 20); assertLife(playerB, 20);
} }
} }

View file

@ -366,7 +366,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
break; break;
case STACK: case STACK:
StackObject stackObject = game.getStack().getSpell(getId()); StackObject stackObject = game.getStack().getSpell(getId());
if (stackObject == null && (this instanceof SplitCard)) { // handle if half od Split cast is on the stack if (stackObject == null && (this instanceof SplitCard)) { // handle if half of Split cast is on the stack
stackObject = game.getStack().getSpell(((SplitCard) this).getLeftHalfCard().getId()); stackObject = game.getStack().getSpell(((SplitCard) this).getLeftHalfCard().getId());
if (stackObject == null) { if (stackObject == null) {
stackObject = game.getStack().getSpell(((SplitCard) this).getRightHalfCard().getId()); stackObject = game.getStack().getSpell(((SplitCard) this).getRightHalfCard().getId());

View file

@ -60,16 +60,32 @@ public abstract class SplitCard extends CardImpl {
public SplitCard(SplitCard card) { public SplitCard(SplitCard card) {
super(card); super(card);
this.leftHalfCard = card.leftHalfCard.copy(); this.leftHalfCard = card.getLeftHalfCard().copy();
((SplitCardHalf) leftHalfCard).setParentCard(this);
this.rightHalfCard = card.rightHalfCard.copy(); this.rightHalfCard = card.rightHalfCard.copy();
((SplitCardHalf) rightHalfCard).setParentCard(this);
} }
public Card getLeftHalfCard() { public SplitCardHalf getLeftHalfCard() {
return leftHalfCard; return (SplitCardHalf) leftHalfCard;
} }
public Card getRightHalfCard() { public SplitCardHalf getRightHalfCard() {
return rightHalfCard; return (SplitCardHalf) rightHalfCard;
}
@Override
public void assignNewId() {
super.assignNewId();
leftHalfCard.assignNewId();
rightHalfCard.assignNewId();
}
@Override
public void setCopy(boolean isCopy) {
super.setCopy(isCopy);
leftHalfCard.setCopy(isCopy);
rightHalfCard.setCopy(isCopy);
} }
@Override @Override

View file

@ -12,5 +12,7 @@ package mage.cards;
public interface SplitCardHalf extends Card { public interface SplitCardHalf extends Card {
@Override @Override
Card copy(); SplitCardHalf copy();
void setParentCard(SplitCard card);
} }

View file

@ -62,7 +62,7 @@ public class SplitCardHalfImpl extends CardImpl implements SplitCardHalf {
} }
@Override @Override
public Card getMainCard() { public SplitCard getMainCard() {
return splitCardParent; return splitCardParent;
} }
@ -74,8 +74,13 @@ public class SplitCardHalfImpl extends CardImpl implements SplitCardHalf {
} }
@Override @Override
public SplitCardHalfImpl copy() { public SplitCardHalf copy() {
return new SplitCardHalfImpl(this); return new SplitCardHalfImpl(this);
} }
@Override
public void setParentCard(SplitCard card) {
this.splitCardParent = card;
}
} }

View file

@ -50,12 +50,12 @@ public class MockSplitCard extends SplitCard {
} }
CardInfo leftHalf = CardRepository.instance.findCard(getLeftHalfName(card)); CardInfo leftHalf = CardRepository.instance.findCard(getLeftHalfName(card));
if(leftHalf != null) { if (leftHalf != null) {
this.leftHalfCard = new MockCard(leftHalf); this.leftHalfCard = new MockCard(leftHalf);
} }
CardInfo rightHalf = CardRepository.instance.findCard(getRightHalfName(card)); CardInfo rightHalf = CardRepository.instance.findCard(getRightHalfName(card));
if(rightHalf != null) { if (rightHalf != null) {
this.rightHalfCard = new MockCard(rightHalf); this.rightHalfCard = new MockCard(rightHalf);
} }
} }

View file

@ -100,7 +100,7 @@ public class Exile implements Serializable, Copyable<Exile> {
} }
public List<Card> getAllCards(Game game) { public List<Card> getAllCards(Game game) {
List<Card> cards = new ArrayList<Card>(); List<Card> cards = new ArrayList<>();
for (ExileZone exile : exileZones.values()) { for (ExileZone exile : exileZones.values()) {
cards.addAll(exile.getCards(game)); cards.addAll(exile.getCards(game));
} }

View file

@ -67,6 +67,7 @@ import mage.cards.Card;
import mage.cards.Cards; import mage.cards.Cards;
import mage.cards.CardsImpl; import mage.cards.CardsImpl;
import mage.cards.SplitCard; import mage.cards.SplitCard;
import mage.cards.SplitCardHalf;
import mage.cards.decks.Deck; import mage.cards.decks.Deck;
import mage.choices.Choice; import mage.choices.Choice;
import mage.constants.CardType; import mage.constants.CardType;
@ -1525,6 +1526,9 @@ public abstract class GameImpl implements Game, Serializable {
Iterator<Card> copiedCards = this.getState().getCopiedCards().iterator(); Iterator<Card> copiedCards = this.getState().getCopiedCards().iterator();
while (copiedCards.hasNext()) { while (copiedCards.hasNext()) {
Card card = copiedCards.next(); Card card = copiedCards.next();
if (card instanceof SplitCardHalf) {
continue; // only the main card is moves, not the halves
}
Zone zone = state.getZone(card.getId()); Zone zone = state.getZone(card.getId());
if (zone != Zone.BATTLEFIELD && zone != Zone.STACK) { if (zone != Zone.BATTLEFIELD && zone != Zone.STACK) {
switch (zone) { switch (zone) {