mirror of
https://github.com/magefree/mage.git
synced 2026-01-24 20:29:19 -08:00
Improved reconnect and tournament handling. Reconnect time is now shown for disconneted players on player list and tournament panel. You can now reconnect (during 3 minutes) to a tournament also if meanwhile new game (after sideboarding ended) or round was started. Conceding the complete match in a tournament can no longer result in a draw, if you won games before. Quitting a tournament does now always end all active games of that quitting player.
This commit is contained in:
parent
c76529bf91
commit
9ff5bcbd92
29 changed files with 282 additions and 109 deletions
|
|
@ -46,7 +46,7 @@ public class TableEvent extends EventObject implements ExternalEvent, Serializab
|
|||
|
||||
public enum EventType {
|
||||
UPDATE, INFO, STATUS, START_DRAFT, START_MATCH, SIDEBOARD, CONSTRUCT, SUBMIT_DECK, END, END_GAME_INFO, ERROR,
|
||||
INIT_TIMER, RESUME_TIMER, PAUSE_TIMER
|
||||
INIT_TIMER, RESUME_TIMER, PAUSE_TIMER, CHECK_STATE_PLAYERS
|
||||
}
|
||||
|
||||
private Game game;
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ public class Round {
|
|||
public boolean isRoundOver() {
|
||||
boolean roundIsOver = true;
|
||||
for (TournamentPairing pair: pairs) {
|
||||
if (!pair.getMatch().isMatchOver()) {
|
||||
if (pair.getMatch() != null && !pair.getMatch().isMatchOver()) {
|
||||
roundIsOver = false;
|
||||
} else {
|
||||
if (!pair.isAlreadyPublished()) {
|
||||
|
|
|
|||
|
|
@ -199,6 +199,7 @@ public abstract class TournamentImpl implements Tournament {
|
|||
}
|
||||
|
||||
protected void playRound(Round round) {
|
||||
|
||||
for (TournamentPairing pair: round.getPairs()) {
|
||||
playMatch(pair);
|
||||
}
|
||||
|
|
@ -240,7 +241,7 @@ public abstract class TournamentImpl implements Tournament {
|
|||
UUID player1Id = pair.getPlayer1().getPlayer().getId();
|
||||
UUID player2Id = pair.getPlayer2().getPlayer().getId();
|
||||
Match match = pair.getMatch();
|
||||
if (match.isMatchOver()) {
|
||||
if (match != null && match.isMatchOver()) {
|
||||
if (round.getRoundNumber() == rounds.size()) {
|
||||
if (players.get(player1Id).getState().equals(TournamentPlayerState.DUELING)) {
|
||||
players.get(player1Id).setState(TournamentPlayerState.WAITING);
|
||||
|
|
@ -259,10 +260,10 @@ public abstract class TournamentImpl implements Tournament {
|
|||
sb2.append("-").append(match.getPlayer(player1Id).getWins()).append(") ");
|
||||
players.get(player1Id).setResults(sb1.toString());
|
||||
players.get(player2Id).setResults(sb2.toString());
|
||||
if (match.getPlayer(player1Id).getWins() > match.getPlayer(player2Id).getWins()) {
|
||||
if (match.getPlayer(player2Id).hasQuit() || match.getPlayer(player1Id).getWins() > match.getPlayer(player2Id).getWins()) {
|
||||
int points = players.get(player1Id).getPoints();
|
||||
players.get(player1Id).setPoints(points + 3);
|
||||
} else if (match.getPlayer(player1Id).getWins() < match.getPlayer(player2Id).getWins()) {
|
||||
} else if (match.getPlayer(player1Id).hasQuit() || match.getPlayer(player1Id).getWins() < match.getPlayer(player2Id).getWins()) {
|
||||
int points = players.get(player2Id).getPoints();
|
||||
players.get(player2Id).setPoints(points + 3);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -42,10 +42,11 @@ public class TournamentPlayer {
|
|||
protected int points;
|
||||
protected String playerType;
|
||||
protected TournamentPlayerState state;
|
||||
protected String stateInfo = "";
|
||||
protected String stateInfo;
|
||||
protected String disconnectInfo;
|
||||
protected Player player;
|
||||
protected Deck deck;
|
||||
protected String results = "";
|
||||
protected String results;
|
||||
protected boolean eliminated = false;
|
||||
protected boolean quit = false;
|
||||
protected boolean doneConstructing;
|
||||
|
|
@ -55,6 +56,10 @@ public class TournamentPlayer {
|
|||
this.player = player;
|
||||
this.playerType = playerType;
|
||||
this.state = TournamentPlayerState.JOINED;
|
||||
this.stateInfo = "";
|
||||
this.disconnectInfo = "";
|
||||
this.results = "";
|
||||
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
|
|
@ -151,6 +156,14 @@ public class TournamentPlayer {
|
|||
this.stateInfo = stateInfo;
|
||||
}
|
||||
|
||||
public String getDisconnectInfo() {
|
||||
return disconnectInfo;
|
||||
}
|
||||
|
||||
public void setDisconnectInfo(String disconnectInfo) {
|
||||
this.disconnectInfo = disconnectInfo;
|
||||
}
|
||||
|
||||
public boolean hasQuit() {
|
||||
return quit;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ package mage.game.tournament;
|
|||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import mage.game.events.TableEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -43,15 +44,15 @@ public abstract class TournamentSingleElimination extends TournamentImpl {
|
|||
|
||||
@Override
|
||||
protected void runTournament() {
|
||||
|
||||
for (Map.Entry<UUID, TournamentPlayer> entry: players.entrySet()) {
|
||||
if (entry.getValue().getPlayer().autoLoseGame()) {
|
||||
entry.getValue().setEliminated();
|
||||
entry.getValue().setResults("Auto Eliminated");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
while (this.getActivePlayers().size() > 1) {
|
||||
// check if some player got killed / disconnected meanwhile and update their state
|
||||
tableEventSource.fireTableEvent(TableEvent.EventType.CHECK_STATE_PLAYERS);
|
||||
Round round = createRoundRandom();
|
||||
playRound(round);
|
||||
eliminatePlayers(round);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import mage.constants.TournamentPlayerState;
|
||||
import mage.game.events.TableEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -45,7 +46,7 @@ public abstract class TournamentSwiss extends TournamentImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void runTournament() {
|
||||
protected void runTournament() {
|
||||
for (Map.Entry<UUID, TournamentPlayer> entry: players.entrySet()) {
|
||||
if (entry.getValue().getPlayer().autoLoseGame()) {
|
||||
entry.getValue().setEliminated();
|
||||
|
|
@ -54,6 +55,8 @@ public abstract class TournamentSwiss extends TournamentImpl {
|
|||
}
|
||||
|
||||
while (this.getActivePlayers().size() > 1 && this.getNumberRounds() > this.getRounds().size()) {
|
||||
// check if some player got killed / disconnected meanwhile and update their state
|
||||
tableEventSource.fireTableEvent(TableEvent.EventType.CHECK_STATE_PLAYERS);
|
||||
// Swiss pairing
|
||||
Round round = createRoundSwiss();
|
||||
playRound(round);
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
|||
this.wins = false;
|
||||
this.loses = false;
|
||||
this.left = false;
|
||||
// quittet won't be reset because the player stays quit
|
||||
this.quit = false;
|
||||
this.passed = false;
|
||||
this.passedTurn = false;
|
||||
this.passedAllTurns = false;
|
||||
|
|
@ -1469,6 +1469,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
|||
|
||||
@Override
|
||||
public void quit(Game game) {
|
||||
quit = true;
|
||||
this.concede(game);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue