mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Code cleanup
This commit is contained in:
@@ -1453,22 +1453,23 @@ public class GameAction {
|
||||
Player first = determineFirstTurnPlayer(lastGameOutcome);
|
||||
|
||||
do {
|
||||
if (game.isGameOver()) break; // conceded during "play or draw"
|
||||
if (game.isGameOver()) { break; } // conceded during "play or draw"
|
||||
|
||||
// FControl should determine now if there are any human players.
|
||||
// Where there are none, it should bring up speed controls
|
||||
game.fireEvent(new GameEventGameStarted(game.getType(), first, game.getPlayers()));
|
||||
|
||||
game.setAge(GameStage.Mulligan);
|
||||
for (final Player p1 : game.getPlayers())
|
||||
for (final Player p1 : game.getPlayers()) {
|
||||
p1.drawCards(p1.getMaxHandSize());
|
||||
}
|
||||
|
||||
performMulligans(first, game.getType() == GameType.Commander);
|
||||
if (game.isGameOver()) break; // conceded during "mulligan" prompt
|
||||
if (game.isGameOver()) { break; } // conceded during "mulligan" prompt
|
||||
|
||||
game.setAge(GameStage.Play);
|
||||
|
||||
// THIS CODE WILL WORK WITH PHASE = NULL {
|
||||
//<THIS CODE WILL WORK WITH PHASE = NULL>
|
||||
if (game.getType() == GameType.Planechase) {
|
||||
first.initPlane();
|
||||
}
|
||||
@@ -1479,7 +1480,7 @@ public class GameAction {
|
||||
// Run Trigger beginning of the game
|
||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||
game.getTriggerHandler().runTrigger(TriggerType.NewGame, runParams, false);
|
||||
// }
|
||||
//</THIS CODE WILL WORK WITH PHASE = NULL>
|
||||
|
||||
game.getPhaseHandler().startFirstTurn(first);
|
||||
|
||||
|
||||
@@ -197,7 +197,8 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
|
||||
if (this.bRepeatCleanup) { // for when Cleanup needs to repeat itself
|
||||
this.bRepeatCleanup = false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// If the phase that's ending has a stack of additional phases
|
||||
// Take the LIFO one and move to that instead of the normal one
|
||||
if (this.extraPhases.containsKey(phase)) {
|
||||
@@ -208,7 +209,8 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
this.extraPhases.remove(phase);
|
||||
}
|
||||
this.phase = nextPhase;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.phase = PhaseType.getNext(phase);
|
||||
}
|
||||
}
|
||||
@@ -272,9 +274,11 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
if (isSkippingPhase(phase)) {
|
||||
skipped = true;
|
||||
givePriorityToPlayer = false;
|
||||
if( phase == PhaseType.COMBAT_DECLARE_ATTACKERS )
|
||||
if (phase == PhaseType.COMBAT_DECLARE_ATTACKERS) {
|
||||
playerTurn.removeKeyword("Skip your next combat phase.");
|
||||
} else {
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Perform turn-based actions
|
||||
switch(this.getPhase()) {
|
||||
case UNTAP:
|
||||
@@ -309,8 +313,9 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
declareAttackersTurnBasedAction();
|
||||
game.getStack().unfreezeStack();
|
||||
|
||||
if (combat != null && combat.getAttackers().isEmpty() )
|
||||
if (combat != null && combat.getAttackers().isEmpty()) {
|
||||
combat = null;
|
||||
}
|
||||
|
||||
givePriorityToPlayer = inCombat();
|
||||
break;
|
||||
@@ -328,7 +333,8 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
// no first strikers, skip this step
|
||||
if (!combat.assignCombatDamage(true)) {
|
||||
this.givePriorityToPlayer = false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
combat.dealAssignedDamage();
|
||||
}
|
||||
break;
|
||||
@@ -338,7 +344,8 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
|
||||
if (!combat.assignCombatDamage(false)) {
|
||||
this.givePriorityToPlayer = false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
combat.dealAssignedDamage();
|
||||
}
|
||||
break;
|
||||
@@ -433,9 +440,10 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
p.loseLife(burn);
|
||||
}
|
||||
// Play the Mana Burn sound
|
||||
if ( burn > 0 )
|
||||
if (burn > 0) {
|
||||
game.fireEvent(new GameEventManaBurn(burn, dealDamage));
|
||||
}
|
||||
}
|
||||
|
||||
switch (this.phase) {
|
||||
case UNTAP:
|
||||
@@ -460,8 +468,9 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
combat = null;
|
||||
this.getPlayerTurn().resetAttackedThisCombat();
|
||||
|
||||
if ( eventEndCombat != null )
|
||||
if (eventEndCombat != null) {
|
||||
game.fireEvent(eventEndCombat);
|
||||
}
|
||||
break;
|
||||
|
||||
case CLEANUP:
|
||||
@@ -632,8 +641,9 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
}
|
||||
|
||||
for (final Card c1 : combat.getAllBlockers()) {
|
||||
if ( c1.getDamageHistory().getCreatureBlockedThisCombat() )
|
||||
if (c1.getDamageHistory().getCreatureBlockedThisCombat()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!c1.getDamageHistory().getCreatureBlockedThisCombat()) {
|
||||
for (final SpellAbility ab : CardFactoryUtil.getBushidoEffects(c1)) {
|
||||
@@ -656,8 +666,9 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
}
|
||||
|
||||
List<Card> blockers = combat.getBlockers(a);
|
||||
if ( blockers.isEmpty() )
|
||||
if (blockers.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Run triggers
|
||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||
@@ -748,8 +759,7 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
Player next = getNextActivePlayer();
|
||||
|
||||
if (game.getType() == GameType.Planechase) {
|
||||
for(Card p :game.getActivePlanes())
|
||||
{
|
||||
for (Card p :game.getActivePlanes()) {
|
||||
if (p != null) {
|
||||
p.setController(next, 0);
|
||||
game.getAction().controllerChangeZoneCorrection(p);
|
||||
@@ -947,8 +957,9 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
FThreads.assertExecutedByEdt(false);
|
||||
StopWatch sw = new StopWatch();
|
||||
|
||||
if(phase != null)
|
||||
if (phase != null) {
|
||||
throw new IllegalStateException("Turns already started, call this only once per game");
|
||||
}
|
||||
|
||||
setPlayerTurn(goesFirst);
|
||||
advanceToNextPhase();
|
||||
@@ -958,22 +969,22 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
givePriorityToPlayer = false;
|
||||
|
||||
while (!game.isGameOver()) { // loop only while is playing
|
||||
|
||||
if (DEBUG_PHASES) {
|
||||
System.out.println("\t\tStack: " + game.getStack());
|
||||
System.out.print(FThreads.prependThreadId(debugPrintState(givePriorityToPlayer)));
|
||||
}
|
||||
|
||||
if (givePriorityToPlayer) {
|
||||
if( DEBUG_PHASES )
|
||||
if (DEBUG_PHASES) {
|
||||
sw.start();
|
||||
}
|
||||
|
||||
// Rule 704.3 Whenever a player would get priority, the game checks ... for state-based actions,
|
||||
game.getAction().checkStateEffects();
|
||||
game.fireEvent(new GameEventPlayerPriority(getPlayerTurn(), getPhase(), getPriorityPlayer()));
|
||||
|
||||
// SBA could lead to game over
|
||||
if ( game.isGameOver() ) return;
|
||||
if (game.isGameOver()) { return; }
|
||||
|
||||
pPlayerPriority.getController().takePriority();
|
||||
|
||||
@@ -983,7 +994,8 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
System.out.println("\t\tStack: " + game.getStack());
|
||||
sw.reset();
|
||||
}
|
||||
} else if( DEBUG_PHASES ){
|
||||
}
|
||||
else if (DEBUG_PHASES){
|
||||
System.out.print(" >>\n");
|
||||
}
|
||||
|
||||
@@ -992,7 +1004,7 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
// of Priority
|
||||
Player nextPlayer = game.getNextPlayerAfter(this.getPriorityPlayer());
|
||||
|
||||
if ( game.isGameOver() || nextPlayer == null ) return; // conceded?
|
||||
if (game.isGameOver() || nextPlayer == null) { return; } // conceded?
|
||||
|
||||
// System.out.println(String.format("%s %s: %s passes priority to %s", playerTurn, phase, actingPlayer, nextPlayer));
|
||||
if (getFirstPriority() == nextPlayer) {
|
||||
@@ -1004,11 +1016,13 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
onPhaseEnd();
|
||||
advanceToNextPhase();
|
||||
onPhaseBegin();
|
||||
} else if (!game.getStack().hasSimultaneousStackEntries()) {
|
||||
}
|
||||
else if (!game.getStack().hasSimultaneousStackEntries()) {
|
||||
game.getStack().resolveStack();
|
||||
game.getStack().chooseOrderOfSimultaneousStackEntryAll();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// pass the priority to other player
|
||||
this.pPlayerPriority = nextPlayer;
|
||||
}
|
||||
@@ -1026,8 +1040,9 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
// as it avoids calling any of the phase effects that may be necessary in a less enforced context
|
||||
public final void devModeSet(final PhaseType phase0, final Player player0) {
|
||||
if (null != phase0) this.phase = phase0;
|
||||
if (null != player0 )
|
||||
if (null != player0) {
|
||||
setPlayerTurn(player0);
|
||||
}
|
||||
|
||||
game.fireEvent(new GameEventTurnPhase(this.getPlayerTurn(), this.getPhase(), ""));
|
||||
combat = null; // not-null can be created only when declare attackers phase begins
|
||||
|
||||
Reference in New Issue
Block a user