mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
* Commander abilities - added support of cards with alternative spells like overload;
This commit is contained in:
parent
cb2730e0d5
commit
9db80a0cf3
4 changed files with 65 additions and 9 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package org.mage.test.cards.continuous;
|
||||
|
||||
import mage.abilities.keyword.FirstStrikeAbility;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
|
|
@ -224,4 +225,50 @@ public class CommandersCastTest extends CardTestCommander4Players {
|
|||
execute();
|
||||
assertAllCommandsUsed();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_AlternativeSpellNormal() {
|
||||
// Player order: A -> D -> C -> B
|
||||
|
||||
// Weapon Surge
|
||||
// Target creature you control gets +1/+0 and gains first strike until end of turn.
|
||||
// Overload {1}{R} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of “target” with “each.”)
|
||||
addCard(Zone.HAND, playerA, "Weapon Surge", 1); // {R} or {1}{R}
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
|
||||
//
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears", 2);
|
||||
|
||||
// cast overload
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Weapon Surge with overload");
|
||||
checkAbility("after", 1, PhaseStep.BEGIN_COMBAT, playerA, "Balduvian Bears", FirstStrikeAbility.class, true);
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
setStrictChooseMode(true);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_AlternativeSpellCommander() {
|
||||
// Player order: A -> D -> C -> B
|
||||
|
||||
// Weapon Surge
|
||||
// Target creature you control gets +1/+0 and gains first strike until end of turn.
|
||||
// Overload {1}{R} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of “target” with “each.”)
|
||||
addCard(Zone.COMMAND, playerA, "Weapon Surge", 1); // {R} or {1}{R}
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
|
||||
//
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears", 2);
|
||||
|
||||
// cast overload
|
||||
showAvaileableAbilities("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA);
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Weapon Surge with overload");
|
||||
setChoice(playerA, "Yes"); // move to command zone
|
||||
checkAbility("after", 1, PhaseStep.BEGIN_COMBAT, playerA, "Balduvian Bears", FirstStrikeAbility.class, true);
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
setStrictChooseMode(true);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -904,8 +904,8 @@ public class TestPlayer implements Player {
|
|||
.map(a -> (
|
||||
a.getZone() + " -> "
|
||||
+ a.getSourceObject(game).getIdName() + " -> "
|
||||
+ (a.getRule().length() > 0
|
||||
? a.getRule().substring(0, Math.min(20, a.getRule().length()) - 1)
|
||||
+ (a.toString().length() > 0
|
||||
? a.toString().substring(0, Math.min(20, a.toString().length()) - 1)
|
||||
: a.getClass().getSimpleName())
|
||||
+ "..."
|
||||
))
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package mage.abilities.common;
|
|||
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.SpellAbilityType;
|
||||
import mage.constants.Zone;
|
||||
|
||||
/**
|
||||
|
|
@ -10,12 +9,12 @@ import mage.constants.Zone;
|
|||
*/
|
||||
public class CastCommanderAbility extends SpellAbility {
|
||||
|
||||
public CastCommanderAbility(Card card) {
|
||||
super(card.getSpellAbility());
|
||||
public CastCommanderAbility(Card card, SpellAbility spellTemplate) {
|
||||
super(spellTemplate);
|
||||
this.newId();
|
||||
this.setCardName(card.getName());
|
||||
this.setCardName(spellTemplate.getCardName());
|
||||
zone = Zone.COMMAND;
|
||||
spellAbilityType = SpellAbilityType.BASE;
|
||||
spellAbilityType = spellTemplate.getSpellAbilityType();
|
||||
}
|
||||
|
||||
public CastCommanderAbility(final CastCommanderAbility ability) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import mage.abilities.text.TextPart;
|
|||
import mage.cards.Card;
|
||||
import mage.cards.FrameStyle;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SpellAbilityType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.game.Game;
|
||||
|
|
@ -19,7 +20,6 @@ import mage.game.events.ZoneChangeEvent;
|
|||
import mage.util.GameLog;
|
||||
import mage.util.SubTypeList;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
|
@ -36,7 +36,17 @@ public class Commander implements CommandObject {
|
|||
|
||||
// replace spell ability by commander cast spell (to cast from command zone)
|
||||
if (card.getSpellAbility() != null) {
|
||||
abilities.add(new CastCommanderAbility(card));
|
||||
abilities.add(new CastCommanderAbility(card, card.getSpellAbility()));
|
||||
}
|
||||
|
||||
// replace alternative spell abilities by commander cast spell (to cast from command zone)
|
||||
for (Ability ability : card.getAbilities()) {
|
||||
if (ability instanceof SpellAbility) {
|
||||
SpellAbility spellAbility = (SpellAbility) ability;
|
||||
if (spellAbility.getSpellAbilityType() == SpellAbilityType.BASE_ALTERNATE) {
|
||||
abilities.add(new CastCommanderAbility(card, spellAbility));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// replace play land with commander play land (to play from command zone)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue