server, refactor: added client side info about current table and parent table (tourney's sub-tables with matches);

This commit is contained in:
Oleg Agafonov 2024-08-11 19:29:42 +04:00
parent bd7aaa34ee
commit 7916af0e52
21 changed files with 315 additions and 161 deletions

View file

@ -5,6 +5,7 @@ import java.io.Serializable;
import java.util.*;
import mage.cards.decks.DeckValidator;
import mage.constants.TableState;
import mage.game.draft.Draft;
import mage.game.events.Listener;
import mage.game.events.TableEvent;
import mage.game.events.TableEventSource;
@ -15,7 +16,7 @@ import mage.players.Player;
import mage.players.PlayerType;
/**
* @author BetaSteward_at_googlemail.com
* @author BetaSteward_at_googlemail.com, JayDi85
*/
public class Table implements Serializable {
@ -28,7 +29,10 @@ public class Table implements Serializable {
private Seat[] seats;
private int numSeats;
private boolean isTournament;
private boolean tournamentSubTable;
private boolean tournamentSubTable; // must assign by setTournamentSubTable only
private UUID parentTableId = null; // original tourney table
private DeckValidator validator;
private TableState state;
private Match match;
@ -87,6 +91,10 @@ public class Table implements Serializable {
return tableId;
}
public UUID getParentTableId() {
return parentTableId;
}
public UUID getRoomId() {
return roomId;
}
@ -104,9 +112,10 @@ public class Table implements Serializable {
setState(TableState.FINISHED);
}
public void initDraft() {
public void initDraft(Draft draft) {
setState(TableState.DRAFTING);
tournament.setStepStartTime(new Date());
draft.setTableId(this.getId());
}
public void construct() {
@ -262,8 +271,9 @@ public class Table implements Serializable {
return tournamentSubTable;
}
public void setTournamentSubTable(boolean tournamentSubTable) {
this.tournamentSubTable = tournamentSubTable;
public void setTournamentSubTable(UUID parentTableId) {
this.tournamentSubTable = true;
this.parentTableId = parentTableId;
}
public Date getStartTime() {

View file

@ -20,6 +20,9 @@ import mage.players.Player;
*/
public interface Draft extends MageItem, Serializable {
UUID getTableId();
void setTableId(UUID tableId);
void addPlayer(Player player);
Collection<DraftPlayer> getPlayers();
boolean replacePlayer(Player oldPlayer, Player newPlayer);

View file

@ -25,6 +25,7 @@ public abstract class DraftImpl implements Draft {
protected static final Logger logger = Logger.getLogger(DraftImpl.class);
protected final UUID id;
protected UUID tableId = null;
protected final Map<UUID, DraftPlayer> players = new LinkedHashMap<>();
protected final PlayerList table = new PlayerList();
protected int numberBoosters;
@ -47,7 +48,7 @@ public abstract class DraftImpl implements Draft {
protected ScheduledExecutorService boosterLoadingExecutor = null;
public DraftImpl(DraftOptions options, List<ExpansionSet> sets) {
id = UUID.randomUUID();
this.id = UUID.randomUUID();
this.setCodes = options.getSetCodes();
this.draftCube = options.getDraftCube();
this.timing = options.getTiming();
@ -60,6 +61,16 @@ public abstract class DraftImpl implements Draft {
return id;
}
@Override
public UUID getTableId() {
return tableId;
}
@Override
public void setTableId(UUID tableId) {
this.tableId = tableId;
}
@Override
public void addPlayer(Player player) {
DraftPlayer draftPlayer = new DraftPlayer(player);

View file

@ -26,6 +26,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
public abstract class TournamentImpl implements Tournament {
protected UUID id = UUID.randomUUID();
protected UUID tableId = null; // assign on table create
protected List<Round> rounds = new CopyOnWriteArrayList<>();
protected Map<UUID, TournamentPlayer> players = new HashMap<>();
protected TournamentOptions options;