mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 20:11:59 -08:00
Tournaments status is updated now and if tournament finished, it's moved to the lower finished matches view.
This commit is contained in:
parent
095c3c5776
commit
402f7fffd9
12 changed files with 89 additions and 24 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue