Test framework: added commander games support (quick start button, "commander" command to put card as commander);

This commit is contained in:
Oleg Agafonov 2019-05-13 13:20:41 +04:00
parent 24b221ff34
commit 8448afc709
6 changed files with 104 additions and 42 deletions

View file

@ -1,7 +1,7 @@
package mage.abilities.common;
import mage.abilities.SpellAbility;
import mage.abilities.costs.CostsImpl;
import mage.cards.Card;
import mage.constants.SpellAbilityType;
import mage.constants.TimingRule;
@ -9,14 +9,13 @@ import mage.constants.Zone;
import mage.game.Game;
/**
*
* @author Plopman
*/
public class CastCommanderAbility extends SpellAbility {
public CastCommanderAbility(Card card) {
super(card.getManaCost(), card.getName(), Zone.COMMAND, SpellAbilityType.BASE);
this.costs = card.getSpellAbility().getCosts().copy();
this.costs = card.getSpellAbility() != null ? card.getSpellAbility().getCosts().copy() : new CostsImpl<>();
this.timing = TimingRule.SORCERY;
this.usesStack = true;
this.controllerId = card.getOwnerId();

View file

@ -40,7 +40,6 @@ public abstract class GameCommanderImpl extends GameImpl {
@Override
protected void init(UUID choosingPlayerId) {
Ability ability = new SimpleStaticAbility(Zone.COMMAND, new InfoEffect("Commander effects"));
//Move commander to command zone
for (UUID playerId : state.getPlayerList(startingPlayerId)) {
Player player = getPlayer(playerId);
@ -49,7 +48,7 @@ public abstract class GameCommanderImpl extends GameImpl {
for (UUID commanderId : player.getCommandersIds()) {
Card commander = this.getCard(commanderId);
if (commander != null) {
initCommander(commander, ability, player);
initCommander(commander, player);
}
}
} else {
@ -57,20 +56,20 @@ public abstract class GameCommanderImpl extends GameImpl {
Card commander = this.getCard(player.getSideboard().iterator().next());
if (commander != null) {
player.addCommanderId(commander.getId());
initCommander(commander, ability, player);
initCommander(commander, player);
}
}
}
}
}
this.getState().addAbility(ability, null);
super.init(choosingPlayerId);
if (startingPlayerSkipsDraw) {
state.getTurnMods().add(new TurnMod(startingPlayerId, PhaseStep.DRAW));
}
}
private void initCommander(Card commander, Ability ability, Player player) {
public void initCommander(Card commander, Player player) {
Ability ability = new SimpleStaticAbility(Zone.COMMAND, new InfoEffect("Commander effects"));
commander.moveToZone(Zone.COMMAND, null, this, true);
commander.getAbilities().setControllerId(player.getId());
ability.addEffect(new CommanderReplacementEffect(commander.getId(), alsoHand, alsoLibrary));
@ -79,6 +78,7 @@ public abstract class GameCommanderImpl extends GameImpl {
CommanderInfoWatcher watcher = new CommanderInfoWatcher(commander.getId(), checkCommanderDamage);
getState().addWatcher(watcher);
watcher.addCardInfoToCommander(this);
this.getState().addAbility(ability, null);
}
//20130711

View file

@ -1,9 +1,5 @@
package mage.game;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
@ -21,8 +17,11 @@ import mage.game.turn.TurnMod;
import mage.players.Player;
import mage.watchers.common.CommanderInfoWatcher;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author JRHerlehy
*/
public abstract class GameTinyLeadersImpl extends GameImpl {
@ -43,7 +42,6 @@ public abstract class GameTinyLeadersImpl extends GameImpl {
@Override
protected void init(UUID choosingPlayerId) {
Ability ability = new SimpleStaticAbility(Zone.COMMAND, new InfoEffect("Commander effects"));
//Move tiny leader to command zone
for (UUID playerId : state.getPlayerList(startingPlayerId)) {
Player player = getPlayer(playerId);
@ -55,6 +53,7 @@ public abstract class GameTinyLeadersImpl extends GameImpl {
this.loadCards(cards, playerId);
player.addCommanderId(commander.getId());
commander.moveToZone(Zone.COMMAND, null, this, true);
Ability ability = new SimpleStaticAbility(Zone.COMMAND, new InfoEffect("Commander effects"));
ability.addEffect(new CommanderReplacementEffect(commander.getId(), alsoHand, alsoLibrary));
ability.addEffect(new CommanderCostModification(commander.getId()));
// Commander rule #4 was removed Jan. 18, 2016
@ -63,13 +62,13 @@ public abstract class GameTinyLeadersImpl extends GameImpl {
CommanderInfoWatcher watcher = new CommanderInfoWatcher(commander.getId(), false);
getState().addWatcher(watcher);
watcher.addCardInfoToCommander(this);
this.getState().addAbility(ability, null);
} else {
throw new UnknownError("Commander card could not be created. Name: [" + player.getMatchPlayer().getDeck().getName() + ']');
}
}
}
this.getState().addAbility(ability, null);
super.init(choosingPlayerId);
if (startingPlayerSkipsDraw) {
state.getTurnMods().add(new TurnMod(startingPlayerId, PhaseStep.DRAW));