mirror of
https://github.com/correl/mage.git
synced 2024-12-24 03:00:14 +00:00
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
|
@ -164,8 +164,8 @@ public class GameView implements Serializable {
|
|||
companion.add(new RevealedView(name, state.getCompanion().get(name), game));
|
||||
}
|
||||
}
|
||||
this.phase = state.getTurn().getPhaseType();
|
||||
this.step = state.getTurn().getStepType();
|
||||
this.phase = state.getTurnPhaseType();
|
||||
this.step = state.getTurnStepType();
|
||||
this.turn = state.getTurnNum();
|
||||
this.activePlayerId = state.getActivePlayerId();
|
||||
if (state.getActivePlayerId() != null) {
|
||||
|
|
|
@ -248,7 +248,7 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
|
|||
}
|
||||
val = minimaxAB(node, depth - 1, alpha, beta);
|
||||
} else {
|
||||
logger.trace("Add Action -- alpha: " + alpha + " beta: " + beta + " depth:" + depth + " step:" + game.getTurn().getStepType() + " for player:" + game.getPlayer(game.getActivePlayerId()).getName());
|
||||
logger.trace("Add Action -- alpha: " + alpha + " beta: " + beta + " depth:" + depth + " step:" + game.getTurnStepType() + " for player:" + game.getPlayer(game.getActivePlayerId()).getName());
|
||||
if (allPassed(game)) {
|
||||
if (!game.getStack().isEmpty()) {
|
||||
resolve(node, depth, game);
|
||||
|
@ -291,7 +291,7 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
|
|||
}
|
||||
}
|
||||
node.setScore(val);
|
||||
logger.trace("returning -- score: " + val + " depth:" + depth + " step:" + game.getTurn().getStepType() + " for player:" + game.getPlayer(node.getPlayerId()).getName());
|
||||
logger.trace("returning -- score: " + val + " depth:" + depth + " step:" + game.getTurnStepType() + " for player:" + game.getPlayer(node.getPlayerId()).getName());
|
||||
return val;
|
||||
|
||||
}
|
||||
|
|
|
@ -45,10 +45,10 @@ public class ComputerPlayer7 extends ComputerPlayer6 {
|
|||
logger.info("======================= Turn: " + game.getTurnNum() + " [" + game.getPlayer(game.getActivePlayerId()).getName() + "] =========================================");
|
||||
}
|
||||
logState(game);
|
||||
logger.debug("Priority -- Step: " + (game.getTurn().getStepType() + " ").substring(0, 25) + " ActivePlayer-" + game.getPlayer(game.getActivePlayerId()).getName() + " PriorityPlayer-" + name);
|
||||
logger.debug("Priority -- Step: " + (game.getTurnStepType() + " ").substring(0, 25) + " ActivePlayer-" + game.getPlayer(game.getActivePlayerId()).getName() + " PriorityPlayer-" + name);
|
||||
game.getState().setPriorityPlayerId(playerId);
|
||||
game.firePriorityEvent(playerId);
|
||||
switch (game.getTurn().getStepType()) {
|
||||
switch (game.getTurnStepType()) {
|
||||
case UPKEEP:
|
||||
case DRAW:
|
||||
pass(game);
|
||||
|
|
|
@ -1266,7 +1266,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
if (game.isMainPhase() && game.getStack().isEmpty()) {
|
||||
playLand(game);
|
||||
}
|
||||
switch (game.getTurn().getStepType()) {
|
||||
switch (game.getTurnStepType()) {
|
||||
case UPKEEP:
|
||||
findPlayables(game);
|
||||
break;
|
||||
|
@ -1331,7 +1331,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
}
|
||||
} else {
|
||||
//respond to opponent events
|
||||
switch (game.getTurn().getStepType()) {
|
||||
switch (game.getTurnStepType()) {
|
||||
case UPKEEP:
|
||||
findPlayables(game);
|
||||
break;
|
||||
|
|
|
@ -61,7 +61,7 @@ public class ComputerPlayerMCTS extends ComputerPlayer implements Player {
|
|||
|
||||
@Override
|
||||
public boolean priority(Game game) {
|
||||
if (game.getStep().getType() == PhaseStep.UPKEEP) {
|
||||
if (game.getTurnStepType() == PhaseStep.UPKEEP) {
|
||||
if (!lastPhase.equals(game.getTurn().getValue(game.getTurnNum()))) {
|
||||
logList(game.getTurn().getValue(game.getTurnNum()) + name + " hand: ", new ArrayList(hand.getCards(game)));
|
||||
lastPhase = game.getTurn().getValue(game.getTurnNum());
|
||||
|
@ -236,7 +236,7 @@ public class ComputerPlayerMCTS extends ComputerPlayer implements Player {
|
|||
if (root.getNumChildren() > 0)
|
||||
nodeSizeRatio = root.getVisits() / root.getNumChildren();
|
||||
// logger.info("Ratio: " + nodeSizeRatio);
|
||||
PhaseStep curStep = game.getStep().getType();
|
||||
PhaseStep curStep = game.getTurnStepType();
|
||||
if (action == NextAction.SELECT_ATTACKERS || action == NextAction.SELECT_BLOCKERS) {
|
||||
if (nodeSizeRatio < THINK_MIN_RATIO) {
|
||||
thinkTime = maxThinkTime;
|
||||
|
|
|
@ -89,7 +89,7 @@ public class MCTSNode {
|
|||
if (game.getStep().getStepPart() == StepPart.PRIORITY) {
|
||||
playerId = game.getPriorityPlayerId();
|
||||
} else {
|
||||
if (game.getStep().getType() == PhaseStep.DECLARE_BLOCKERS) {
|
||||
if (game.getTurnStepType() == PhaseStep.DECLARE_BLOCKERS) {
|
||||
playerId = game.getCombat().getDefenders().iterator().next();
|
||||
} else {
|
||||
playerId = game.getActivePlayerId();
|
||||
|
@ -129,7 +129,7 @@ public class MCTSNode {
|
|||
}
|
||||
switch (player.getNextAction()) {
|
||||
case PRIORITY:
|
||||
// logger.info("Priority for player:" + player.getName() + " turn: " + game.getTurnNum() + " phase: " + game.getPhase().getType() + " step: " + game.getStep().getType());
|
||||
// logger.info("Priority for player:" + player.getName() + " turn: " + game.getTurnNum() + " phase: " + game.getTurnPhaseType() + " step: " + game.getTurnStepType());
|
||||
List<Ability> abilities;
|
||||
if (!USE_ACTION_CACHE)
|
||||
abilities = player.getPlayableOptions(game);
|
||||
|
|
|
@ -1022,7 +1022,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
boolean quickStop = false;
|
||||
if (isGameUnderControl()) { // TODO: remove to enable quick stop for controlling player
|
||||
// if was attacked - always stop BEFORE blocker step (to cast extra spells)
|
||||
if (game.getTurn().getStepType() == PhaseStep.DECLARE_ATTACKERS
|
||||
if (game.getTurnStepType() == PhaseStep.DECLARE_ATTACKERS
|
||||
&& game.getCombat().getPlayerDefenders(game).contains(playerId)) {
|
||||
FilterCreatureForCombatBlock filter = filterCreatureForCombatBlock.copy();
|
||||
filter.add(new ControllerIdPredicate(playerId));
|
||||
|
@ -1044,7 +1044,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
|
||||
if (passedUntilEndStepBeforeMyTurn) {
|
||||
if (game.getTurn().getStepType() != PhaseStep.END_TURN) {
|
||||
if (game.getTurnStepType() != PhaseStep.END_TURN) {
|
||||
// other step
|
||||
if (passWithManaPoolCheck(game)) {
|
||||
return false;
|
||||
|
@ -1080,8 +1080,8 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
|
||||
if (passedUntilNextMain) {
|
||||
if (game.getTurn().getStepType() == PhaseStep.POSTCOMBAT_MAIN
|
||||
|| game.getTurn().getStepType() == PhaseStep.PRECOMBAT_MAIN) {
|
||||
if (game.getTurnStepType() == PhaseStep.POSTCOMBAT_MAIN
|
||||
|| game.getTurnStepType() == PhaseStep.PRECOMBAT_MAIN) {
|
||||
// it's main step
|
||||
if (!skippedAtLeastOnce
|
||||
|| (!playerId.equals(game.getActivePlayerId())
|
||||
|
@ -1103,7 +1103,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
|
||||
if (passedUntilEndOfTurn) {
|
||||
if (game.getTurn().getStepType() == PhaseStep.END_TURN) {
|
||||
if (game.getTurnStepType() == PhaseStep.END_TURN) {
|
||||
// it's end of turn step
|
||||
if (!skippedAtLeastOnce
|
||||
|| (playerId.equals(game.getActivePlayerId())
|
||||
|
@ -1271,16 +1271,16 @@ public class HumanPlayer extends PlayerImpl {
|
|||
try {
|
||||
|
||||
if (playerId.equals(game.getActivePlayerId())) {
|
||||
return !controllingPlayer.getUserData().getUserSkipPrioritySteps().getYourTurn().isPhaseStepSet(game.getStep().getType());
|
||||
return !controllingPlayer.getUserData().getUserSkipPrioritySteps().getYourTurn().isPhaseStepSet(game.getTurnStepType());
|
||||
} else {
|
||||
return !controllingPlayer.getUserData().getUserSkipPrioritySteps().getOpponentTurn().isPhaseStepSet(game.getStep().getType());
|
||||
return !controllingPlayer.getUserData().getUserSkipPrioritySteps().getOpponentTurn().isPhaseStepSet(game.getTurnStepType());
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
if (controllingPlayer.getUserData() != null) {
|
||||
if (controllingPlayer.getUserData().getUserSkipPrioritySteps() != null) {
|
||||
if (game.getStep() != null) {
|
||||
if (game.getStep().getType() == null) {
|
||||
logger.error("game.getStep().getType() == null");
|
||||
if (game.getTurnStepType() == null) {
|
||||
logger.error("game.getTurnStepType() == null");
|
||||
}
|
||||
} else {
|
||||
logger.error("game.getStep() == null");
|
||||
|
@ -2659,7 +2659,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
// TODO: chooseUse and other dialogs must be under controlling player
|
||||
if (!chooseUse(Outcome.Detriment, GameLog.getPlayerConfirmColoredText("You still have mana in your mana pool. Pass regardless?")
|
||||
+ GameLog.getSmallSecondLineText(activePlayerText + " / " + game.getStep().getType().toString() + priorityPlayerText), null, game)) {
|
||||
+ GameLog.getSmallSecondLineText(activePlayerText + " / " + game.getTurnStepType().toString() + priorityPlayerText), null, game)) {
|
||||
sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, game, null);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -877,7 +877,7 @@ public class GameController implements GameCallback {
|
|||
private void informOthers(UUID playerId) throws MageException {
|
||||
StringBuilder message = new StringBuilder();
|
||||
if (game.getStep() != null) {
|
||||
message.append(game.getStep().getType().toString()).append(" - ");
|
||||
message.append(game.getTurnStepType().toString()).append(" - ");
|
||||
}
|
||||
message.append("Waiting for ").append(game.getPlayer(playerId).getLogName());
|
||||
for (final Entry<UUID, GameSessionPlayer> entry : getGameSessionsMap().entrySet()) {
|
||||
|
@ -896,10 +896,10 @@ public class GameController implements GameCallback {
|
|||
if (players != null && !players.isEmpty()) {
|
||||
controller = game.getPlayer(players.get(0));
|
||||
}
|
||||
if (controller == null || game.getStep() == null || game.getStep().getType() == null) {
|
||||
if (controller == null || game.getStep() == null || game.getTurnStepType() == null) {
|
||||
return;
|
||||
}
|
||||
final String message = new StringBuilder(game.getStep().getType().toString()).append(" - Waiting for ").append(controller.getName()).toString();
|
||||
final String message = new StringBuilder(game.getTurnStepType().toString()).append(" - Waiting for ").append(controller.getName()).toString();
|
||||
for (final Entry<UUID, GameSessionPlayer> entry : getGameSessionsMap().entrySet()) {
|
||||
boolean skip = players.stream().anyMatch(playerId -> entry.getKey().equals(playerId));
|
||||
if (!skip) {
|
||||
|
@ -1296,10 +1296,10 @@ public class GameController implements GameCallback {
|
|||
sb.append("<font color='red'>FIX command called by ").append(user.getName()).append("</font>");
|
||||
sb.append("<font size='-2'>"); // font resize start for all next logs
|
||||
sb.append("<br>Game ID: ").append(game.getId());
|
||||
if (game.getTurn().getPhaseType() == null) {
|
||||
if (game.getTurnPhaseType() == null) {
|
||||
sb.append("<br>Phase: not started").append(" Step: not started");
|
||||
} else {
|
||||
sb.append("<br>Phase: ").append(game.getTurn().getPhaseType().toString()).append(" Step: ").append(game.getTurn().getStepType().toString());
|
||||
sb.append("<br>Phase: ").append(game.getTurnPhaseType().toString()).append(" Step: ").append(game.getTurnStepType().toString());
|
||||
}
|
||||
// pings info
|
||||
sb.append("<br>");
|
||||
|
|
|
@ -62,7 +62,7 @@ class BeforeCombatDamageCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
PhaseStep phaseStep = game.getStep().getType();
|
||||
PhaseStep phaseStep = game.getTurnStepType();
|
||||
if(phaseStep.getIndex() < PhaseStep.FIRST_COMBAT_DAMAGE.getIndex()) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ enum AshenGhoulCondition implements Condition {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (game.getStep().getType() != PhaseStep.UPKEEP
|
||||
if (game.getTurnStepType() != PhaseStep.UPKEEP
|
||||
|| !game.isActivePlayer(source.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ class BasandraBattleSeraphEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (game.getPhase().getType() == TurnPhase.COMBAT) {
|
||||
if (game.getTurnPhaseType() == TurnPhase.COMBAT) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -68,8 +68,8 @@ enum BerserkersFrenzyCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (game.getPhase().getType() == TurnPhase.COMBAT) {
|
||||
return game.getStep().getType().isBefore(PhaseStep.DECLARE_BLOCKERS);
|
||||
if (game.getTurnPhaseType() == TurnPhase.COMBAT) {
|
||||
return game.getTurnStepType().isBefore(PhaseStep.DECLARE_BLOCKERS);
|
||||
}
|
||||
return !game.getTurn().isDeclareAttackersStepStarted();
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ class BlindingBeamEffect2 extends ContinuousRuleModifyingEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
// prevent untap event of creatures of target player
|
||||
if (game.getTurn().getStepType() == PhaseStep.UNTAP) {
|
||||
if (game.getTurnStepType() == PhaseStep.UNTAP) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null && permanent.isControlledBy(targetPlayerId) && filter.match(permanent, game)) {
|
||||
return true;
|
||||
|
|
|
@ -68,11 +68,11 @@ class BloodFrenzyCastRestriction extends ContinuousRuleModifyingEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if(event.getSourceId().equals(source.getSourceId())) {
|
||||
if(game.getPhase().getType() == TurnPhase.COMBAT
|
||||
if(game.getTurnPhaseType() == TurnPhase.COMBAT
|
||||
// There cannot be a legal target before declare attackers,
|
||||
// so in practice it is limited to these two steps.
|
||||
&& (game.getStep().getType() == PhaseStep.DECLARE_ATTACKERS
|
||||
|| game.getStep().getType() == PhaseStep.DECLARE_BLOCKERS)) {
|
||||
&& (game.getTurnStepType() == PhaseStep.DECLARE_ATTACKERS
|
||||
|| game.getTurnStepType() == PhaseStep.DECLARE_BLOCKERS)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -67,7 +67,7 @@ class CathedralMembraneAbility extends ZoneChangeTriggeredAbility {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (super.checkTrigger(event, game)) {
|
||||
if (game.getPhase().getType() == TurnPhase.COMBAT) {
|
||||
if (game.getTurnPhaseType() == TurnPhase.COMBAT) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ class CorrosiveOozeCombatWatcher extends Watcher {
|
|||
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
|
||||
if (((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
|
||||
if (game.getTurn() != null && TurnPhase.COMBAT == game.getTurn().getPhaseType()) {
|
||||
if (game.getTurn() != null && TurnPhase.COMBAT == game.getTurnPhaseType()) {
|
||||
// Check if a previous blocked or blocked by creatures is leaving the battlefield
|
||||
for (Map.Entry<MageObjectReference, Set<MageObjectReference>> entry : oozeBlocksOrBlocked.entrySet()) {
|
||||
for (MageObjectReference mor : entry.getValue()) {
|
||||
|
|
|
@ -72,7 +72,7 @@ class BeforeEndCombatCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
PhaseStep phaseStep = game.getStep().getType();
|
||||
PhaseStep phaseStep = game.getTurnStepType();
|
||||
if(phaseStep.getIndex() < PhaseStep.END_COMBAT.getIndex()) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ class GideonBattleForgedAttacksIfAbleTargetEffect extends RequirementEffect {
|
|||
if (targetPermanent == null) {
|
||||
return true;
|
||||
}
|
||||
return game.getPhase().getType() == TurnPhase.END && this.isYourNextTurn(game); // discard on end of their next turn
|
||||
return game.getTurnPhaseType() == TurnPhase.END && this.isYourNextTurn(game); // discard on end of their next turn
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -123,7 +123,7 @@ class GideonJuraEffect extends RequirementEffect {
|
|||
|
||||
@Override
|
||||
public boolean isInactive(Ability source, Game game) {
|
||||
return (game.getPhase().getType() == TurnPhase.END && this.isYourNextTurn(game))
|
||||
return (game.getTurnPhaseType() == TurnPhase.END && this.isYourNextTurn(game))
|
||||
// 6/15/2010: If a creature controlled by the affected player can't attack Gideon Jura
|
||||
// (because he's no longer on the battlefield, for example), that player may have it attack you,
|
||||
// another one of your planeswalkers, or nothing at all.
|
||||
|
|
|
@ -91,7 +91,7 @@ class DontUntapIfAttackedLastTurnSourceEffect extends ContinuousRuleModifyingEff
|
|||
|
||||
@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())) {
|
||||
|
|
|
@ -125,7 +125,7 @@ enum HakimLoreweaverCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (PhaseStep.UPKEEP != game.getStep().getType()
|
||||
if (PhaseStep.UPKEEP != game.getTurnStepType()
|
||||
|| !game.isActivePlayer(source.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ class HalfdaneSetBasePowerToughnessEffect extends SetBasePowerToughnessSourceEff
|
|||
|
||||
@Override
|
||||
public boolean isInactive(Ability source, Game game) {
|
||||
if (super.isInactive(source, game) && game.getStep().getType().isAfter(PhaseStep.UPKEEP)) {
|
||||
if (super.isInactive(source, game) && game.getTurnStepType().isAfter(PhaseStep.UPKEEP)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -69,7 +69,7 @@ class HandToHandEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (game.getPhase().getType() == TurnPhase.COMBAT) {
|
||||
if (game.getTurnPhaseType() == TurnPhase.COMBAT) {
|
||||
MageObject object = game.getObject(event.getSourceId());
|
||||
if (event.getType() == GameEvent.EventType.CAST_SPELL) {
|
||||
if (object != null && object.isInstant(game)) {
|
||||
|
|
|
@ -86,7 +86,7 @@ class HeavyArbalestEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (game.getTurn().getStepType() == PhaseStep.UNTAP) {
|
||||
if (game.getTurnStepType() == PhaseStep.UNTAP) {
|
||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||
Permanent equipped = game.getPermanent(equipment.getAttachedTo());
|
||||
|
|
|
@ -86,7 +86,7 @@ class HullbreacherReplacementEffect extends ReplacementEffectImpl {
|
|||
return false;
|
||||
}
|
||||
if (!game.isActivePlayer(event.getPlayerId())
|
||||
|| game.getStep().getType() != PhaseStep.DRAW) {
|
||||
|| game.getTurnStepType() != PhaseStep.DRAW) {
|
||||
return true;
|
||||
}
|
||||
CardsDrawnDuringDrawStepWatcher watcher = game.getState().getWatcher(CardsDrawnDuringDrawStepWatcher.class);
|
||||
|
|
|
@ -116,7 +116,7 @@ class IllusionistsGambitRequirementEffect extends RequirementEffect {
|
|||
|
||||
@Override
|
||||
public boolean isInactive(Ability source, Game game) {
|
||||
if (game.getTurn().getStepType() == PhaseStep.END_COMBAT) {
|
||||
if (game.getTurnStepType() == PhaseStep.END_COMBAT) {
|
||||
return !Objects.equals(game.getTurn().getPhase(), phase);
|
||||
}
|
||||
return false;
|
||||
|
@ -158,7 +158,7 @@ class IllusionistsGambitRestrictionEffect extends RestrictionEffect {
|
|||
|
||||
@Override
|
||||
public boolean isInactive(Ability source, Game game) {
|
||||
if (game.getTurn().getStepType() == PhaseStep.END_COMBAT) {
|
||||
if (game.getTurnStepType() == PhaseStep.END_COMBAT) {
|
||||
return !Objects.equals(game.getTurn().getPhase(), phase);
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -81,7 +81,7 @@ class IslandSanctuaryEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
return source.isControlledBy(event.getPlayerId()) && game.getTurn().getStepType() == PhaseStep.DRAW && game.getActivePlayerId().equals(source.getControllerId());
|
||||
return source.isControlledBy(event.getPlayerId()) && game.getTurnStepType() == PhaseStep.DRAW && game.getActivePlayerId().equals(source.getControllerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -109,7 +109,7 @@ class KillSwitchUntapEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (game.getTurn().getStepType() != PhaseStep.UNTAP) {
|
||||
if (game.getTurnStepType() != PhaseStep.UNTAP) {
|
||||
return false;
|
||||
}
|
||||
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
|
||||
|
|
|
@ -104,7 +104,7 @@ class ManaCacheManaAbility extends ActivatedManaAbilityImpl {
|
|||
Player player = game.getPlayer(playerId);
|
||||
if (player == null
|
||||
|| !playerId.equals(game.getActivePlayerId())
|
||||
|| !game.getStep().getType().isBefore(PhaseStep.END_TURN)) {
|
||||
|| !game.getTurnStepType().isBefore(PhaseStep.END_TURN)) {
|
||||
return ActivationStatus.getFalse();
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ class MarisiBreakerOfTheCoilSpellEffect extends ContinuousRuleModifyingEffectImp
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
return game.getPhase().getType() == TurnPhase.COMBAT
|
||||
return game.getTurnPhaseType() == TurnPhase.COMBAT
|
||||
&& game.getOpponents(source.getControllerId()).contains(event.getPlayerId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ class MongrelPackAbility extends ZoneChangeTriggeredAbility {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (super.checkTrigger(event, game)) {
|
||||
if (game.getPhase().getType() == TurnPhase.COMBAT) {
|
||||
if (game.getTurnPhaseType() == TurnPhase.COMBAT) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ enum MoraugFuryOfAkoumCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return game.isActivePlayer(source.getControllerId()) && game.getPhase().getType().isMain();
|
||||
return game.isActivePlayer(source.getControllerId()) && game.getTurnPhaseType().isMain();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ class MoraugFuryOfAkoumCombatEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
TurnPhase turnPhase = game.getPhase().getType();
|
||||
TurnPhase turnPhase = game.getTurnPhaseType();
|
||||
for (TurnMod turnMod : game.getState().getTurnMods()) {
|
||||
if ("moraug".equals(turnMod.getNote())
|
||||
&& turnMod.getPlayerId().equals(source.getControllerId())
|
||||
|
|
|
@ -58,7 +58,7 @@ enum NemesisPhoenixCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (game.getStep().getType() != PhaseStep.DECLARE_ATTACKERS) {
|
||||
if (game.getTurnStepType() != PhaseStep.DECLARE_ATTACKERS) {
|
||||
return false;
|
||||
}
|
||||
Set<UUID> opponents = game.getOpponents(source.getControllerId());
|
||||
|
|
|
@ -89,7 +89,7 @@ class NotionThiefReplacementEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
|
||||
if (game.isActivePlayer(event.getPlayerId()) && game.getStep().getType() == PhaseStep.DRAW) {
|
||||
if (game.isActivePlayer(event.getPlayerId()) && game.getTurnStepType() == PhaseStep.DRAW) {
|
||||
CardsDrawnDuringDrawStepWatcher watcher = game.getState().getWatcher(CardsDrawnDuringDrawStepWatcher.class);
|
||||
if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) > 0) {
|
||||
return true;
|
||||
|
|
|
@ -150,7 +150,7 @@ class OracleEnVecMustAttackRequirementEffect extends RequirementEffect {
|
|||
|
||||
@Override
|
||||
public boolean isInactive(Ability source, Game game) {
|
||||
return game.getPhase().getType() == TurnPhase.END && this.isYourNextTurn(game);
|
||||
return game.getTurnPhaseType() == TurnPhase.END && this.isYourNextTurn(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -199,7 +199,7 @@ class OracleEnVecCantAttackRestrictionEffect extends RestrictionEffect {
|
|||
|
||||
@Override
|
||||
public boolean isInactive(Ability source, Game game) {
|
||||
return game.getPhase().getType() == TurnPhase.END && this.isYourNextTurn(game);
|
||||
return game.getTurnPhaseType() == TurnPhase.END && this.isYourNextTurn(game);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ class RowanKenrithAttackEffect extends RequirementEffect {
|
|||
|
||||
@Override
|
||||
public boolean isInactive(Ability source, Game game) {
|
||||
return (game.getPhase().getType() == TurnPhase.END
|
||||
return (game.getTurnPhaseType() == TurnPhase.END
|
||||
&& this.isYourNextTurn(game));
|
||||
}
|
||||
|
||||
|
|
|
@ -75,8 +75,8 @@ class SizzlingSoloistEffect extends RequirementEffect {
|
|||
return true;
|
||||
}
|
||||
return game.isActivePlayer(game.getControllerId(getTargetPointer().getFirst(game, source)))
|
||||
&& game.getPhase().getType() == TurnPhase.COMBAT
|
||||
&& game.getStep().getType() == PhaseStep.END_COMBAT;
|
||||
&& game.getTurnPhaseType() == TurnPhase.COMBAT
|
||||
&& game.getTurnStepType() == PhaseStep.END_COMBAT;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -64,7 +64,7 @@ class SphinxOfTheSecondSunEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
TurnPhase turnPhase = game.getPhase().getType();
|
||||
TurnPhase turnPhase = game.getTurnPhaseType();
|
||||
for (TurnMod turnMod : game.getState().getTurnMods()) {
|
||||
if ("sphinxSecondSun".equals(turnMod.getNote())
|
||||
&& turnMod.getPlayerId().equals(source.getControllerId())
|
||||
|
|
|
@ -69,7 +69,7 @@ class StorageMatrixRestrictionEffect extends RestrictionEffect {
|
|||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
if (game.getStep().getType() == PhaseStep.UNTAP) {
|
||||
if (game.getTurnStepType() == PhaseStep.UNTAP) {
|
||||
if (game.getTurnNum() != turn) {
|
||||
turn = game.getTurnNum();
|
||||
applies = false;
|
||||
|
|
|
@ -101,7 +101,7 @@ class DontUntapIfAttackedLastTurnEnchantedEffect extends ContinuousRuleModifying
|
|||
|
||||
@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());
|
||||
|
|
|
@ -59,7 +59,7 @@ class TauntEffect extends RequirementEffect {
|
|||
|
||||
@Override
|
||||
public boolean isInactive(Ability source, Game game) {
|
||||
return game.getPhase().getType() == TurnPhase.END && this.isYourNextTurn(game);
|
||||
return game.getTurnPhaseType() == TurnPhase.END && this.isYourNextTurn(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -85,8 +85,8 @@ class TrenchBehemothEffect extends RequirementEffect {
|
|||
return true;
|
||||
}
|
||||
return game.isActivePlayer(game.getControllerId(getTargetPointer().getFirst(game, source)))
|
||||
&& game.getPhase().getType() == TurnPhase.COMBAT
|
||||
&& game.getStep().getType() == PhaseStep.END_COMBAT;
|
||||
&& game.getTurnPhaseType() == TurnPhase.COMBAT
|
||||
&& game.getTurnStepType() == PhaseStep.END_COMBAT;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -69,7 +69,7 @@ class TsabosWebPreventUntapEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
|
||||
@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 && permanent.isLand(game)) {
|
||||
for (Ability ability :permanent.getAbilities()) {
|
||||
|
|
|
@ -57,7 +57,7 @@ class UnwindingClockEffect extends ContinuousEffectImpl {
|
|||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
boolean applied = Boolean.TRUE.equals(game.getState().getValue(source.getSourceId() + "applied"));
|
||||
if (!applied && layer == Layer.RulesEffects) {
|
||||
if (!game.isActivePlayer(source.getControllerId()) && game.getStep().getType() == PhaseStep.UNTAP) {
|
||||
if (!game.isActivePlayer(source.getControllerId()) && game.getTurnStepType() == PhaseStep.UNTAP) {
|
||||
game.getState().setValue(source.getSourceId() + "applied", true);
|
||||
for (Permanent artifact : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
|
||||
boolean untap = true;
|
||||
|
@ -70,7 +70,7 @@ class UnwindingClockEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
}
|
||||
} else if (applied && layer == Layer.RulesEffects) {
|
||||
if (game.getStep().getType() == PhaseStep.END_TURN) {
|
||||
if (game.getTurnStepType() == PhaseStep.END_TURN) {
|
||||
game.getState().setValue(source.getSourceId() + "applied", false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ class UrbanBurgeoningUntapEffect extends ContinuousEffectImpl {
|
|||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
boolean applied = Boolean.TRUE.equals(game.getState().getValue(source.getSourceId() + "applied"));
|
||||
if (!applied && layer == Layer.RulesEffects) {
|
||||
if (!game.isActivePlayer(source.getControllerId()) && game.getStep().getType() == PhaseStep.UNTAP) {
|
||||
if (!game.isActivePlayer(source.getControllerId()) && game.getTurnStepType() == PhaseStep.UNTAP) {
|
||||
game.getState().setValue(source.getSourceId() + "applied", true);
|
||||
Permanent land = game.getPermanent(source.getSourceId());
|
||||
boolean untap = true;
|
||||
|
@ -82,7 +82,7 @@ class UrbanBurgeoningUntapEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
}
|
||||
} else if (applied && layer == Layer.RulesEffects) {
|
||||
if (game.getStep().getType() == PhaseStep.END_TURN) {
|
||||
if (game.getTurnStepType() == PhaseStep.END_TURN) {
|
||||
game.getState().setValue(source.getSourceId() + "applied", false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ class VraskaTheUnseenGainAbilityEffect extends ContinuousEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean isInactive(Ability source, Game game) {
|
||||
return game.getPhase().getType() == TurnPhase.END && this.isYourNextTurn(game);
|
||||
return game.getTurnPhaseType() == TurnPhase.END && this.isYourNextTurn(game);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ class VulshokGauntletsEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (game.getTurn().getStepType() == PhaseStep.UNTAP) {
|
||||
if (game.getTurnStepType() == PhaseStep.UNTAP) {
|
||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||
Permanent equipped = game.getPermanent(equipment.getAttachedTo());
|
||||
|
|
|
@ -70,7 +70,7 @@ class WallOfDustRestrictionEffect extends RestrictionEffect {
|
|||
return true;
|
||||
}
|
||||
|
||||
return game.getPhase().getType() == TurnPhase.END && this.isYourNextTurn(game);
|
||||
return game.getTurnPhaseType() == TurnPhase.END && this.isYourNextTurn(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -71,7 +71,7 @@ class WiretappingTriggeredAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return game.isActivePlayer(event.getPlayerId())
|
||||
&& game.getStep().getType() == PhaseStep.DRAW
|
||||
&& game.getTurnStepType() == PhaseStep.DRAW
|
||||
&& isControlledBy(event.getPlayerId())
|
||||
&& game
|
||||
.getState()
|
||||
|
|
|
@ -73,7 +73,7 @@ class ZursWeirdingReplacementEffect extends ReplacementEffectImpl {
|
|||
return false;
|
||||
}
|
||||
// Reveals it instead
|
||||
player.revealCards(sourceObject.getIdName() + " next draw of " + player.getName() + " (" + game.getTurnNum() + '|' + game.getPhase().getType() + ')', new CardsImpl(card), game);
|
||||
player.revealCards(sourceObject.getIdName() + " next draw of " + player.getName() + " (" + game.getTurnNum() + '|' + game.getTurnPhaseType() + ')', new CardsImpl(card), game);
|
||||
|
||||
// Then any other player may pay 2 life. If a player does, put that card into its owner's graveyard
|
||||
String message = "Pay 2 life to put " + card.getLogName() + " into " + player.getLogName() + " graveyard?";
|
||||
|
|
|
@ -48,6 +48,6 @@ public class PhageTheUntouchableTest extends CardTestPlayerBase {
|
|||
|
||||
Assert.assertTrue("Game has ended.", currentGame.hasEnded());
|
||||
assertWonTheGame(playerA);
|
||||
Assert.assertTrue("Game ist At end phase", currentGame.getPhase().getType() == TurnPhase.END);
|
||||
Assert.assertTrue("Game ist At end phase", currentGame.getTurnPhaseType() == TurnPhase.END);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -567,7 +567,7 @@ public class TestPlayer implements Player {
|
|||
if (actionsToRemoveLater.size() > 0) {
|
||||
List<PlayerAction> removed = new ArrayList<>();
|
||||
actionsToRemoveLater.forEach((action, step) -> {
|
||||
if (game.getStep().getType() != step) {
|
||||
if (game.getTurnStepType() != step) {
|
||||
action.onActionRemovedLater(game, this);
|
||||
actions.remove(action);
|
||||
removed.add(action);
|
||||
|
@ -584,7 +584,7 @@ public class TestPlayer implements Player {
|
|||
List<PlayerAction> tempActions = new ArrayList<>();
|
||||
tempActions.addAll(actions);
|
||||
for (PlayerAction action : tempActions) {
|
||||
if (action.getTurnNum() == game.getTurnNum() && action.getStep() == game.getStep().getType()) {
|
||||
if (action.getTurnNum() == game.getTurnNum() && action.getStep() == game.getTurnStepType()) {
|
||||
|
||||
if (action.getAction().startsWith(ACTIVATE_ABILITY)) {
|
||||
String command = action.getAction();
|
||||
|
@ -677,9 +677,8 @@ public class TestPlayer implements Player {
|
|||
printEnd();
|
||||
// TODO: enable assert and rewrite failed activateManaAbility tests
|
||||
// (must use checkAbility instead multiple mana calls)
|
||||
LOGGER.warn("WARNING, test must be rewritten to use checkAbility instead multiple mana calls");
|
||||
//Assert.fail("Can't find mana ability to activate command: " + command);
|
||||
new Exception("WARNING, test must be rewritten to use checkAbility instead multiple mana calls")
|
||||
.printStackTrace();
|
||||
} else if (action.getAction().startsWith("addCounters:")) {
|
||||
String command = action.getAction();
|
||||
command = command.substring(command.indexOf("addCounters:") + 12);
|
||||
|
@ -748,7 +747,7 @@ public class TestPlayer implements Player {
|
|||
// play step
|
||||
if (command.equals(AI_COMMAND_PLAY_STEP)) {
|
||||
AIRealGameSimulation = true; // disable on action's remove
|
||||
actionsToRemoveLater.put(action, game.getStep().getType());
|
||||
actionsToRemoveLater.put(action, game.getTurnStepType());
|
||||
computerPlayer.priority(game);
|
||||
return true;
|
||||
}
|
||||
|
@ -1966,7 +1965,7 @@ public class TestPlayer implements Player {
|
|||
}
|
||||
Assert.fail("Missing " + choiceType.toUpperCase(Locale.ENGLISH) + " def for"
|
||||
+ " turn " + game.getTurnNum()
|
||||
+ ", step " + (game.getStep() != null ? game.getStep().getType().name() : "not started")
|
||||
+ ", step " + (game.getStep() != null ? game.getTurnStepType().name() : "not started")
|
||||
+ ", " + this.getName()
|
||||
+ "\n" + reason);
|
||||
}
|
||||
|
|
|
@ -23,13 +23,13 @@ public class DealsDamageToOneOrMoreCreaturesTriggeredAbility extends DealsDamage
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (super.checkTrigger(event, game)) {
|
||||
// check that combat damage does only once trigger also if multiple creatures were damaged because they block or were blocked by source
|
||||
if (game.getTurn().getStepType() == PhaseStep.COMBAT_DAMAGE
|
||||
|| game.getTurn().getStepType() == PhaseStep.FIRST_COMBAT_DAMAGE) {
|
||||
if (game.getTurnStepType() == PhaseStep.COMBAT_DAMAGE
|
||||
|| game.getTurnStepType() == PhaseStep.FIRST_COMBAT_DAMAGE) {
|
||||
String stepHash = (String) game.getState().getValue("damageStep" + getOriginalId());
|
||||
String newStepHash = game.getStep().getType().toString() + game.getTurnNum();
|
||||
String newStepHash = game.getTurnStepType().toString() + game.getTurnNum();
|
||||
if (!newStepHash.equals(stepHash)) {
|
||||
// this ability did not trigger during this damage step
|
||||
game.getState().setValue("damageStep" + getOriginalId(), game.getStep().getType().toString() + game.getTurnNum());
|
||||
game.getState().setValue("damageStep" + getOriginalId(), game.getTurnStepType().toString() + game.getTurnNum());
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -18,7 +18,7 @@ public enum AddendumCondition implements Condition {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (!game.isActivePlayer(source.getControllerId()) ||
|
||||
!game.getPhase().getType().isMain()) {
|
||||
!game.getTurnPhaseType().isMain()) {
|
||||
return false;
|
||||
}
|
||||
if (CastFromEverywhereSourceCondition.instance.apply(game, source)) {
|
||||
|
|
|
@ -18,8 +18,8 @@ public enum AfterBlockersAreDeclaredCondition implements Condition {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
|
||||
return !(game.getStep().getType() == PhaseStep.BEGIN_COMBAT
|
||||
|| game.getStep().getType() == PhaseStep.DECLARE_ATTACKERS);
|
||||
return !(game.getTurnStepType() == PhaseStep.BEGIN_COMBAT
|
||||
|| game.getTurnStepType() == PhaseStep.DECLARE_ATTACKERS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@ public enum AfterCombatCondition implements Condition {
|
|||
@Override
|
||||
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return game.getStep().getType().isAfter(PhaseStep.END_COMBAT);
|
||||
return game.getTurnStepType().isAfter(PhaseStep.END_COMBAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -14,7 +14,7 @@ public enum AfterUpkeepStepCondtion implements Condition {
|
|||
@Override
|
||||
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return game.getStep().getType().isAfter(PhaseStep.UPKEEP);
|
||||
return game.getTurnStepType().isAfter(PhaseStep.UPKEEP);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,7 @@ public enum BeforeBlockersAreDeclaredCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return game.getStep().getType().isBefore(PhaseStep.DECLARE_BLOCKERS);
|
||||
return game.getTurnStepType().isBefore(PhaseStep.DECLARE_BLOCKERS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,7 +28,7 @@ public class IsPhaseCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return turnPhase == game.getTurn().getPhaseType() && (!yourTurn || game.getActivePlayerId().equals(source.getControllerId()));
|
||||
return turnPhase == game.getTurnPhaseType() && (!yourTurn || game.getActivePlayerId().equals(source.getControllerId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,7 +26,7 @@ public class IsStepCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return phaseStep == game.getStep().getType() && (!onlyDuringYourSteps || game.isActivePlayer(source.getControllerId()));
|
||||
return phaseStep == game.getTurnStepType() && (!onlyDuringYourSteps || game.isActivePlayer(source.getControllerId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -201,7 +201,7 @@ public class ContinuousEffects implements Serializable {
|
|||
updateTimestamps(timestampGroupName, layerEffects);
|
||||
layerEffects.sort(Comparator.comparingLong(ContinuousEffect::getOrder));
|
||||
/* debug effects apply order:
|
||||
if (game.getStep() != null) System.out.println("layr - " + game.getTurnNum() + "." + game.getStep().getType() + ": layers " + layerEffects.size()
|
||||
if (game.getStep() != null) System.out.println("layr - " + game.getTurnNum() + "." + game.getTurnStepType() + ": layers " + layerEffects.size()
|
||||
+ " - " + layerEffects.stream().map(l -> l.getClass().getSimpleName()).collect(Collectors.joining(", "))
|
||||
+ " - " + callName);
|
||||
//*/
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class ArtificialScoringSystem implements ScoringSystem {
|
|||
if (game.getStep() == null) {
|
||||
return 0;
|
||||
}
|
||||
return ScoringConstants.LOSE_GAME_SCORE + game.getTurnNum() * 2500 + game.getStep().getType().getIndex() * 200;
|
||||
return ScoringConstants.LOSE_GAME_SCORE + game.getTurnNum() * 2500 + game.getTurnStepType().getIndex() * 200;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -180,6 +180,19 @@ public interface Game extends MageItem, Serializable, Copyable<Game> {
|
|||
|
||||
Turn getTurn();
|
||||
|
||||
/**
|
||||
* @return can return null in non started games
|
||||
*/
|
||||
PhaseStep getTurnStepType();
|
||||
|
||||
/**
|
||||
* @return can return null in non started games
|
||||
*/
|
||||
TurnPhase getTurnPhaseType();
|
||||
|
||||
/**
|
||||
* @return can return null in non started games
|
||||
*/
|
||||
Phase getPhase();
|
||||
|
||||
Step getStep();
|
||||
|
|
|
@ -2882,6 +2882,16 @@ public abstract class GameImpl implements Game {
|
|||
return state.getTurn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhaseStep getTurnStepType() {
|
||||
return state.getTurnStepType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TurnPhase getTurnPhaseType() {
|
||||
return state.getTurnPhaseType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Phase getPhase() {
|
||||
return state.getTurn().getPhase();
|
||||
|
@ -2919,7 +2929,7 @@ public abstract class GameImpl implements Game {
|
|||
|
||||
@Override
|
||||
public boolean isMainPhase() {
|
||||
return state.getTurn().getStepType() == PhaseStep.PRECOMBAT_MAIN || state.getTurn().getStepType() == PhaseStep.POSTCOMBAT_MAIN;
|
||||
return state.getTurnStepType() == PhaseStep.PRECOMBAT_MAIN || state.getTurnStepType() == PhaseStep.POSTCOMBAT_MAIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,6 +7,8 @@ import mage.abilities.effects.ContinuousEffect;
|
|||
import mage.abilities.effects.ContinuousEffects;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.cards.*;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.TurnPhase;
|
||||
import mage.constants.Zone;
|
||||
import mage.designations.Designation;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
|
@ -22,6 +24,8 @@ import mage.game.permanent.PermanentCard;
|
|||
import mage.game.permanent.PermanentToken;
|
||||
import mage.game.stack.SpellStack;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.game.turn.Phase;
|
||||
import mage.game.turn.Step;
|
||||
import mage.game.turn.Turn;
|
||||
import mage.game.turn.TurnMods;
|
||||
import mage.players.Player;
|
||||
|
@ -572,6 +576,19 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
return turn;
|
||||
}
|
||||
|
||||
public PhaseStep getTurnStepType() {
|
||||
Turn turn = this.getTurn();
|
||||
Phase phase = turn != null ? turn.getPhase() : null;
|
||||
Step step = phase != null ? phase.getStep() : null;
|
||||
return step != null ? step.getType() : null;
|
||||
}
|
||||
|
||||
public TurnPhase getTurnPhaseType() {
|
||||
Turn turn = this.getTurn();
|
||||
Phase phase = turn != null ? turn.getPhase() : null;
|
||||
return phase != null ? phase.getType() : null;
|
||||
}
|
||||
|
||||
public Combat getCombat() {
|
||||
return combat;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class LukeSkywalkerEmblemEffect extends PreventionEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (game.getPhase().getType() == TurnPhase.COMBAT
|
||||
if (game.getTurnPhaseType() == TurnPhase.COMBAT
|
||||
&& super.applies(event, source, game)
|
||||
&& event.getType() == GameEvent.EventType.DAMAGE_PLAYER) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
|
|
|
@ -90,7 +90,7 @@ class EdgeOfMalacolEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
// Prevent untap event of creatures of target player
|
||||
if (game.getTurn().getStepType() == PhaseStep.UNTAP) {
|
||||
if (game.getTurnStepType() == PhaseStep.UNTAP) {
|
||||
Plane cPlane = game.getState().getCurrentPlane();
|
||||
if (cPlane == null) {
|
||||
return false;
|
||||
|
|
|
@ -84,13 +84,6 @@ public class Turn implements Serializable {
|
|||
return null;
|
||||
}
|
||||
|
||||
public PhaseStep getStepType() {
|
||||
if (currentPhase != null && currentPhase.getStep() != null) {
|
||||
return currentPhase.getStep().getType();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param game
|
||||
* @param activePlayer
|
||||
|
@ -148,8 +141,8 @@ public class Turn implements Serializable {
|
|||
public void resumePlay(Game game, boolean wasPaused) {
|
||||
activePlayerId = game.getActivePlayerId();
|
||||
UUID priorityPlayerId = game.getPriorityPlayerId();
|
||||
TurnPhase phaseType = game.getPhase().getType();
|
||||
PhaseStep stepType = game.getStep().getType();
|
||||
TurnPhase phaseType = game.getTurnPhaseType();
|
||||
PhaseStep stepType = game.getTurnStepType();
|
||||
|
||||
Iterator<Phase> it = phases.iterator();
|
||||
Phase phase;
|
||||
|
|
|
@ -271,7 +271,7 @@ public class ManaPool implements Serializable {
|
|||
|
||||
private int emptyItem(ManaPoolItem item, Emptiable toEmpty, Game game, ManaType manaType) {
|
||||
if (item.getDuration() == Duration.EndOfTurn
|
||||
&& game.getPhase().getType() != TurnPhase.END) {
|
||||
&& game.getTurnPhaseType() != TurnPhase.END) {
|
||||
return 0;
|
||||
}
|
||||
if (!manaBecomesColorless) {
|
||||
|
|
|
@ -2407,7 +2407,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
case PASS_PRIORITY_UNTIL_TURN_END_STEP: // F5
|
||||
resetPlayerPassedActions();
|
||||
passedUntilEndOfTurn = true;
|
||||
skippedAtLeastOnce = PhaseStep.END_TURN != game.getTurn().getStepType();
|
||||
skippedAtLeastOnce = PhaseStep.END_TURN != game.getTurnStepType();
|
||||
this.skip();
|
||||
break;
|
||||
case PASS_PRIORITY_UNTIL_NEXT_TURN: // F4
|
||||
|
@ -2423,8 +2423,8 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
case PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE: //F7
|
||||
resetPlayerPassedActions();
|
||||
passedUntilNextMain = true;
|
||||
skippedAtLeastOnce = !(game.getTurn().getStepType() == PhaseStep.POSTCOMBAT_MAIN
|
||||
|| game.getTurn().getStepType() == PhaseStep.PRECOMBAT_MAIN);
|
||||
skippedAtLeastOnce = !(game.getTurnStepType() == PhaseStep.POSTCOMBAT_MAIN
|
||||
|| game.getTurnStepType() == PhaseStep.PRECOMBAT_MAIN);
|
||||
this.skip();
|
||||
break;
|
||||
case PASS_PRIORITY_UNTIL_STACK_RESOLVED: // Default F10 - Skips until the current stack is resolved
|
||||
|
|
Loading…
Reference in a new issue