Fixed a bug that while a match or tournament was just starting a player could still leave the table, setting the table / tournament / match to an undefined state. Now the player can only leave the Match / Tournament if it has started properly.

This commit is contained in:
LevelX2 2014-09-03 01:02:10 +02:00
parent 3f5f6a6166
commit fec0744315
10 changed files with 159 additions and 100 deletions

View file

@ -6,7 +6,8 @@ package mage.constants;
*/
public enum TableState {
WAITING ("Waiting for players"),
STARTING ("Waiting to start"),
READY_TO_START("Waiting to start"),
STARTING ("Starting"),
DRAFTING ("Drafting"),
DUELING ("Dueling"),
SIDEBOARDING ("Sideboarding"),

View file

@ -172,7 +172,7 @@ public class Table implements Serializable {
}
seat.setPlayer(player);
if (isReady()) {
setState(TableState.STARTING);
setState(TableState.READY_TO_START);
}
return seat.getPlayer().getId();
}
@ -208,7 +208,7 @@ public class Table implements Serializable {
Player player = seats[i].getPlayer();
if (player != null && player.getId().equals(playerId)) {
seats[i].setPlayer(null);
if (getState().equals(TableState.STARTING)) {
if (getState().equals(TableState.READY_TO_START)) {
setState(TableState.WAITING);
}
break;
@ -216,14 +216,14 @@ public class Table implements Serializable {
}
}
final public void setState(TableState state) {
final public synchronized void setState(TableState state) {
this.state = state;
if (isTournament()) {
getTournament().setTournamentState(state.toString());
}
}
public TableState getState() {
public synchronized TableState getState() {
return state;
}