[minor] formatting

This commit is contained in:
LevelX2 2013-03-06 16:35:22 +01:00
parent 155b7a277b
commit ffcd51989e
4 changed files with 117 additions and 61 deletions

View file

@ -28,6 +28,13 @@
package mage.server.game; package mage.server.game;
import java.io.*;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.zip.GZIPOutputStream;
import mage.Constants.Zone; import mage.Constants.Zone;
import mage.MageException; import mage.MageException;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -55,13 +62,6 @@ import mage.view.GameView;
import mage.view.PermanentView; import mage.view.PermanentView;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import java.io.*;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.zip.GZIPOutputStream;
/** /**
* *
@ -130,7 +130,7 @@ public class GameController implements GameCallback {
new Listener<PlayerQueryEvent> () { new Listener<PlayerQueryEvent> () {
@Override @Override
public void event(PlayerQueryEvent event) { public void event(PlayerQueryEvent event) {
// logger.info(event.getPlayerId() + "--" + event.getQueryType() + "--" + event.getMessage()); logger.trace(new StringBuilder(event.getPlayerId().toString()).append("--").append(event.getQueryType()).append("--").append(event.getMessage()).toString());
try { try {
switch (event.getQueryType()) { switch (event.getQueryType()) {
case ASK: case ASK:
@ -198,8 +198,8 @@ public class GameController implements GameCallback {
User user = UserManager.getInstance().getUser(userId); User user = UserManager.getInstance().getUser(userId);
gameSession.setUserData(user.getUserData()); gameSession.setUserData(user.getUserData());
user.addGame(playerId, gameSession); user.addGame(playerId, gameSession);
logger.info("player " + playerId + " has joined game " + game.getId()); logger.info(new StringBuilder("Player ").append(playerId).append(" has joined game ").append(game.getId()).toString());
ChatManager.getInstance().broadcast(chatId, "", game.getPlayer(playerId).getName() + " has joined the game", MessageColor.BLACK); ChatManager.getInstance().broadcast(chatId, "", new StringBuilder(game.getPlayer(playerId).getName()).append(" has joined the game").toString(), MessageColor.BLACK);
checkStart(); checkStart();
} }
@ -328,15 +328,16 @@ public class GameController implements GameCallback {
public void sendPlayerUUID(UUID userId, final UUID data) { public void sendPlayerUUID(UUID userId, final UUID data) {
sendMessage(userId, new Command() { sendMessage(userId, new Command() {
@Override
public void execute(UUID playerId) { public void execute(UUID playerId) {
gameSessions.get(playerId).sendPlayerUUID(data); gameSessions.get(playerId).sendPlayerUUID(data);
} }
}); });
} }
public void sendPlayerString(UUID userId, final String data) { public void sendPlayerString(UUID userId, final String data) {
sendMessage(userId, new Command() { sendMessage(userId, new Command() {
@Override
public void execute(UUID playerId) { public void execute(UUID playerId) {
gameSessions.get(playerId).sendPlayerString(data); gameSessions.get(playerId).sendPlayerString(data);
} }
@ -345,6 +346,7 @@ public class GameController implements GameCallback {
public void sendPlayerBoolean(UUID userId, final Boolean data) { public void sendPlayerBoolean(UUID userId, final Boolean data) {
sendMessage(userId, new Command() { sendMessage(userId, new Command() {
@Override
public void execute(UUID playerId) { public void execute(UUID playerId) {
gameSessions.get(playerId).sendPlayerBoolean(data); gameSessions.get(playerId).sendPlayerBoolean(data);
} }
@ -354,6 +356,7 @@ public class GameController implements GameCallback {
public void sendPlayerInteger(UUID userId, final Integer data) { public void sendPlayerInteger(UUID userId, final Integer data) {
sendMessage(userId, new Command() { sendMessage(userId, new Command() {
@Override
public void execute(UUID playerId) { public void execute(UUID playerId) {
gameSessions.get(playerId).sendPlayerInteger(data); gameSessions.get(playerId).sendPlayerInteger(data);
} }
@ -371,15 +374,8 @@ public class GameController implements GameCallback {
} }
private synchronized void ask(UUID playerId, final String question) throws MageException { private synchronized void ask(UUID playerId, final String question) throws MageException {
/*if (question.equals("Do you want to take a mulligan?")) {
System.out.println("reverted");
for (UUID uuid : game.getOpponents(playerId)) {
gameSessions.get(uuid).ask(question);
informOthers(uuid);
}
return;
}*/
perform(playerId, new Command() { perform(playerId, new Command() {
@Override
public void execute(UUID playerId) { public void execute(UUID playerId) {
gameSessions.get(playerId).ask(question); gameSessions.get(playerId).ask(question);
} }
@ -389,6 +385,7 @@ public class GameController implements GameCallback {
private synchronized void chooseAbility(UUID playerId, final List<? extends Ability> choices) throws MageException { private synchronized void chooseAbility(UUID playerId, final List<? extends Ability> choices) throws MageException {
perform(playerId, new Command() { perform(playerId, new Command() {
@Override
public void execute(UUID playerId) { public void execute(UUID playerId) {
gameSessions.get(playerId).chooseAbility(new AbilityPickerView(choices)); gameSessions.get(playerId).chooseAbility(new AbilityPickerView(choices));
} }
@ -397,6 +394,7 @@ public class GameController implements GameCallback {
private synchronized void choosePile(UUID playerId, final String message, final List<? extends Card> pile1, final List<? extends Card> pile2) throws MageException { private synchronized void choosePile(UUID playerId, final String message, final List<? extends Card> pile1, final List<? extends Card> pile2) throws MageException {
perform(playerId, new Command() { perform(playerId, new Command() {
@Override
public void execute(UUID playerId) { public void execute(UUID playerId) {
gameSessions.get(playerId).choosePile(message, new CardsView(pile1), new CardsView(pile2)); gameSessions.get(playerId).choosePile(message, new CardsView(pile1), new CardsView(pile2));
} }
@ -405,6 +403,7 @@ public class GameController implements GameCallback {
private synchronized void chooseMode(UUID playerId, final Map<UUID, String> modes) throws MageException { private synchronized void chooseMode(UUID playerId, final Map<UUID, String> modes) throws MageException {
perform(playerId, new Command() { perform(playerId, new Command() {
@Override
public void execute(UUID playerId) { public void execute(UUID playerId) {
gameSessions.get(playerId).chooseAbility(new AbilityPickerView(modes)); gameSessions.get(playerId).chooseAbility(new AbilityPickerView(modes));
} }
@ -413,6 +412,7 @@ public class GameController implements GameCallback {
private synchronized void choose(UUID playerId, final String message, final Set<String> choices) throws MageException { private synchronized void choose(UUID playerId, final String message, final Set<String> choices) throws MageException {
perform(playerId, new Command() { perform(playerId, new Command() {
@Override
public void execute(UUID playerId) { public void execute(UUID playerId) {
gameSessions.get(playerId).choose(message, choices); gameSessions.get(playerId).choose(message, choices);
} }
@ -421,6 +421,7 @@ public class GameController implements GameCallback {
private synchronized void target(UUID playerId, final String question, final Cards cards, final List<Permanent> perms, final Set<UUID> targets, final boolean required, final Map<String, Serializable> options) throws MageException { private synchronized void target(UUID playerId, final String question, final Cards cards, final List<Permanent> perms, final Set<UUID> targets, final boolean required, final Map<String, Serializable> options) throws MageException {
perform(playerId, new Command() { perform(playerId, new Command() {
@Override
public void execute(UUID playerId) { public void execute(UUID playerId) {
if (cards != null) { if (cards != null) {
gameSessions.get(playerId).target(question, new CardsView(cards.getCards(game)), targets, required, options); gameSessions.get(playerId).target(question, new CardsView(cards.getCards(game)), targets, required, options);
@ -430,15 +431,17 @@ public class GameController implements GameCallback {
permsView.put(perm.getId(), new PermanentView(perm, game.getCard(perm.getId()))); permsView.put(perm.getId(), new PermanentView(perm, game.getCard(perm.getId())));
} }
gameSessions.get(playerId).target(question, permsView, targets, required, options); gameSessions.get(playerId).target(question, permsView, targets, required, options);
} else } else {
gameSessions.get(playerId).target(question, new CardsView(), targets, required, options); gameSessions.get(playerId).target(question, new CardsView(), targets, required, options);
} }
}
}); });
} }
private synchronized void target(UUID playerId, final String question, final Collection<? extends Ability> abilities, final boolean required, final Map<String, Serializable> options) throws MageException { private synchronized void target(UUID playerId, final String question, final Collection<? extends Ability> abilities, final boolean required, final Map<String, Serializable> options) throws MageException {
perform(playerId, new Command() { perform(playerId, new Command() {
@Override
public void execute(UUID playerId) { public void execute(UUID playerId) {
gameSessions.get(playerId).target(question, new CardsView(abilities, game), null, required, options); gameSessions.get(playerId).target(question, new CardsView(abilities, game), null, required, options);
} }
@ -447,6 +450,7 @@ public class GameController implements GameCallback {
private synchronized void select(final UUID playerId, final String message) throws MageException { private synchronized void select(final UUID playerId, final String message) throws MageException {
perform(playerId, new Command() { perform(playerId, new Command() {
@Override
public void execute(UUID playerId) { public void execute(UUID playerId) {
gameSessions.get(playerId).select(message); gameSessions.get(playerId).select(message);
} }
@ -455,6 +459,7 @@ public class GameController implements GameCallback {
private synchronized void playMana(UUID playerId, final String message) throws MageException { private synchronized void playMana(UUID playerId, final String message) throws MageException {
perform(playerId, new Command() { perform(playerId, new Command() {
@Override
public void execute(UUID playerId) { public void execute(UUID playerId) {
gameSessions.get(playerId).playMana(message); gameSessions.get(playerId).playMana(message);
} }
@ -463,6 +468,7 @@ public class GameController implements GameCallback {
private synchronized void playXMana(UUID playerId, final String message) throws MageException { private synchronized void playXMana(UUID playerId, final String message) throws MageException {
perform(playerId, new Command() { perform(playerId, new Command() {
@Override
public void execute(UUID playerId) { public void execute(UUID playerId) {
gameSessions.get(playerId).playXMana(message); gameSessions.get(playerId).playXMana(message);
} }
@ -471,6 +477,7 @@ public class GameController implements GameCallback {
private synchronized void amount(UUID playerId, final String message, final int min, final int max) throws MageException { private synchronized void amount(UUID playerId, final String message, final int min, final int max) throws MageException {
perform(playerId, new Command() { perform(playerId, new Command() {
@Override
public void execute(UUID playerId) { public void execute(UUID playerId) {
gameSessions.get(playerId).getAmount(message, min, max); gameSessions.get(playerId).getAmount(message, min, max);
} }
@ -485,6 +492,7 @@ public class GameController implements GameCallback {
private synchronized void lookAtCards(UUID playerId, final String name, final Cards cards) throws MageException { private synchronized void lookAtCards(UUID playerId, final String name, final Cards cards) throws MageException {
perform(playerId, new Command() { perform(playerId, new Command() {
@Override
public void execute(UUID playerId) { public void execute(UUID playerId) {
gameSessions.get(playerId).revealCards(name, new CardsView(cards.getCards(game))); gameSessions.get(playerId).revealCards(name, new CardsView(cards.getCards(game)));
} }
@ -492,23 +500,24 @@ public class GameController implements GameCallback {
} }
private void informOthers(UUID playerId) throws MageException { private void informOthers(UUID playerId) throws MageException {
String message = ""; StringBuilder message = new StringBuilder();
if (game.getStep() != null) if (game.getStep() != null) {
message += game.getStep().getType().toString() + " - "; message.append(game.getStep().getType().toString()).append(" - ");
message += "Waiting for " + game.getPlayer(playerId).getName(); }
message.append("Waiting for ").append(game.getPlayer(playerId).getName());
for (final Entry<UUID, GameSession> entry: gameSessions.entrySet()) { for (final Entry<UUID, GameSession> entry: gameSessions.entrySet()) {
if (!entry.getKey().equals(playerId)) { if (!entry.getKey().equals(playerId)) {
entry.getValue().inform(message); entry.getValue().inform(message.toString());
} }
} }
for (final GameWatcher watcher: watchers.values()) { for (final GameWatcher watcher: watchers.values()) {
watcher.inform(message); watcher.inform(message.toString());
} }
} }
private void informOthers(List<UUID> players) throws MageException { private void informOthers(List<UUID> players) throws MageException {
// first player is always original controller // first player is always original controller
final String message = game.getStep().toString() + " - Waiting for " + game.getPlayer(players.get(0)).getName(); final String message = new StringBuilder(game.getStep().toString()).append(" - Waiting for ").append(game.getPlayer(players.get(0)).getName()).toString();
for (final Entry<UUID, GameSession> entry: gameSessions.entrySet()) { for (final Entry<UUID, GameSession> entry: gameSessions.entrySet()) {
boolean skip = false; boolean skip = false;
for (UUID uuid : players) { for (UUID uuid : players) {
@ -517,7 +526,9 @@ public class GameController implements GameCallback {
break; break;
} }
} }
if (!skip) entry.getValue().inform(message); if (!skip) {
entry.getValue().inform(message);
}
} }
for (final GameWatcher watcher: watchers.values()) { for (final GameWatcher watcher: watchers.values()) {
watcher.inform(message); watcher.inform(message);
@ -526,6 +537,7 @@ public class GameController implements GameCallback {
private synchronized void informPersonal(UUID playerId, final String message) throws MageException { private synchronized void informPersonal(UUID playerId, final String message) throws MageException {
perform(playerId, new Command() { perform(playerId, new Command() {
@Override
public void execute(UUID playerId) { public void execute(UUID playerId) {
gameSessions.get(playerId).informPersonal(message); gameSessions.get(playerId).informPersonal(message);
} }
@ -590,16 +602,22 @@ public class GameController implements GameCallback {
private void perform(UUID playerId, Command command, boolean informOthers) throws MageException { private void perform(UUID playerId, Command command, boolean informOthers) throws MageException {
if (game.getPlayer(playerId).isGameUnderControl()) { if (game.getPlayer(playerId).isGameUnderControl()) {
if (gameSessions.containsKey(playerId)) if (gameSessions.containsKey(playerId)) {
command.execute(playerId); command.execute(playerId);
if (informOthers) informOthers(playerId); }
if (informOthers) {
informOthers(playerId);
}
} else { } else {
List<UUID> players = Splitter.split(game, playerId); List<UUID> players = Splitter.split(game, playerId);
for (UUID uuid : players) { for (UUID uuid : players) {
if (gameSessions.containsKey(uuid)) if (gameSessions.containsKey(uuid)) {
command.execute(uuid); command.execute(uuid);
} }
if (informOthers) informOthers(players); }
if (informOthers) {
informOthers(players);
}
} }
} }
@ -609,8 +627,9 @@ public class GameController implements GameCallback {
// if it's your priority (or game not started yet in which case it will be null) // if it's your priority (or game not started yet in which case it will be null)
// then execute only your action // then execute only your action
if (game.getPriorityPlayerId() == null || game.getPriorityPlayerId().equals(playerId)) { if (game.getPriorityPlayerId() == null || game.getPriorityPlayerId().equals(playerId)) {
if (gameSessions.containsKey(playerId)) if (gameSessions.containsKey(playerId)) {
command.execute(playerId); command.execute(playerId);
}
} // otherwise execute the action under other player's control } // otherwise execute the action under other player's control
else { else {
//System.out.println("asThough: " + playerId + " " + game.getPriorityPlayerId()); //System.out.println("asThough: " + playerId + " " + game.getPriorityPlayerId());
@ -630,11 +649,11 @@ public class GameController implements GameCallback {
Player priorityPlayer = game.getPlayer(game.getPriorityPlayerId()); Player priorityPlayer = game.getPlayer(game.getPriorityPlayerId());
logger.warn(" priority player: " + priorityPlayer.getName() + ", id: " + priorityPlayer.getId()); logger.warn(" priority player: " + priorityPlayer.getName() + ", id: " + priorityPlayer.getId());
logger.warn(" command: " + command.toString()); logger.warn(" command: " + command.toString());
logger.warn(" command-class: " + command.getClass().getName());
} }
} }
} else { } else {
// ignore - no control over the turn // ignore - no control over the turn
return;
} }
} }

View file

@ -27,13 +27,14 @@
*/ */
package mage.abilities.effects.common.turn; package mage.abilities.effects.common.turn;
import mage.Constants; import java.util.UUID;
import mage.Constants.Outcome;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.game.Game; import mage.game.Game;
import mage.game.turn.TurnMod; import mage.game.turn.TurnMod;
import java.util.UUID;
/** /**
* @author nantuko * @author nantuko
@ -41,7 +42,7 @@ import java.util.UUID;
public class ControlTargetPlayerNextTurnEffect extends OneShotEffect<ControlTargetPlayerNextTurnEffect> { public class ControlTargetPlayerNextTurnEffect extends OneShotEffect<ControlTargetPlayerNextTurnEffect> {
public ControlTargetPlayerNextTurnEffect() { public ControlTargetPlayerNextTurnEffect() {
super(Constants.Outcome.Benefit); super(Outcome.Benefit);
staticText = "You control target player during that player's next turn. (You see all cards that player could see and make all decisions for the player.)"; staticText = "You control target player during that player's next turn. (You see all cards that player could see and make all decisions for the player.)";
} }

View file

@ -28,17 +28,17 @@
package mage.game.turn; package mage.game.turn;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import mage.Constants.PhaseStep; import mage.Constants.PhaseStep;
import mage.Constants.TurnPhase; import mage.Constants.TurnPhase;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.players.Player; import mage.players.Player;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
/** /**
* *
@ -59,8 +59,9 @@ public class Turn implements Serializable {
} }
public Turn(final Turn turn) { public Turn(final Turn turn) {
if (turn.currentPhase != null) if (turn.currentPhase != null) {
this.currentPhase = turn.currentPhase.copy(); this.currentPhase = turn.currentPhase.copy();
}
this.activePlayerId = turn.activePlayerId; this.activePlayerId = turn.activePlayerId;
for (Phase phase: turn.phases) { for (Phase phase: turn.phases) {
this.phases.add(phase.copy()); this.phases.add(phase.copy());
@ -69,8 +70,9 @@ public class Turn implements Serializable {
} }
public TurnPhase getPhaseType() { public TurnPhase getPhaseType() {
if (currentPhase != null) if (currentPhase != null) {
return currentPhase.getType(); return currentPhase.getType();
}
return null; return null;
} }
@ -92,23 +94,27 @@ public class Turn implements Serializable {
} }
public Step getStep() { public Step getStep() {
if (currentPhase != null) if (currentPhase != null) {
return currentPhase.getStep(); return currentPhase.getStep();
}
return null; return null;
} }
public PhaseStep getStepType() { public PhaseStep getStepType() {
if (currentPhase != null && currentPhase.getStep() != null) if (currentPhase != null && currentPhase.getStep() != null) {
return currentPhase.getStep().getType(); return currentPhase.getStep().getType();
}
return null; return null;
} }
public void play(Game game, UUID activePlayerId) { public void play(Game game, UUID activePlayerId) {
if (game.isPaused() || game.isGameOver()) if (game.isPaused() || game.isGameOver()) {
return; return;
}
if (game.getState().getTurnMods().skipTurn(activePlayerId)) if (game.getState().getTurnMods().skipTurn(activePlayerId)) {
return; return;
}
checkTurnIsControlledByOtherPlayer(game, activePlayerId); checkTurnIsControlledByOtherPlayer(game, activePlayerId);
@ -116,8 +122,9 @@ public class Turn implements Serializable {
resetCounts(); resetCounts();
game.getPlayer(activePlayerId).beginTurn(game); game.getPlayer(activePlayerId).beginTurn(game);
for (Phase phase: phases) { for (Phase phase: phases) {
if (game.isPaused() || game.isGameOver()) if (game.isPaused() || game.isGameOver()) {
return; return;
}
currentPhase = phase; currentPhase = phase;
game.fireEvent(new GameEvent(GameEvent.EventType.PHASE_CHANGED, activePlayerId, null, activePlayerId)); game.fireEvent(new GameEvent(GameEvent.EventType.PHASE_CHANGED, activePlayerId, null, activePlayerId));
if (!game.getState().getTurnMods().skipPhase(activePlayerId, currentPhase.getType())) { if (!game.getState().getTurnMods().skipPhase(activePlayerId, currentPhase.getType())) {
@ -128,7 +135,8 @@ public class Turn implements Serializable {
//game.saveState(); //game.saveState();
//20091005 - 500.8 //20091005 - 500.8
while (playExtraPhases(game, phase.getType())); while (playExtraPhases(game, phase.getType())) {
}
} }
} }
// magenoxx: this causes bugs when we need to add several phases connected with each other (WorldAtWarTest) // magenoxx: this causes bugs when we need to add several phases connected with each other (WorldAtWarTest)
@ -159,8 +167,9 @@ public class Turn implements Serializable {
} }
while (it.hasNext()) { while (it.hasNext()) {
phase = it.next(); phase = it.next();
if (game.isPaused() || game.isGameOver()) if (game.isPaused() || game.isGameOver()) {
return; return;
}
currentPhase = phase; currentPhase = phase;
if (!game.getState().getTurnMods().skipPhase(activePlayerId, currentPhase.getType())) { if (!game.getState().getTurnMods().skipPhase(activePlayerId, currentPhase.getType())) {
if (phase.play(game, activePlayerId)) { if (phase.play(game, activePlayerId)) {
@ -193,11 +202,13 @@ public class Turn implements Serializable {
private boolean playExtraPhases(Game game, TurnPhase afterPhase) { private boolean playExtraPhases(Game game, TurnPhase afterPhase) {
TurnMod extraPhaseTurnMod = game.getState().getTurnMods().extraPhase(activePlayerId, afterPhase); TurnMod extraPhaseTurnMod = game.getState().getTurnMods().extraPhase(activePlayerId, afterPhase);
if (extraPhaseTurnMod == null) if (extraPhaseTurnMod == null) {
return false; return false;
}
TurnPhase extraPhase = extraPhaseTurnMod.getExtraPhase(); TurnPhase extraPhase = extraPhaseTurnMod.getExtraPhase();
if (extraPhase == null) if (extraPhase == null) {
return false; return false;
}
Phase phase; Phase phase;
switch(extraPhase) { switch(extraPhase) {
case BEGINNING: case BEGINNING:

View file

@ -28,11 +28,11 @@
package mage.game.turn; package mage.game.turn;
import java.io.Serializable;
import java.util.UUID;
import mage.Constants.PhaseStep; import mage.Constants.PhaseStep;
import mage.Constants.TurnPhase; import mage.Constants.TurnPhase;
import java.io.Serializable;
import java.util.UUID;
/** /**
* stores extra turns, phases or steps * stores extra turns, phases or steps
@ -53,15 +53,29 @@ public class TurnMod implements Serializable {
private TurnPhase afterPhase; private TurnPhase afterPhase;
private PhaseStep afterStep; private PhaseStep afterStep;
/**
* Used to define if a player skips the next turn or gets an extra turn.
*
* @param playerId
* @param skip - true = skips next turn, false = player gets extra turn
*/
public TurnMod(UUID playerId, boolean skip) { public TurnMod(UUID playerId, boolean skip) {
this.id = UUID.randomUUID(); this.id = UUID.randomUUID();
this.playerId = playerId; this.playerId = playerId;
if (skip) if (skip) {
this.skipTurn = true; this.skipTurn = true;
else }
else {
this.extraTurn = true; this.extraTurn = true;
} }
}
/**
* Used to define that a player controlls the next turn of another player.
*
* @param playerId - id of the player whose next turn is controlled by newControllerId
* @param newControllerId - id of the player that controlls playerId's next turn
*/
public TurnMod(UUID playerId, UUID newControllerId) { public TurnMod(UUID playerId, UUID newControllerId) {
this.id = UUID.randomUUID(); this.id = UUID.randomUUID();
this.playerId = playerId; this.playerId = playerId;
@ -69,6 +83,7 @@ public class TurnMod implements Serializable {
} }
/** /**
* Used to define if and when a player gets an extra phase.
* *
* @param playerId * @param playerId
* @param phase * @param phase
@ -77,17 +92,20 @@ public class TurnMod implements Serializable {
public TurnMod(UUID playerId, TurnPhase phase, TurnPhase afterPhase, boolean skip) { public TurnMod(UUID playerId, TurnPhase phase, TurnPhase afterPhase, boolean skip) {
this.id = UUID.randomUUID(); this.id = UUID.randomUUID();
this.playerId = playerId; this.playerId = playerId;
if (skip) if (skip) {
this.skipPhase = phase; this.skipPhase = phase;
else }
else {
this.extraPhase = phase; this.extraPhase = phase;
}
this.afterPhase = afterPhase; this.afterPhase = afterPhase;
} }
/** /**
* Used to define if and when a player gets an extra step.
* *
* @param playerId * @param playerId
* @param step * @param step - extra step the player gets
* @param afterStep - set to null if extraStep is after the next step * @param afterStep - set to null if extraStep is after the next step
*/ */
public TurnMod(UUID playerId, Step step, PhaseStep afterStep) { public TurnMod(UUID playerId, Step step, PhaseStep afterStep) {
@ -97,6 +115,12 @@ public class TurnMod implements Serializable {
this.afterStep = afterStep; this.afterStep = afterStep;
} }
/**
* Used to define that a player skips the next time the specified step
*
* @param playerId
* @param step - step to skip the next time
*/
public TurnMod(UUID playerId, PhaseStep step) { public TurnMod(UUID playerId, PhaseStep step) {
this.id = UUID.randomUUID(); this.id = UUID.randomUUID();
this.playerId = playerId; this.playerId = playerId;
@ -111,8 +135,9 @@ public class TurnMod implements Serializable {
this.skipTurn = mod.skipTurn; this.skipTurn = mod.skipTurn;
this.extraPhase = mod.extraPhase; this.extraPhase = mod.extraPhase;
this.skipPhase = mod.skipPhase; this.skipPhase = mod.skipPhase;
if (mod.extraStep != null) if (mod.extraStep != null) {
this.extraStep = mod.extraStep.copy(); this.extraStep = mod.extraStep.copy();
}
this.skipStep = mod.skipStep; this.skipStep = mod.skipStep;
this.afterPhase = mod.afterPhase; this.afterPhase = mod.afterPhase;
this.afterStep = mod.afterStep; this.afterStep = mod.afterStep;