Add Ascend mechanic to the game engine (#1486)
* Add MagicAbility.Ascend * Add MagicPlayerState.CitysBlessing * Add Ascend spell ability to MagicSpellCardEvent * Add import * Get rid of type name * Add the city's blessing to MagicCondition * Use doAction in Ascend spell card event * Add import * Add checking if player already has city's blessing * Add AscendTrigger.java * Add import * Add AscendTrigger to Ascend ability * Move AscendTrigger into OtherEntersBattlefieldTrigger.java Creating a new instance of AscendTrigger would hog memory. * Move ascend spell ability to MagicRuleEventAction * Revert "Move AscendTrigger into OtherEntersBattlefieldTrigger.java" This reverts commit 72fdf16e7ad13343ffe2b52458a28b22c2dd970c. * Use single AscendTrigger instance * Remove AscendTrigger, add MagicStatic.Ascend * Remove PutStateTriggerOnStackAction from Ascend * Add import * Use source.getController() for ascending playermaster
parent
967ac7aa34
commit
e44d086554
|
@ -633,6 +633,12 @@ public enum MagicAbility {
|
|||
));
|
||||
}
|
||||
},
|
||||
Ascend("ascend",0) {
|
||||
@Override
|
||||
protected void addAbilityImpl(final MagicAbilityStore card, final Matcher arg) {
|
||||
card.add(MagicStatic.Ascend);
|
||||
}
|
||||
},
|
||||
|
||||
// abilities that involve SN
|
||||
ShockLand("As SN enters the battlefield, you may " + ARG.COST + "\\. If you don't, SN enters the battlefield tapped\\.", -10) {
|
||||
|
|
|
@ -8,7 +8,8 @@ public enum MagicPlayerState {
|
|||
HasLostLife(""),
|
||||
HasGainedLife(""),
|
||||
Monarch(""),
|
||||
Revolt("") //has had a controlled permanent leave the battlefield
|
||||
Revolt(""), //has had a controlled permanent leave the battlefield
|
||||
CitysBlessing("")
|
||||
;
|
||||
|
||||
private final String description;
|
||||
|
@ -16,7 +17,8 @@ public enum MagicPlayerState {
|
|||
|
||||
// states that persist after cleanup
|
||||
public static final int CLEANUP_MASK =
|
||||
Monarch.getMask();
|
||||
Monarch.getMask() |
|
||||
CitysBlessing.getMask();
|
||||
|
||||
// states that persist during a turn
|
||||
public static final int TURN_MASK =
|
||||
|
@ -24,7 +26,8 @@ public enum MagicPlayerState {
|
|||
WasDealtDamage.getMask() |
|
||||
HasLostLife.getMask() |
|
||||
HasGainedLife.getMask() |
|
||||
Revolt.getMask();
|
||||
Revolt.getMask() |
|
||||
CitysBlessing.getMask();
|
||||
|
||||
private MagicPlayerState(final String description) {
|
||||
this.description=description;
|
||||
|
|
|
@ -809,6 +809,13 @@ public abstract class MagicCondition implements MagicMatchedCostEvent {
|
|||
}
|
||||
};
|
||||
|
||||
public static MagicCondition HAS_THE_CITYS_BLESSING = new MagicCondition() {
|
||||
@Override
|
||||
public boolean accept(MagicSource source) {
|
||||
return source.getController().hasState(MagicPlayerState.CitysBlessing);
|
||||
}
|
||||
};
|
||||
|
||||
public static MagicCondition PERMANENT_YOU_CONTROLLED_LEFT_BATTLEFIELD = new MagicCondition() {
|
||||
@Override
|
||||
public boolean accept(MagicSource source) {
|
||||
|
|
|
@ -794,6 +794,12 @@ public enum MagicConditionParser {
|
|||
return MagicCondition.YOU_ARE_MONARCH;
|
||||
}
|
||||
},
|
||||
CitysBlessing("you have the city's blessing") {
|
||||
@Override
|
||||
public MagicCondition toCondition(final Matcher arg) {
|
||||
return MagicCondition.HAS_THE_CITYS_BLESSING;
|
||||
}
|
||||
},
|
||||
;
|
||||
|
||||
private final Pattern pattern;
|
||||
|
|
|
@ -3244,6 +3244,20 @@ public enum MagicRuleEventAction {
|
|||
};
|
||||
}
|
||||
},
|
||||
Ascend(
|
||||
"ascend"
|
||||
) {
|
||||
@Override
|
||||
public MagicEventAction getAction(final Matcher matcher) {
|
||||
return (game, event) -> {
|
||||
if (!event.getPlayer().hasState(MagicPlayerState.CitysBlessing) &&
|
||||
event.getPlayer().getNrOfPermanents() >= 10) {
|
||||
game.doAction(new ChangePlayerStateAction(event.getPlayer(), MagicPlayerState.CitysBlessing));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
},
|
||||
;
|
||||
|
||||
private final Pattern pattern;
|
||||
|
|
|
@ -15,9 +15,11 @@ import magic.model.MagicCard;
|
|||
import magic.model.MagicManaCost;
|
||||
import magic.model.MagicCostManaType;
|
||||
import magic.model.MagicPlayer;
|
||||
import magic.model.MagicPlayerState;
|
||||
import magic.model.MagicPowerToughness;
|
||||
import magic.model.MagicSubType;
|
||||
import magic.model.MagicType;
|
||||
import magic.model.action.ChangePlayerStateAction;
|
||||
import magic.model.action.PutStateTriggerOnStackAction;
|
||||
import magic.model.action.RemoveStaticAction;
|
||||
import magic.model.condition.MagicCondition;
|
||||
|
@ -597,4 +599,16 @@ public abstract class MagicStatic extends MagicDummyModifier implements MagicCha
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static MagicStatic Ascend = new MagicStatic(MagicLayer.Game) {
|
||||
@Override
|
||||
public boolean condition(final MagicGame game,final MagicPermanent source,final MagicPermanent target) {
|
||||
final MagicPlayer controller = source.getController();
|
||||
return !controller.hasState(MagicPlayerState.CitysBlessing) && controller.getNrOfPermanents() >= 10;
|
||||
}
|
||||
@Override
|
||||
public void modGame(final MagicPermanent source, final MagicGame game) {
|
||||
game.doAction(new ChangePlayerStateAction(source.getController(), MagicPlayerState.CitysBlessing));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue