forked from External/mage
fix and test Zirda's Companion legality (#12142)
This commit is contained in:
parent
b2c52ff906
commit
dee0637496
5 changed files with 110 additions and 3 deletions
|
|
@ -2,8 +2,7 @@ package mage.cards.z;
|
||||||
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.*;
|
||||||
import mage.abilities.ActivatedAbility;
|
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.common.TapSourceCost;
|
import mage.abilities.costs.common.TapSourceCost;
|
||||||
|
|
@ -79,7 +78,9 @@ enum ZirdaTheDawnwakerCompanionCondition implements CompanionCondition {
|
||||||
.allMatch(card -> card
|
.allMatch(card -> card
|
||||||
.getAbilities()
|
.getAbilities()
|
||||||
.stream()
|
.stream()
|
||||||
.anyMatch(ActivatedAbility.class::isInstance)
|
.anyMatch(ability -> ability.getAbilityType() == AbilityType.ACTIVATED
|
||||||
|
|| ability.getAbilityType() == AbilityType.MANA
|
||||||
|
|| ability.getAbilityType() == AbilityType.LOYALTY)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
20
Mage.Tests/Companion_ZirdaInvalid.dck
Normal file
20
Mage.Tests/Companion_ZirdaInvalid.dck
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
NAME:Invalid Zirda Invalid
|
||||||
|
|
||||||
|
4 [MRD:278] Ancient Den
|
||||||
|
4 [UMA:236] Ancient Tomb
|
||||||
|
4 [2XM:232] Basalt Monolith
|
||||||
|
1 [CLU:231] Boros Garrison
|
||||||
|
4 [CLU:220] Boros Signet
|
||||||
|
4 [LCI:269] Cavern of Souls
|
||||||
|
4 [EXO:143] City of Traitors
|
||||||
|
4 [C21:292] Great Furnace
|
||||||
|
4 [ULG:126] Grim Monolith
|
||||||
|
4 [VIS:149] Magma Mine
|
||||||
|
4 [STH:138] Mox Diamond
|
||||||
|
4 [SOM:179] Mox Opal
|
||||||
|
4 [FUT:42] Pact of Negation
|
||||||
|
2 [ICE:213] Pyroblast
|
||||||
|
1 [ELD:171] Questing Beast
|
||||||
|
4 [5DN:156] Staff of Domination
|
||||||
|
4 [AER:181] Walking Ballista
|
||||||
|
SB: 1 [IKO:233] Zirda, the Dawnwaker
|
||||||
20
Mage.Tests/Companion_ZirdaValid.dck
Normal file
20
Mage.Tests/Companion_ZirdaValid.dck
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
NAME:Valid Zirda Deck
|
||||||
|
|
||||||
|
4 [MRD:278] Ancient Den
|
||||||
|
4 [UMA:236] Ancient Tomb
|
||||||
|
4 [2XM:232] Basalt Monolith
|
||||||
|
1 [CLU:231] Boros Garrison
|
||||||
|
4 [CLU:220] Boros Signet
|
||||||
|
4 [LCI:269] Cavern of Souls
|
||||||
|
4 [EXO:143] City of Traitors
|
||||||
|
4 [C21:292] Great Furnace
|
||||||
|
4 [ULG:126] Grim Monolith
|
||||||
|
4 [VIS:149] Magma Mine
|
||||||
|
4 [STH:138] Mox Diamond
|
||||||
|
4 [SOM:179] Mox Opal
|
||||||
|
4 [FUT:42] Pact of Negation
|
||||||
|
1 [OTJ:277] Plains
|
||||||
|
2 [ICE:213] Pyroblast
|
||||||
|
4 [5DN:156] Staff of Domination
|
||||||
|
4 [AER:181] Walking Ballista
|
||||||
|
SB: 1 [IKO:233] Zirda, the Dawnwaker
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
package org.mage.test.cards.single.iko;
|
||||||
|
|
||||||
|
import mage.constants.MultiplayerAttackOption;
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.RangeOfInfluence;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.GameException;
|
||||||
|
import mage.game.TwoPlayerDuel;
|
||||||
|
import mage.game.mulligan.MulliganType;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.impl.CardTestPlayerAPIImpl;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author TheElk801
|
||||||
|
*/
|
||||||
|
public class ZirdaTheDawnwakerCompanionTest extends CardTestPlayerAPIImpl {
|
||||||
|
|
||||||
|
private static final String zirda = "Zirda, the Dawnwaker";
|
||||||
|
|
||||||
|
public ZirdaTheDawnwakerCompanionTest() {
|
||||||
|
deckNameA = "Companion_ZirdaValid.dck";
|
||||||
|
deckNameB = "Companion_ZirdaInvalid.dck";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Game createNewGameAndPlayers() throws GameException, FileNotFoundException {
|
||||||
|
Game game = new TwoPlayerDuel(MultiplayerAttackOption.LEFT, RangeOfInfluence.ONE, MulliganType.GAME_DEFAULT.getMulligan(0), 60, 20, 7);
|
||||||
|
|
||||||
|
playerA = createPlayer(game, "PlayerA", deckNameA);
|
||||||
|
playerB = createPlayer(game, "PlayerB", deckNameB);
|
||||||
|
return game;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCompanionAbility() {
|
||||||
|
setChoice(playerA, true); // choice to companion Zirda
|
||||||
|
// playerB does not make a choice.
|
||||||
|
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Plains", 3);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Plains", 3);
|
||||||
|
|
||||||
|
checkPlayableAbility("Valid Zirda Deck", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Companion", true);
|
||||||
|
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Companion");
|
||||||
|
checkPlayableAbility("Invalid Zirda Deck", 2, PhaseStep.PRECOMBAT_MAIN, playerB, "Companion", false);
|
||||||
|
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
setStopAt(2, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertHandCount(playerA, zirda, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6,8 +6,10 @@ import mage.abilities.effects.keyword.CompanionEffect;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.constants.TimingRule;
|
import mage.constants.TimingRule;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
|
import mage.game.Game;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows card to be companion
|
* Allows card to be companion
|
||||||
|
|
@ -48,4 +50,13 @@ public class CompanionAbility extends SpecialAction {
|
||||||
public final String getLegalRule() {
|
public final String getLegalRule() {
|
||||||
return companionCondition.getRule();
|
return companionCondition.getRule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActivationStatus canActivate(UUID playerId, Game game) {
|
||||||
|
// Check that the card is actually a companion.
|
||||||
|
Card card = game.getState().getCompanion().getCard(getSourceId(), game);
|
||||||
|
return card != null
|
||||||
|
? super.canActivate(playerId, game)
|
||||||
|
: ActivationStatus.getFalse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue