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:
@@ -414,7 +414,7 @@ public enum FControl implements KeyEventDispatcher {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
game.isGameOver(); // this is synchronized method - it's used to make Game-0 thread see changes made here
|
game.isGameOver(); // this is synchronized method - it's used to make Game-0 thread see changes made here
|
||||||
inputQueue.onGameOver(false); // release any waiting input, effectively passing priority
|
inputQueue.onGameOver(false); //release any waiting input, effectively passing priority
|
||||||
}
|
}
|
||||||
|
|
||||||
playbackControl.onGameStopRequested();
|
playbackControl.onGameStopRequested();
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class InputQueue extends Observable {
|
|||||||
* TODO: Write javadoc for this method.
|
* TODO: Write javadoc for this method.
|
||||||
*/
|
*/
|
||||||
public void onGameOver(boolean releaseAllInputs) {
|
public void onGameOver(boolean releaseAllInputs) {
|
||||||
for (InputSynchronized inp : inputStack ) {
|
for (InputSynchronized inp : inputStack) {
|
||||||
inp.relaseLatchWhenGameIsOver();
|
inp.relaseLatchWhenGameIsOver();
|
||||||
if (!releaseAllInputs) {
|
if (!releaseAllInputs) {
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1453,33 +1453,34 @@ public class GameAction {
|
|||||||
Player first = determineFirstTurnPlayer(lastGameOutcome);
|
Player first = determineFirstTurnPlayer(lastGameOutcome);
|
||||||
|
|
||||||
do {
|
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.
|
// FControl should determine now if there are any human players.
|
||||||
// Where there are none, it should bring up speed controls
|
// Where there are none, it should bring up speed controls
|
||||||
game.fireEvent(new GameEventGameStarted(game.getType(), first, game.getPlayers()));
|
game.fireEvent(new GameEventGameStarted(game.getType(), first, game.getPlayers()));
|
||||||
|
|
||||||
game.setAge(GameStage.Mulligan);
|
game.setAge(GameStage.Mulligan);
|
||||||
for (final Player p1 : game.getPlayers())
|
for (final Player p1 : game.getPlayers()) {
|
||||||
p1.drawCards(p1.getMaxHandSize());
|
p1.drawCards(p1.getMaxHandSize());
|
||||||
|
}
|
||||||
|
|
||||||
performMulligans(first, game.getType() == GameType.Commander);
|
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);
|
game.setAge(GameStage.Play);
|
||||||
|
|
||||||
// THIS CODE WILL WORK WITH PHASE = NULL {
|
//<THIS CODE WILL WORK WITH PHASE = NULL>
|
||||||
if (game.getType() == GameType.Planechase) {
|
if (game.getType() == GameType.Planechase) {
|
||||||
first.initPlane();
|
first.initPlane();
|
||||||
}
|
}
|
||||||
|
|
||||||
runOpeningHandActions(first);
|
runOpeningHandActions(first);
|
||||||
checkStateEffects(); // why?
|
checkStateEffects(); // why?
|
||||||
|
|
||||||
// Run Trigger beginning of the game
|
// Run Trigger beginning of the game
|
||||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||||
game.getTriggerHandler().runTrigger(TriggerType.NewGame, runParams, false);
|
game.getTriggerHandler().runTrigger(TriggerType.NewGame, runParams, false);
|
||||||
// }
|
//</THIS CODE WILL WORK WITH PHASE = NULL>
|
||||||
|
|
||||||
game.getPhaseHandler().startFirstTurn(first);
|
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
|
if (this.bRepeatCleanup) { // for when Cleanup needs to repeat itself
|
||||||
this.bRepeatCleanup = false;
|
this.bRepeatCleanup = false;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// If the phase that's ending has a stack of additional phases
|
// 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
|
// Take the LIFO one and move to that instead of the normal one
|
||||||
if (this.extraPhases.containsKey(phase)) {
|
if (this.extraPhases.containsKey(phase)) {
|
||||||
@@ -208,7 +209,8 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
this.extraPhases.remove(phase);
|
this.extraPhases.remove(phase);
|
||||||
}
|
}
|
||||||
this.phase = nextPhase;
|
this.phase = nextPhase;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
this.phase = PhaseType.getNext(phase);
|
this.phase = PhaseType.getNext(phase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -269,12 +271,14 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
private final void onPhaseBegin() {
|
private final void onPhaseBegin() {
|
||||||
boolean skipped = false;
|
boolean skipped = false;
|
||||||
|
|
||||||
if ( isSkippingPhase(phase) ) {
|
if (isSkippingPhase(phase)) {
|
||||||
skipped = true;
|
skipped = true;
|
||||||
givePriorityToPlayer = false;
|
givePriorityToPlayer = false;
|
||||||
if( phase == PhaseType.COMBAT_DECLARE_ATTACKERS )
|
if (phase == PhaseType.COMBAT_DECLARE_ATTACKERS) {
|
||||||
playerTurn.removeKeyword("Skip your next combat phase.");
|
playerTurn.removeKeyword("Skip your next combat phase.");
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
// Perform turn-based actions
|
// Perform turn-based actions
|
||||||
switch(this.getPhase()) {
|
switch(this.getPhase()) {
|
||||||
case UNTAP:
|
case UNTAP:
|
||||||
@@ -309,8 +313,9 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
declareAttackersTurnBasedAction();
|
declareAttackersTurnBasedAction();
|
||||||
game.getStack().unfreezeStack();
|
game.getStack().unfreezeStack();
|
||||||
|
|
||||||
if (combat != null && combat.getAttackers().isEmpty() )
|
if (combat != null && combat.getAttackers().isEmpty()) {
|
||||||
combat = null;
|
combat = null;
|
||||||
|
}
|
||||||
|
|
||||||
givePriorityToPlayer = inCombat();
|
givePriorityToPlayer = inCombat();
|
||||||
break;
|
break;
|
||||||
@@ -328,7 +333,8 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
// no first strikers, skip this step
|
// no first strikers, skip this step
|
||||||
if (!combat.assignCombatDamage(true)) {
|
if (!combat.assignCombatDamage(true)) {
|
||||||
this.givePriorityToPlayer = false;
|
this.givePriorityToPlayer = false;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
combat.dealAssignedDamage();
|
combat.dealAssignedDamage();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -338,7 +344,8 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
|
|
||||||
if (!combat.assignCombatDamage(false)) {
|
if (!combat.assignCombatDamage(false)) {
|
||||||
this.givePriorityToPlayer = false;
|
this.givePriorityToPlayer = false;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
combat.dealAssignedDamage();
|
combat.dealAssignedDamage();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -365,8 +372,8 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
final int max = playerTurn.getMaxHandSize();
|
final int max = playerTurn.getMaxHandSize();
|
||||||
int numDiscard = playerTurn.isUnlimitedHandSize() || handSize <= max || handSize == 0 ? 0 : handSize - max;
|
int numDiscard = playerTurn.isUnlimitedHandSize() || handSize <= max || handSize == 0 ? 0 : handSize - max;
|
||||||
|
|
||||||
if ( numDiscard > 0 ) {
|
if (numDiscard > 0) {
|
||||||
for(Card c : playerTurn.getController().chooseCardsToDiscardToMaximumHandSize(numDiscard)){
|
for (Card c : playerTurn.getController().chooseCardsToDiscardToMaximumHandSize(numDiscard)){
|
||||||
playerTurn.discard(c, null);
|
playerTurn.discard(c, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -412,7 +419,7 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
game.getStack().unfreezeStack();
|
game.getStack().unfreezeStack();
|
||||||
|
|
||||||
// Rule 514.3a
|
// Rule 514.3a
|
||||||
if( phase == PhaseType.CLEANUP && !game.getStack().isEmpty() ) {
|
if (phase == PhaseType.CLEANUP && !game.getStack().isEmpty()) {
|
||||||
bRepeatCleanup = true;
|
bRepeatCleanup = true;
|
||||||
givePriorityToPlayer = true;
|
givePriorityToPlayer = true;
|
||||||
}
|
}
|
||||||
@@ -433,8 +440,9 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
p.loseLife(burn);
|
p.loseLife(burn);
|
||||||
}
|
}
|
||||||
// Play the Mana Burn sound
|
// Play the Mana Burn sound
|
||||||
if ( burn > 0 )
|
if (burn > 0) {
|
||||||
game.fireEvent(new GameEventManaBurn(burn, dealDamage));
|
game.fireEvent(new GameEventManaBurn(burn, dealDamage));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (this.phase) {
|
switch (this.phase) {
|
||||||
@@ -452,7 +460,7 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
|
|
||||||
case COMBAT_END:
|
case COMBAT_END:
|
||||||
GameEventCombatEnded eventEndCombat = null;
|
GameEventCombatEnded eventEndCombat = null;
|
||||||
if( combat != null ) {
|
if (combat != null) {
|
||||||
List<Card> attackers = combat.getAttackers();
|
List<Card> attackers = combat.getAttackers();
|
||||||
List<Card> blockers = combat.getAllBlockers();
|
List<Card> blockers = combat.getAllBlockers();
|
||||||
eventEndCombat = new GameEventCombatEnded(attackers, blockers);
|
eventEndCombat = new GameEventCombatEnded(attackers, blockers);
|
||||||
@@ -460,8 +468,9 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
combat = null;
|
combat = null;
|
||||||
this.getPlayerTurn().resetAttackedThisCombat();
|
this.getPlayerTurn().resetAttackedThisCombat();
|
||||||
|
|
||||||
if ( eventEndCombat != null )
|
if (eventEndCombat != null) {
|
||||||
game.fireEvent(eventEndCombat);
|
game.fireEvent(eventEndCombat);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CLEANUP:
|
case CLEANUP:
|
||||||
@@ -508,7 +517,7 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
|
|
||||||
// Prepare and fire event 'attackers declared'
|
// Prepare and fire event 'attackers declared'
|
||||||
Multimap<GameEntity, Card> attackersMap = ArrayListMultimap.create();
|
Multimap<GameEntity, Card> attackersMap = ArrayListMultimap.create();
|
||||||
for(GameEntity ge : combat.getDefenders()) {
|
for (GameEntity ge : combat.getDefenders()) {
|
||||||
attackersMap.putAll(ge, combat.getAttackersOf(ge));
|
attackersMap.putAll(ge, combat.getAttackersOf(ge));
|
||||||
}
|
}
|
||||||
game.fireEvent(new GameEventAttackersDeclared(playerTurn, attackersMap));
|
game.fireEvent(new GameEventAttackersDeclared(playerTurn, attackersMap));
|
||||||
@@ -560,7 +569,7 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
// Apply Odric's effect here
|
// Apply Odric's effect here
|
||||||
Player whoDeclaresBlockers = playerDeclaresBlockers == null || playerDeclaresBlockers.hasLost() ? p : playerDeclaresBlockers;
|
Player whoDeclaresBlockers = playerDeclaresBlockers == null || playerDeclaresBlockers.hasLost() ? p : playerDeclaresBlockers;
|
||||||
if (game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.attackerChoosesBlockers)) {
|
if (game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.attackerChoosesBlockers)) {
|
||||||
whoDeclaresBlockers = combat.getAttackingPlayer();
|
whoDeclaresBlockers = combat.getAttackingPlayer();
|
||||||
}
|
}
|
||||||
if (combat.isPlayerAttacked(p)) {
|
if (combat.isPlayerAttacked(p)) {
|
||||||
if (CombatUtil.canBlock(p, combat)) {
|
if (CombatUtil.canBlock(p, combat)) {
|
||||||
@@ -580,7 +589,7 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
for (Card attacker : attackers) {
|
for (Card attacker : attackers) {
|
||||||
boolean hasPaid = payRequiredBlockCosts(game, blocker, attacker);
|
boolean hasPaid = payRequiredBlockCosts(game, blocker, attacker);
|
||||||
|
|
||||||
if ( !hasPaid ) {
|
if (!hasPaid) {
|
||||||
combat.removeBlockAssignment(attacker, blocker);
|
combat.removeBlockAssignment(attacker, blocker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -588,7 +597,7 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
|
|
||||||
List<Card> remainingBlockers = CardLists.filterControlledBy(combat.getAllBlockers(), p);
|
List<Card> remainingBlockers = CardLists.filterControlledBy(combat.getAllBlockers(), p);
|
||||||
for (Card c : remainingBlockers) {
|
for (Card c : remainingBlockers) {
|
||||||
if ( remainingBlockers.size() < 2 && c.hasKeyword("CARDNAME can't attack or block alone.") ) {
|
if (remainingBlockers.size() < 2 && c.hasKeyword("CARDNAME can't attack or block alone.")) {
|
||||||
combat.undoBlockingAssignment(c);
|
combat.undoBlockingAssignment(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -597,15 +606,15 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
|
|
||||||
// map: defender => (many) attacker => (many) blocker
|
// map: defender => (many) attacker => (many) blocker
|
||||||
Map<GameEntity, MapOfLists<Card, Card>> blockers = new HashMap<GameEntity, MapOfLists<Card,Card>>();
|
Map<GameEntity, MapOfLists<Card, Card>> blockers = new HashMap<GameEntity, MapOfLists<Card,Card>>();
|
||||||
for(GameEntity ge : combat.getDefendersControlledBy(p)) {
|
for (GameEntity ge : combat.getDefendersControlledBy(p)) {
|
||||||
MapOfLists<Card, Card> protectThisDefender = new HashMapOfLists<Card, Card>(CollectionSuppliers.<Card>arrayLists());
|
MapOfLists<Card, Card> protectThisDefender = new HashMapOfLists<Card, Card>(CollectionSuppliers.<Card>arrayLists());
|
||||||
for(Card att : combat.getAttackersOf(ge)) {
|
for (Card att : combat.getAttackersOf(ge)) {
|
||||||
protectThisDefender.addAll(att, combat.getBlockers(att));
|
protectThisDefender.addAll(att, combat.getBlockers(att));
|
||||||
}
|
}
|
||||||
blockers.put(ge, protectThisDefender);
|
blockers.put(ge, protectThisDefender);
|
||||||
}
|
}
|
||||||
game.fireEvent(new GameEventBlockersDeclared(p, blockers));
|
game.fireEvent(new GameEventBlockersDeclared(p, blockers));
|
||||||
} while(p != playerTurn);
|
} while (p != playerTurn);
|
||||||
|
|
||||||
combat.orderBlockersForDamageAssignment(); // 509.2
|
combat.orderBlockersForDamageAssignment(); // 509.2
|
||||||
combat.orderAttackersForDamageAssignment(); // 509.3
|
combat.orderAttackersForDamageAssignment(); // 509.3
|
||||||
@@ -632,8 +641,9 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (final Card c1 : combat.getAllBlockers()) {
|
for (final Card c1 : combat.getAllBlockers()) {
|
||||||
if ( c1.getDamageHistory().getCreatureBlockedThisCombat() )
|
if (c1.getDamageHistory().getCreatureBlockedThisCombat()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!c1.getDamageHistory().getCreatureBlockedThisCombat()) {
|
if (!c1.getDamageHistory().getCreatureBlockedThisCombat()) {
|
||||||
for (final SpellAbility ab : CardFactoryUtil.getBushidoEffects(c1)) {
|
for (final SpellAbility ab : CardFactoryUtil.getBushidoEffects(c1)) {
|
||||||
@@ -656,8 +666,9 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Card> blockers = combat.getBlockers(a);
|
List<Card> blockers = combat.getBlockers(a);
|
||||||
if ( blockers.isEmpty() )
|
if (blockers.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Run triggers
|
// Run triggers
|
||||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||||
@@ -692,7 +703,7 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
final ArrayList<StaticAbility> staticAbilities = card.getStaticAbilities();
|
final ArrayList<StaticAbility> staticAbilities = card.getStaticAbilities();
|
||||||
for (final StaticAbility stAb : staticAbilities) {
|
for (final StaticAbility stAb : staticAbilities) {
|
||||||
Cost c1 = stAb.getBlockCost(blocker, attacker);
|
Cost c1 = stAb.getBlockCost(blocker, attacker);
|
||||||
if ( c1 != null ) {
|
if (c1 != null) {
|
||||||
blockCost.add(c1);
|
blockCost.add(c1);
|
||||||
hasBlockCost = true;
|
hasBlockCost = true;
|
||||||
}
|
}
|
||||||
@@ -748,8 +759,7 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
Player next = getNextActivePlayer();
|
Player next = getNextActivePlayer();
|
||||||
|
|
||||||
if (game.getType() == GameType.Planechase) {
|
if (game.getType() == GameType.Planechase) {
|
||||||
for(Card p :game.getActivePlanes())
|
for (Card p :game.getActivePlanes()) {
|
||||||
{
|
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
p.setController(next, 0);
|
p.setController(next, 0);
|
||||||
game.getAction().controllerChangeZoneCorrection(p);
|
game.getAction().controllerChangeZoneCorrection(p);
|
||||||
@@ -947,8 +957,9 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
FThreads.assertExecutedByEdt(false);
|
FThreads.assertExecutedByEdt(false);
|
||||||
StopWatch sw = new StopWatch();
|
StopWatch sw = new StopWatch();
|
||||||
|
|
||||||
if(phase != null)
|
if (phase != null) {
|
||||||
throw new IllegalStateException("Turns already started, call this only once per game");
|
throw new IllegalStateException("Turns already started, call this only once per game");
|
||||||
|
}
|
||||||
|
|
||||||
setPlayerTurn(goesFirst);
|
setPlayerTurn(goesFirst);
|
||||||
advanceToNextPhase();
|
advanceToNextPhase();
|
||||||
@@ -958,32 +969,33 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
givePriorityToPlayer = false;
|
givePriorityToPlayer = false;
|
||||||
|
|
||||||
while (!game.isGameOver()) { // loop only while is playing
|
while (!game.isGameOver()) { // loop only while is playing
|
||||||
|
if (DEBUG_PHASES) {
|
||||||
if( DEBUG_PHASES ) {
|
|
||||||
System.out.println("\t\tStack: " + game.getStack());
|
System.out.println("\t\tStack: " + game.getStack());
|
||||||
System.out.print(FThreads.prependThreadId(debugPrintState(givePriorityToPlayer)));
|
System.out.print(FThreads.prependThreadId(debugPrintState(givePriorityToPlayer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if( givePriorityToPlayer ) {
|
if (givePriorityToPlayer) {
|
||||||
if( DEBUG_PHASES )
|
if (DEBUG_PHASES) {
|
||||||
sw.start();
|
sw.start();
|
||||||
|
}
|
||||||
|
|
||||||
// Rule 704.3 Whenever a player would get priority, the game checks ... for state-based actions,
|
// Rule 704.3 Whenever a player would get priority, the game checks ... for state-based actions,
|
||||||
game.getAction().checkStateEffects();
|
game.getAction().checkStateEffects();
|
||||||
game.fireEvent(new GameEventPlayerPriority(getPlayerTurn(), getPhase(), getPriorityPlayer()));
|
game.fireEvent(new GameEventPlayerPriority(getPlayerTurn(), getPhase(), getPriorityPlayer()));
|
||||||
|
|
||||||
// SBA could lead to game over
|
// SBA could lead to game over
|
||||||
if ( game.isGameOver() ) return;
|
if (game.isGameOver()) { return; }
|
||||||
|
|
||||||
pPlayerPriority.getController().takePriority();
|
pPlayerPriority.getController().takePriority();
|
||||||
|
|
||||||
if( DEBUG_PHASES ) {
|
if (DEBUG_PHASES) {
|
||||||
sw.stop();
|
sw.stop();
|
||||||
System.out.print("... passed in " + sw.getTime()/1000f + " s\n");
|
System.out.print("... passed in " + sw.getTime()/1000f + " s\n");
|
||||||
System.out.println("\t\tStack: " + game.getStack());
|
System.out.println("\t\tStack: " + game.getStack());
|
||||||
sw.reset();
|
sw.reset();
|
||||||
}
|
}
|
||||||
} else if( DEBUG_PHASES ){
|
}
|
||||||
|
else if (DEBUG_PHASES){
|
||||||
System.out.print(" >>\n");
|
System.out.print(" >>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -992,7 +1004,7 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
// of Priority
|
// of Priority
|
||||||
Player nextPlayer = game.getNextPlayerAfter(this.getPriorityPlayer());
|
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));
|
// System.out.println(String.format("%s %s: %s passes priority to %s", playerTurn, phase, actingPlayer, nextPlayer));
|
||||||
if (getFirstPriority() == nextPlayer) {
|
if (getFirstPriority() == nextPlayer) {
|
||||||
@@ -1004,17 +1016,19 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
onPhaseEnd();
|
onPhaseEnd();
|
||||||
advanceToNextPhase();
|
advanceToNextPhase();
|
||||||
onPhaseBegin();
|
onPhaseBegin();
|
||||||
} else if (!game.getStack().hasSimultaneousStackEntries()) {
|
}
|
||||||
|
else if (!game.getStack().hasSimultaneousStackEntries()) {
|
||||||
game.getStack().resolveStack();
|
game.getStack().resolveStack();
|
||||||
game.getStack().chooseOrderOfSimultaneousStackEntryAll();
|
game.getStack().chooseOrderOfSimultaneousStackEntryAll();
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// pass the priority to other player
|
// pass the priority to other player
|
||||||
this.pPlayerPriority = nextPlayer;
|
this.pPlayerPriority = nextPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If ever the karn's ultimate resolved
|
// If ever the karn's ultimate resolved
|
||||||
if( game.getAge() == GameStage.RestartedByKarn) {
|
if (game.getAge() == GameStage.RestartedByKarn) {
|
||||||
phase = null;
|
phase = null;
|
||||||
game.fireEvent(new GameEventGameRestarted(playerTurn));
|
game.fireEvent(new GameEventGameRestarted(playerTurn));
|
||||||
return;
|
return;
|
||||||
@@ -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
|
// 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) {
|
public final void devModeSet(final PhaseType phase0, final Player player0) {
|
||||||
if (null != phase0) this.phase = phase0;
|
if (null != phase0) this.phase = phase0;
|
||||||
if (null != player0 )
|
if (null != player0) {
|
||||||
setPlayerTurn(player0);
|
setPlayerTurn(player0);
|
||||||
|
}
|
||||||
|
|
||||||
game.fireEvent(new GameEventTurnPhase(this.getPlayerTurn(), this.getPhase(), ""));
|
game.fireEvent(new GameEventTurnPhase(this.getPlayerTurn(), this.getPhase(), ""));
|
||||||
combat = null; // not-null can be created only when declare attackers phase begins
|
combat = null; // not-null can be created only when declare attackers phase begins
|
||||||
|
|||||||
Reference in New Issue
Block a user