mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 19:41: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
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.1" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||||
<AuxValues>
|
<AuxValues>
|
||||||
|
|
@ -21,8 +21,8 @@
|
||||||
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
|
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||||
<Component id="jPanel2" pref="779" max="32767" attributes="0"/>
|
<Component id="jPanel2" pref="809" max="32767" attributes="0"/>
|
||||||
<EmptySpace pref="69" max="32767" attributes="0"/>
|
<EmptySpace pref="99" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
@ -32,12 +32,12 @@
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
|
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||||
<Component id="jSplitPane1" pref="501" max="32767" attributes="0"/>
|
<Component id="jSplitPane1" max="32767" attributes="0"/>
|
||||||
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||||
<Component id="jPanel2" min="-2" pref="25" max="-2" attributes="0"/>
|
<Component id="jPanel2" min="-2" pref="25" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
|
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
|
||||||
<EmptySpace min="0" pref="576" max="32767" attributes="0"/>
|
<EmptySpace min="0" pref="580" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
|
|
@ -131,7 +131,7 @@
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="jLabel2" pref="449" max="32767" attributes="0"/>
|
<Component id="jLabel2" max="32767" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace min="-2" pref="440" max="-2" attributes="0"/>
|
<EmptySpace min="-2" pref="440" max="-2" attributes="0"/>
|
||||||
|
|
@ -218,7 +218,7 @@
|
||||||
<Layout>
|
<Layout>
|
||||||
<DimensionLayout dim="0">
|
<DimensionLayout dim="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Component id="jSplitPane2" alignment="0" pref="743" max="32767" attributes="0"/>
|
<Component id="jSplitPane2" alignment="0" pref="803" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
|
|
|
||||||
|
|
@ -162,8 +162,10 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
session.removeTable(roomId, tableId);
|
session.removeTable(roomId, tableId);
|
||||||
}
|
}
|
||||||
} else if (state.equals("Watch")) {
|
} else if (state.equals("Watch")) {
|
||||||
logger.info("Watching table " + tableId);
|
if (!isTournament) {
|
||||||
session.watchTable(roomId, tableId);
|
logger.info("Watching table " + tableId);
|
||||||
|
session.watchTable(roomId, tableId);
|
||||||
|
}
|
||||||
} else if (state.equals("Replay")) {
|
} else if (state.equals("Replay")) {
|
||||||
logger.info("Replaying game " + gameId);
|
logger.info("Replaying game " + gameId);
|
||||||
// no replay because of memory leaks
|
// no replay because of memory leaks
|
||||||
|
|
@ -653,7 +655,12 @@ class TableTableModel extends AbstractTableModel {
|
||||||
if (session != null && owner.equals(session.getUserName())) {
|
if (session != null && owner.equals(session.getUserName())) {
|
||||||
return "Remove";
|
return "Remove";
|
||||||
}
|
}
|
||||||
return "Watch";
|
if (tables[arg0].isTournament()) {
|
||||||
|
return "None";
|
||||||
|
} else {
|
||||||
|
return "Watch";
|
||||||
|
}
|
||||||
|
|
||||||
case FINISHED:
|
case FINISHED:
|
||||||
owner = tables[arg0].getControllerName();
|
owner = tables[arg0].getControllerName();
|
||||||
if (session != null && owner.equals(session.getUserName())) {
|
if (session != null && owner.equals(session.getUserName())) {
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,10 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.Table;
|
||||||
import mage.game.match.Match;
|
import mage.game.match.Match;
|
||||||
import mage.game.match.MatchPlayer;
|
import mage.game.match.MatchPlayer;
|
||||||
|
import mage.game.tournament.TournamentPlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -69,6 +71,25 @@ public class MatchView implements Serializable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// used for tournaments
|
||||||
|
public MatchView(Table table) {
|
||||||
|
this.matchId = table.getTournament().getId();
|
||||||
|
this.matchName = table.getName();
|
||||||
|
this.gameType = table.getGameType();
|
||||||
|
this.deckType = table.getDeckType();
|
||||||
|
|
||||||
|
StringBuilder sb1 = new StringBuilder();
|
||||||
|
for (TournamentPlayer tPlayer : table.getTournament().getPlayers()) {
|
||||||
|
sb1.append(tPlayer.getPlayer().getName()).append(" (").append(tPlayer.getPoints()).append(" P.) ");
|
||||||
|
}
|
||||||
|
this.players = sb1.toString();
|
||||||
|
StringBuilder sb2 = new StringBuilder();
|
||||||
|
for (TournamentPlayer tPlayer : table.getTournament().getPlayers()) {
|
||||||
|
sb2.append(tPlayer.getPlayer().getName()).append(": ").append(tPlayer.getResults()).append(" ");
|
||||||
|
}
|
||||||
|
this.result = sb2.toString();
|
||||||
|
}
|
||||||
|
|
||||||
public UUID getMatchId() {
|
public UUID getMatchId() {
|
||||||
return matchId;
|
return matchId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,11 @@ public class TableView implements Serializable {
|
||||||
games.add(game.getId());
|
games.add(game.getId());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.additionalInfo = new StringBuilder("Seats: ").append(table.getTournament().getPlayers().size()).append("/").append(table.getNumberOfSeats()).toString();
|
StringBuilder sb = new StringBuilder("Seats: ").append(table.getTournament().getPlayers().size()).append("/").append(table.getNumberOfSeats());
|
||||||
|
if (table.getState().equals(TableState.DUELING)) {
|
||||||
|
sb.append(" - Running round: ").append(table.getTournament().getRounds().size());
|
||||||
|
}
|
||||||
|
this.additionalInfo = sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,8 @@ public class BoosterDraftEliminationTournament extends TournamentSingleEliminati
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void winners() {
|
protected void winners() {
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
// TODO: Show winners and tournament result
|
||||||
|
// throw new UnsupportedOperationException("Not supported yet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -83,6 +84,7 @@ public class BoosterDraftEliminationTournament extends TournamentSingleEliminati
|
||||||
case COMPETE:
|
case COMPETE:
|
||||||
currentStep = TournamentStep.WINNERS;
|
currentStep = TournamentStep.WINNERS;
|
||||||
winners();
|
winners();
|
||||||
|
end();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,8 @@ public class SealedEliminationTournament extends TournamentSingleElimination {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void winners() {
|
protected void winners() {
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
// TODO: Show winners and tournament result
|
||||||
|
// throw new UnsupportedOperationException("Not supported yet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -70,6 +71,7 @@ public class SealedEliminationTournament extends TournamentSingleElimination {
|
||||||
case COMPETE:
|
case COMPETE:
|
||||||
currentStep = TournamentStep.WINNERS;
|
currentStep = TournamentStep.WINNERS;
|
||||||
winners();
|
winners();
|
||||||
|
end();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -418,6 +418,14 @@ public class TableController {
|
||||||
table.construct();
|
table.construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void initTournament() {
|
||||||
|
table.initTournament();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endTournament(Tournament tournament) {
|
||||||
|
table.endTournament();
|
||||||
|
}
|
||||||
|
|
||||||
public MatchOptions getOptions() {
|
public MatchOptions getOptions() {
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
@ -483,10 +491,6 @@ public class TableController {
|
||||||
tournament.nextStep();
|
tournament.nextStep();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endTournament(Tournament tournament) {
|
|
||||||
//TODO: implement this
|
|
||||||
}
|
|
||||||
|
|
||||||
public void swapSeats(int seatNum1, int seatNum2) {
|
public void swapSeats(int seatNum1, int seatNum2) {
|
||||||
if (table.getState() == TableState.STARTING) {
|
if (table.getState() == TableState.STARTING) {
|
||||||
if (seatNum1 >= 0 && seatNum2 >= 0 && seatNum1 < table.getSeats().length && seatNum2 < table.getSeats().length) {
|
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 {
|
public void addPlayer(UUID userId, UUID tableId, Player player, String playerType, Deck deck) throws GameException {
|
||||||
if (controllers.containsKey(tableId)) {
|
if (controllers.containsKey(tableId)) {
|
||||||
controllers.get(tableId).addPlayer(userId, player, playerType, deck);
|
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));
|
tableList.add(new TableView(table));
|
||||||
}
|
}
|
||||||
else if (matchList.size() < 50) {
|
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()) {
|
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?
|
// Any special action needed?
|
||||||
}
|
}
|
||||||
this.removeTable(table.getId());
|
this.removeTable(table.getId());
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ import mage.game.draft.Draft;
|
||||||
import mage.game.events.Listener;
|
import mage.game.events.Listener;
|
||||||
import mage.game.events.PlayerQueryEvent;
|
import mage.game.events.PlayerQueryEvent;
|
||||||
import mage.game.events.TableEvent;
|
import mage.game.events.TableEvent;
|
||||||
|
import static mage.game.events.TableEvent.EventType.CONSTRUCT;
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
import mage.game.tournament.Tournament;
|
import mage.game.tournament.Tournament;
|
||||||
import mage.game.tournament.TournamentPairing;
|
import mage.game.tournament.TournamentPairing;
|
||||||
|
|
@ -89,15 +90,17 @@ public class TournamentController {
|
||||||
case START_DRAFT:
|
case START_DRAFT:
|
||||||
startDraft(event.getDraft());
|
startDraft(event.getDraft());
|
||||||
break;
|
break;
|
||||||
|
case CONSTRUCT:
|
||||||
|
construct();
|
||||||
|
break;
|
||||||
case START_MATCH:
|
case START_MATCH:
|
||||||
|
initTournament(); // set state
|
||||||
startMatch(event.getPair(), event.getMatchOptions());
|
startMatch(event.getPair(), event.getMatchOptions());
|
||||||
break;
|
break;
|
||||||
// case SUBMIT_DECK:
|
// case SUBMIT_DECK:
|
||||||
// submitDeck(event.getPlayerId(), event.getDeck());
|
// submitDeck(event.getPlayerId(), event.getDeck());
|
||||||
// break;
|
// break;
|
||||||
case CONSTRUCT:
|
|
||||||
construct();
|
|
||||||
break;
|
|
||||||
case END:
|
case END:
|
||||||
endTournament();
|
endTournament();
|
||||||
break;
|
break;
|
||||||
|
|
@ -185,6 +188,7 @@ public class TournamentController {
|
||||||
tournamentSession.removeTournament();
|
tournamentSession.removeTournament();
|
||||||
}
|
}
|
||||||
TableManager.getInstance().endTournament(tableId, tournament);
|
TableManager.getInstance().endTournament(tableId, tournament);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startMatch(TournamentPairing pair, MatchOptions matchOptions) {
|
private void startMatch(TournamentPairing pair, MatchOptions matchOptions) {
|
||||||
|
|
@ -210,6 +214,10 @@ public class TournamentController {
|
||||||
TableManager.getInstance().construct(tableId);
|
TableManager.getInstance().construct(tableId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initTournament() {
|
||||||
|
TableManager.getInstance().initTournament(tableId);
|
||||||
|
}
|
||||||
|
|
||||||
private void construct(UUID playerId, int timeout) throws MageException {
|
private void construct(UUID playerId, int timeout) throws MageException {
|
||||||
if (tournamentSessions.containsKey(playerId)) {
|
if (tournamentSessions.containsKey(playerId)) {
|
||||||
TournamentSession tournamentSession = tournamentSessions.get(playerId);
|
TournamentSession tournamentSession = tournamentSessions.get(playerId);
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,10 @@ public class Table implements Serializable {
|
||||||
state = TableState.DUELING;
|
state = TableState.DUELING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void endTournament() {
|
||||||
|
state = TableState.FINISHED;
|
||||||
|
}
|
||||||
|
|
||||||
public void initDraft() {
|
public void initDraft() {
|
||||||
state = TableState.DRAFTING;
|
state = TableState.DRAFTING;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -278,6 +278,10 @@ public abstract class TournamentImpl implements Tournament {
|
||||||
tableEventSource.fireTableEvent(EventType.START_MATCH, pair, options.getMatchOptions());
|
tableEventSource.fireTableEvent(EventType.START_MATCH, pair, options.getMatchOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void end() {
|
||||||
|
tableEventSource.fireTableEvent(EventType.END);
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract void runTournament();
|
protected abstract void runTournament();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue