forked from External/mage
Fixed potential NPE errors in getPhase usage (fixed Berserker's Frenzy, etc)
This commit is contained in:
parent
cfd7464b49
commit
a15a0daa04
81 changed files with 162 additions and 130 deletions
|
|
@ -35,8 +35,8 @@ public class AddCombatAndMainPhaseEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
// 15.07.2006 If it's somehow not a main phase when Fury of the Horde resolves, all it does is untap all creatures that attacked that turn. No new phases are created.
|
||||
if (game.getTurn().getPhaseType() == TurnPhase.PRECOMBAT_MAIN
|
||||
|| game.getTurn().getPhaseType() == TurnPhase.POSTCOMBAT_MAIN) {
|
||||
if (game.getTurnPhaseType() == TurnPhase.PRECOMBAT_MAIN
|
||||
|| game.getTurnPhaseType() == TurnPhase.POSTCOMBAT_MAIN) {
|
||||
// we can't add two turn modes at once, will add additional post combat on delayed trigger resolution
|
||||
TurnMod combat = new TurnMod(source.getControllerId(), TurnPhase.COMBAT, TurnPhase.POSTCOMBAT_MAIN, false);
|
||||
game.getState().getTurnMods().add(combat);
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class DontUntapInControllersNextUntapStepSourceEffect extends ContinuousR
|
|||
validForTurnNum = game.getTurnNum();
|
||||
}
|
||||
// skip untap action
|
||||
if (game.getTurn().getStepType() == PhaseStep.UNTAP
|
||||
if (game.getTurnStepType() == PhaseStep.UNTAP
|
||||
&& event.getType() == GameEvent.EventType.UNTAP
|
||||
&& game.isActivePlayer(source.getControllerId())
|
||||
&& event.getTargetId().equals(source.getSourceId())) {
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ public class DontUntapInControllersNextUntapStepTargetEffect extends ContinuousR
|
|||
}
|
||||
}
|
||||
|
||||
if (game.getTurn().getStepType() == PhaseStep.UNTAP && event.getType() == GameEvent.EventType.UNTAP) {
|
||||
if (game.getTurnStepType() == PhaseStep.UNTAP && event.getType() == GameEvent.EventType.UNTAP) {
|
||||
if (handledTargetsDuringTurn.containsKey(event.getTargetId())
|
||||
&& !handledTargetsDuringTurn.get(event.getTargetId())
|
||||
&& getTargetPointer().getTargets(game, source).contains(event.getTargetId())) {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class DontUntapInControllersUntapStepAllEffect extends ContinuousRuleModi
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (game.getTurn().getStepType() == PhaseStep.UNTAP) {
|
||||
if (game.getTurnStepType() == PhaseStep.UNTAP) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null) {
|
||||
switch(targetController) {
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class DontUntapInControllersUntapStepEnchantedEffect extends ContinuousRu
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (game.getTurn().getStepType() == PhaseStep.UNTAP) {
|
||||
if (game.getTurnStepType() == PhaseStep.UNTAP) {
|
||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||
if (enchantment != null && enchantment.getAttachedTo() != null && event.getTargetId().equals(enchantment.getAttachedTo())) {
|
||||
Permanent permanent = game.getPermanent(enchantment.getAttachedTo());
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class DontUntapInControllersUntapStepSourceEffect extends ContinuousRuleM
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (game.getTurn().getStepType() == PhaseStep.UNTAP
|
||||
if (game.getTurnStepType() == PhaseStep.UNTAP
|
||||
&& event.getTargetId().equals(source.getSourceId())) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null && permanent.isControlledBy(game.getActivePlayerId())) {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class DontUntapInControllersUntapStepTargetEffect extends ContinuousRuleM
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (game.getTurn().getStepType() != PhaseStep.UNTAP) {
|
||||
if (game.getTurnStepType() != PhaseStep.UNTAP) {
|
||||
return false;
|
||||
}
|
||||
for (UUID targetId : targetPointer.getTargets(game, source)) {
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public class DontUntapInPlayersNextUntapStepAllEffect extends ContinuousRuleModi
|
|||
}
|
||||
}
|
||||
|
||||
if (game.getTurn().getStepType() == PhaseStep.UNTAP && event.getType() == GameEvent.EventType.UNTAP) {
|
||||
if (game.getTurnStepType() == PhaseStep.UNTAP && event.getType() == GameEvent.EventType.UNTAP) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class UntapAllDuringEachOtherPlayersUntapStepEffect extends ContinuousEff
|
|||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
if (layer == Layer.RulesEffects && game.getStep().getType() == PhaseStep.UNTAP && !source.isControlledBy(game.getActivePlayerId())) {
|
||||
if (layer == Layer.RulesEffects && game.getTurnStepType() == PhaseStep.UNTAP && !source.isControlledBy(game.getActivePlayerId())) {
|
||||
Integer appliedTurn = (Integer) game.getState().getValue(source.getSourceId() + "appliedTurn");
|
||||
if (appliedTurn == null) {
|
||||
appliedTurn = 0;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class UntapSourceDuringEachOtherPlayersUntapStepEffect extends Continuous
|
|||
if (!applied && layer == Layer.RulesEffects) {
|
||||
if (!source.isControlledBy(game.getActivePlayerId())
|
||||
&& game.getStep() != null
|
||||
&& game.getStep().getType() == PhaseStep.UNTAP) {
|
||||
&& game.getTurnStepType() == PhaseStep.UNTAP) {
|
||||
game.getState().setValue(source.getSourceId() + "applied", true);
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
|
|
@ -46,7 +46,7 @@ public class UntapSourceDuringEachOtherPlayersUntapStepEffect extends Continuous
|
|||
}
|
||||
}
|
||||
} else if (applied && layer == Layer.RulesEffects) {
|
||||
if (game.getStep() != null && game.getStep().getType() == PhaseStep.END_TURN) {
|
||||
if (game.getStep() != null && game.getTurnStepType() == PhaseStep.END_TURN) {
|
||||
game.getState().setValue(source.getSourceId() + "applied", false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ public class CastOnlyDuringPhaseStepSourceEffect extends ContinuousRuleModifying
|
|||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
// has to return true, if the spell cannot be cast in the current phase / step
|
||||
if (event.getSourceId().equals(source.getSourceId())) {
|
||||
if ((turnPhase != null && game.getPhase().getType() != turnPhase)
|
||||
|| (phaseStep != null && (game.getTurn().getStepType() != phaseStep))
|
||||
if ((turnPhase != null && game.getTurnPhaseType() != turnPhase)
|
||||
|| (phaseStep != null && (game.getTurnStepType() != phaseStep))
|
||||
|| (condition != null && !condition.apply(game, source))) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue