mirror of
https://github.com/correl/mage.git
synced 2024-12-01 11:09:56 +00:00
* Implemented latest Commander rule changes concerning zone changes.
This commit is contained in:
parent
2f2ce63ca2
commit
488e7a9290
6 changed files with 62 additions and 50 deletions
|
@ -44,15 +44,15 @@ public class CommanderDuelMatch extends MatchImpl {
|
|||
@Override
|
||||
public void startGame() throws GameException {
|
||||
int startLife = 40;
|
||||
boolean alsoLibrary = false;
|
||||
boolean alsoHand = true;
|
||||
// Don't like it to compare but seems like it's complicated to do it in another way
|
||||
if (options.getDeckType().equals("Variant Magic - Duel Commander")) {
|
||||
startLife = 30;
|
||||
alsoLibrary = true;
|
||||
alsoHand = false;
|
||||
}
|
||||
CommanderDuel game = new CommanderDuel(options.getAttackOption(), options.getRange(), options.getFreeMulligans(), startLife);
|
||||
game.setStartMessage(this.createGameStartMessage());
|
||||
game.setAlsoLibrary(alsoLibrary);
|
||||
game.setAlsoHand(alsoHand);
|
||||
initGame(game);
|
||||
games.add(game);
|
||||
}
|
||||
|
|
|
@ -44,14 +44,14 @@ public class CommanderFreeForAllMatch extends MatchImpl {
|
|||
@Override
|
||||
public void startGame() throws GameException {
|
||||
int startLife = 40;
|
||||
boolean alsoLibrary = false;
|
||||
boolean alsoHand = true;
|
||||
if (options.getDeckType().equals("Variant Magic - Duel Commander")) {
|
||||
startLife = 30;
|
||||
alsoLibrary = true;
|
||||
alsoHand = false;
|
||||
}
|
||||
CommanderFreeForAll game = new CommanderFreeForAll(options.getAttackOption(), options.getRange(), options.getFreeMulligans(), startLife);
|
||||
game.setStartMessage(this.createGameStartMessage());
|
||||
game.setAlsoLibrary(alsoLibrary);
|
||||
game.setAlsoHand(alsoHand);
|
||||
initGame(game);
|
||||
games.add(game);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class TinyLeadersDuelMatch extends MatchImpl {
|
|||
game.setStartMessage(this.createGameStartMessage());
|
||||
|
||||
//Tucking a Tiny Leader is legal
|
||||
game.setAlsoLibrary(false);
|
||||
game.setAlsoHand(true);
|
||||
this.initGame(game);
|
||||
games.add(game);
|
||||
}
|
||||
|
|
|
@ -54,20 +54,20 @@ import mage.players.Player;
|
|||
public class CommanderReplacementEffect extends ReplacementEffectImpl {
|
||||
|
||||
private final UUID commanderId;
|
||||
private final boolean alsoLibrary;
|
||||
private final boolean alsoHand;
|
||||
|
||||
public CommanderReplacementEffect(UUID commanderId, boolean alsoLibrary) {
|
||||
public CommanderReplacementEffect(UUID commanderId, boolean alsoHand) {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit);
|
||||
staticText = "If a commander would be put into its owner’s graveyard from anywhere, that player may put it into the command zone instead. If a commander would be put into the exile zone from anywhere, its owner may put it into the command zone instead.";
|
||||
this.commanderId = commanderId;
|
||||
this.duration = Duration.EndOfGame;
|
||||
this.alsoLibrary = alsoLibrary;
|
||||
this.alsoHand = alsoHand;
|
||||
}
|
||||
|
||||
public CommanderReplacementEffect(final CommanderReplacementEffect effect) {
|
||||
super(effect);
|
||||
this.commanderId = effect.commanderId;
|
||||
this.alsoLibrary = effect.alsoLibrary;
|
||||
this.alsoHand = effect.alsoHand;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -80,6 +80,46 @@ public class CommanderReplacementEffect extends ReplacementEffectImpl {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
if (commanderId == null) {
|
||||
throw new IllegalArgumentException("commanderId has to be set");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
switch(((ZoneChangeEvent)event).getToZone()) {
|
||||
case HAND:
|
||||
if (!alsoHand) {
|
||||
return false;
|
||||
}
|
||||
case GRAVEYARD:
|
||||
case EXILED:
|
||||
case LIBRARY:
|
||||
if(commanderId.equals(event.getTargetId())){
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case STACK:
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null) {
|
||||
if (commanderId.equals(spell.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
if (((ZoneChangeEvent)event).getFromZone() == Zone.BATTLEFIELD) {
|
||||
|
@ -114,32 +154,4 @@ public class CommanderReplacementEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (((ZoneChangeEvent)event).getToZone() == Zone.GRAVEYARD ||
|
||||
((ZoneChangeEvent)event).getToZone() == Zone.EXILED ||
|
||||
(alsoLibrary && ((ZoneChangeEvent)event).getToZone() == Zone.LIBRARY))
|
||||
{
|
||||
if (commanderId != null) {
|
||||
if (((ZoneChangeEvent)event).getFromZone().equals(Zone.STACK)) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null) {
|
||||
if (commanderId.equals(spell.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(commanderId.equals(event.getTargetId())){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public abstract class GameCommanderImpl extends GameImpl {
|
|||
private final Map<UUID, Cards> mulliganedCards = new HashMap<>();
|
||||
private final Set<CommanderInfoWatcher> commanderCombatWatcher = new HashSet<>();
|
||||
|
||||
protected boolean alsoLibrary; // replace also commander going to library
|
||||
protected boolean alsoHand; // replace also commander going to hand
|
||||
protected boolean startingPlayerSkipsDraw = true;
|
||||
|
||||
public GameCommanderImpl(MultiplayerAttackOption attackOption, RangeOfInfluence range, int freeMulligans, int startLife) {
|
||||
|
@ -68,7 +68,7 @@ public abstract class GameCommanderImpl extends GameImpl {
|
|||
|
||||
public GameCommanderImpl(final GameCommanderImpl game) {
|
||||
super(game);
|
||||
this.alsoLibrary = game.alsoLibrary;
|
||||
this.alsoHand = game.alsoHand;
|
||||
this.startingPlayerSkipsDraw = game.startingPlayerSkipsDraw;
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ public abstract class GameCommanderImpl extends GameImpl {
|
|||
if (commander != null) {
|
||||
player.setCommanderId(commander.getId());
|
||||
commander.moveToZone(Zone.COMMAND, null, this, true);
|
||||
ability.addEffect(new CommanderReplacementEffect(commander.getId(), alsoLibrary));
|
||||
ability.addEffect(new CommanderReplacementEffect(commander.getId(), alsoHand));
|
||||
ability.addEffect(new CommanderCostModification(commander.getId()));
|
||||
ability.addEffect(new CommanderManaReplacementEffect(player.getId(), CardUtil.getColorIdentity(commander)));
|
||||
getState().setValue(commander.getId() + "_castCount", 0);
|
||||
|
@ -211,8 +211,8 @@ public abstract class GameCommanderImpl extends GameImpl {
|
|||
return !player.getId().equals(playerToCheck);
|
||||
}
|
||||
|
||||
public void setAlsoLibrary(boolean alsoLibrary) {
|
||||
this.alsoLibrary = alsoLibrary;
|
||||
public void setAlsoHand(boolean alsoHand) {
|
||||
this.alsoHand = alsoHand;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ import mage.watchers.common.CommanderInfoWatcher;
|
|||
*/
|
||||
public abstract class GameTinyLeadersImpl extends GameImpl{
|
||||
|
||||
protected boolean alsoLibrary; // replace also commander going to library
|
||||
protected boolean alsoHand; // replace also commander going to library
|
||||
protected boolean startingPlayerSkipsDraw = true;
|
||||
|
||||
public GameTinyLeadersImpl(MultiplayerAttackOption attackOption, RangeOfInfluence range, int freeMulligans, int startLife) {
|
||||
|
@ -68,7 +68,7 @@ public abstract class GameTinyLeadersImpl extends GameImpl{
|
|||
|
||||
public GameTinyLeadersImpl(final GameTinyLeadersImpl game) {
|
||||
super(game);
|
||||
this.alsoLibrary = game.alsoLibrary;
|
||||
this.alsoHand = game.alsoHand;
|
||||
this.startingPlayerSkipsDraw = game.startingPlayerSkipsDraw;
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ public abstract class GameTinyLeadersImpl extends GameImpl{
|
|||
this.loadCards(cards, playerId);
|
||||
player.setCommanderId(commander.getId());
|
||||
commander.moveToZone(Zone.COMMAND, null, this, true);
|
||||
ability.addEffect(new CommanderReplacementEffect(commander.getId(), alsoLibrary));
|
||||
ability.addEffect(new CommanderReplacementEffect(commander.getId(), alsoHand));
|
||||
ability.addEffect(new CommanderCostModification(commander.getId()));
|
||||
ability.addEffect(new CommanderManaReplacementEffect(player.getId(), CardUtil.getColorIdentity(commander)));
|
||||
getState().setValue(commander.getId() + "_castCount", 0);
|
||||
|
@ -152,8 +152,8 @@ public abstract class GameTinyLeadersImpl extends GameImpl{
|
|||
return !player.getId().equals(playerToCheck);
|
||||
}
|
||||
|
||||
public void setAlsoLibrary(boolean alsoLibrary) {
|
||||
this.alsoLibrary = alsoLibrary;
|
||||
public void setAlsoHand(boolean alsoHand) {
|
||||
this.alsoHand = alsoHand;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue