Added - queue configurator check max player count for live draft tables

This commit is contained in:
jakub.salavec
2025-06-13 16:22:08 +02:00
parent 71f6b33503
commit 1a8f93eb25
3 changed files with 51 additions and 9 deletions

View File

@@ -116,7 +116,7 @@ public class TournamentRequestHandler extends LotroServerRequestHandler implemen
.filter(code -> _soloDraftDefinitions.getAllSoloDrafts().values().stream().anyMatch(soloDraft -> code.equals(soloDraft.getCode()))).map(code -> new JSONDefs.ItemStub(code, availableSoloDraftFormats.get(code)))
.collect(Collectors.toList());
data.tableDrafts = _tableDraftLibrary.getAllTableDrafts().stream()
.map(tableDraftDefinition -> new JSONDefs.ItemStub(tableDraftDefinition.getCode(), tableDraftDefinition.getName()))
.map(tableDraftDefinition -> new JSONDefs.LiveDraftInfo(tableDraftDefinition.getCode(), tableDraftDefinition.getName(), tableDraftDefinition.getMaxPlayers(), tableDraftDefinition.getRecommendedTimer().name()))
.collect(Collectors.toList());
data.draftTimerTypes = DraftTimer.getAllTypes();
@@ -228,6 +228,8 @@ public class TournamentRequestHandler extends LotroServerRequestHandler implemen
Throw400IfStringNull("tableDraftFormatCode", tableDraftFormatCodeStr);
var tableDraftDefinition = _tableDraftLibrary.getTableDraftDefinition(tableDraftFormatCodeStr);
Throw400IfValidationFails("tableDraftFormatCode", tableDraftFormatCodeStr,tableDraftDefinition != null);
//Check if all players can get to one table
Throw400IfValidationFails("maxPlayers", maxPlayersStr, tableDraftDefinition.getMaxPlayers() < maxPlayers);
tableDraftParams.tableDraftFormatCode = tableDraftFormatCodeStr;
tableDraftParams.format = tableDraftDefinition.getFormat();
tableDraftParams.draftTimerType = DraftTimer.getTypeFromString(tableDraftTimer);
@@ -244,7 +246,7 @@ public class TournamentRequestHandler extends LotroServerRequestHandler implemen
params.cost = 0; // Gold is not being used, they can be free to enter
params.playoff = Tournament.PairingType.parse(playoff);
params.tiebreaker = "owr";
params.prizes = Tournament.PrizeType.LIMITED; // At 4+ players, get one Event Award for each win or buy
params.prizes = Tournament.PrizeType.LIMITED; // At 4+ players, get one Event Award for each win or bye
params.maximumPlayers = maxPlayers;
params.manualKickoff = false;

View File

@@ -189,7 +189,13 @@ var GempLotrHallUI = Class.extend({
const startableEarly = $("#startableEarlySelect").val();
const readyCheck = $("#readyCheckSelect").val();
const validPlayerCount = Number.isInteger(playerCount) && playerCount >= 1;
const formatMaxPlayers = $("#formatSelect").find("option:selected").data("maxplayers");
var validMaxPlayers = true;
if (formatMaxPlayers) {
validMaxPlayers = playerCount <= formatMaxPlayers;
}
const validPlayerCount = Number.isInteger(playerCount) && playerCount >= 1 && validMaxPlayers;
const validDeckDuration = Number.isInteger(deckDuration) && deckDuration >= 5;
const draftValid = gameType !== "table_draft" || draftTimer;
const validPlayerReadyCombo = playerCount > 2 || readyCheck < 0;
@@ -247,11 +253,16 @@ var GempLotrHallUI = Class.extend({
// Fill options
for (const format of formats) {
$select.append(
$("<option>")
.val(format.code)
.text(format.name)
);
const $option = $("<option>")
.val(format.code)
.text(format.name);
// For live draft, save the table capacity
if (gameType === "table_draft" && format.maxPlayers) {
$option.attr("data-maxplayers", format.maxPlayers);
}
$select.append($option);
}
// Number of players
@@ -260,6 +271,22 @@ var GempLotrHallUI = Class.extend({
.attr({ type: "number", id: "numPlayers", name: "numPlayers", min: 1 })
.val(4);
// Modify the max number of players based on format selected (if needed)
$select.on("change", function () {
const selectedFormat = $(this).find("option:selected");
const maxPlayers = selectedFormat.data("maxplayers");
if (maxPlayers) {
$playersInput.attr("max", maxPlayers);
const currentVal = parseInt($playersInput.val(), 10);
if (currentVal > maxPlayers) {
$playersInput.val(maxPlayers);
}
} else {
$playersInput.removeAttr("max");
}
});
// Pairing type
const $pairingLabel = $("<label>").attr("for", "pairingType").text("Pairing type:");
const $pairingSelect = $("<select>")

View File

@@ -31,6 +31,19 @@ public class JSONDefs {
}
}
public static class LiveDraftInfo {
public String code;
public String name;
public int maxPlayers;
public String recommendedTimer;
public LiveDraftInfo(String c, String n, int p, String t) {
code = c;
name = n;
maxPlayers = p;
recommendedTimer = t;
}
}
public static class Format {
public String adventure;
public String code;
@@ -91,7 +104,7 @@ public class JSONDefs {
public static class PlayerMadeTournamentAvailableFormats {
public List<ItemStub> sealed;
public List<ItemStub> soloDrafts;
public List<ItemStub> tableDrafts;
public List<LiveDraftInfo> tableDrafts;
public List<String> draftTimerTypes;
}