Tournaments status is updated now and if tournament finished, it's moved to the lower finished matches view.

This commit is contained in:
LevelX2 2013-03-27 22:31:15 +01:00
parent 095c3c5776
commit 402f7fffd9
12 changed files with 89 additions and 24 deletions

View file

@ -418,6 +418,14 @@ public class TableController {
table.construct();
}
public void initTournament() {
table.initTournament();
}
public void endTournament(Tournament tournament) {
table.endTournament();
}
public MatchOptions getOptions() {
return options;
}
@ -483,10 +491,6 @@ public class TableController {
tournament.nextStep();
}
public void endTournament(Tournament tournament) {
//TODO: implement this
}
public void swapSeats(int seatNum1, int seatNum2) {
if (table.getState() == TableState.STARTING) {
if (seatNum1 >= 0 && seatNum2 >= 0 && seatNum1 < table.getSeats().length && seatNum2 < table.getSeats().length) {

View file

@ -273,6 +273,12 @@ public class TableManager {
}
}
public void initTournament(UUID tableId) {
if (controllers.containsKey(tableId)) {
controllers.get(tableId).initTournament();
}
}
public void addPlayer(UUID userId, UUID tableId, Player player, String playerType, Deck deck) throws GameException {
if (controllers.containsKey(tableId)) {
controllers.get(tableId).addPlayer(userId, player, playerType, deck);

View file

@ -95,11 +95,14 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
tableList.add(new TableView(table));
}
else if (matchList.size() < 50) {
matchList.add(new MatchView(table.getMatch()));
} else {
// more since 50 matches finished since this match so remobe it
if (table.isTournament()) {
// is this possible?
matchList.add(new MatchView(table));
} else {
matchList.add(new MatchView(table.getMatch()));
}
} else {
// more since 50 matches finished since this match so remove it
if (table.isTournament()) {
// Any special action needed?
}
this.removeTable(table.getId());

View file

@ -39,6 +39,7 @@ import mage.game.draft.Draft;
import mage.game.events.Listener;
import mage.game.events.PlayerQueryEvent;
import mage.game.events.TableEvent;
import static mage.game.events.TableEvent.EventType.CONSTRUCT;
import mage.game.match.MatchOptions;
import mage.game.tournament.Tournament;
import mage.game.tournament.TournamentPairing;
@ -89,15 +90,17 @@ public class TournamentController {
case START_DRAFT:
startDraft(event.getDraft());
break;
case CONSTRUCT:
construct();
break;
case START_MATCH:
initTournament(); // set state
startMatch(event.getPair(), event.getMatchOptions());
break;
// case SUBMIT_DECK:
// submitDeck(event.getPlayerId(), event.getDeck());
// break;
case CONSTRUCT:
construct();
break;
case END:
endTournament();
break;
@ -185,6 +188,7 @@ public class TournamentController {
tournamentSession.removeTournament();
}
TableManager.getInstance().endTournament(tableId, tournament);
}
private void startMatch(TournamentPairing pair, MatchOptions matchOptions) {
@ -210,6 +214,10 @@ public class TournamentController {
TableManager.getInstance().construct(tableId);
}
private void initTournament() {
TableManager.getInstance().initTournament(tableId);
}
private void construct(UUID playerId, int timeout) throws MageException {
if (tournamentSessions.containsKey(playerId)) {
TournamentSession tournamentSession = tournamentSessions.get(playerId);