Added - queue configurator check max player count for live draft tables
This commit is contained in:
@@ -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)))
|
.filter(code -> _soloDraftDefinitions.getAllSoloDrafts().values().stream().anyMatch(soloDraft -> code.equals(soloDraft.getCode()))).map(code -> new JSONDefs.ItemStub(code, availableSoloDraftFormats.get(code)))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
data.tableDrafts = _tableDraftLibrary.getAllTableDrafts().stream()
|
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());
|
.collect(Collectors.toList());
|
||||||
data.draftTimerTypes = DraftTimer.getAllTypes();
|
data.draftTimerTypes = DraftTimer.getAllTypes();
|
||||||
|
|
||||||
@@ -228,6 +228,8 @@ public class TournamentRequestHandler extends LotroServerRequestHandler implemen
|
|||||||
Throw400IfStringNull("tableDraftFormatCode", tableDraftFormatCodeStr);
|
Throw400IfStringNull("tableDraftFormatCode", tableDraftFormatCodeStr);
|
||||||
var tableDraftDefinition = _tableDraftLibrary.getTableDraftDefinition(tableDraftFormatCodeStr);
|
var tableDraftDefinition = _tableDraftLibrary.getTableDraftDefinition(tableDraftFormatCodeStr);
|
||||||
Throw400IfValidationFails("tableDraftFormatCode", tableDraftFormatCodeStr,tableDraftDefinition != null);
|
Throw400IfValidationFails("tableDraftFormatCode", tableDraftFormatCodeStr,tableDraftDefinition != null);
|
||||||
|
//Check if all players can get to one table
|
||||||
|
Throw400IfValidationFails("maxPlayers", maxPlayersStr, tableDraftDefinition.getMaxPlayers() < maxPlayers);
|
||||||
tableDraftParams.tableDraftFormatCode = tableDraftFormatCodeStr;
|
tableDraftParams.tableDraftFormatCode = tableDraftFormatCodeStr;
|
||||||
tableDraftParams.format = tableDraftDefinition.getFormat();
|
tableDraftParams.format = tableDraftDefinition.getFormat();
|
||||||
tableDraftParams.draftTimerType = DraftTimer.getTypeFromString(tableDraftTimer);
|
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.cost = 0; // Gold is not being used, they can be free to enter
|
||||||
params.playoff = Tournament.PairingType.parse(playoff);
|
params.playoff = Tournament.PairingType.parse(playoff);
|
||||||
params.tiebreaker = "owr";
|
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.maximumPlayers = maxPlayers;
|
||||||
params.manualKickoff = false;
|
params.manualKickoff = false;
|
||||||
|
|
||||||
|
|||||||
@@ -189,7 +189,13 @@ var GempLotrHallUI = Class.extend({
|
|||||||
const startableEarly = $("#startableEarlySelect").val();
|
const startableEarly = $("#startableEarlySelect").val();
|
||||||
const readyCheck = $("#readyCheckSelect").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 validDeckDuration = Number.isInteger(deckDuration) && deckDuration >= 5;
|
||||||
const draftValid = gameType !== "table_draft" || draftTimer;
|
const draftValid = gameType !== "table_draft" || draftTimer;
|
||||||
const validPlayerReadyCombo = playerCount > 2 || readyCheck < 0;
|
const validPlayerReadyCombo = playerCount > 2 || readyCheck < 0;
|
||||||
@@ -247,11 +253,16 @@ var GempLotrHallUI = Class.extend({
|
|||||||
|
|
||||||
// Fill options
|
// Fill options
|
||||||
for (const format of formats) {
|
for (const format of formats) {
|
||||||
$select.append(
|
const $option = $("<option>")
|
||||||
$("<option>")
|
.val(format.code)
|
||||||
.val(format.code)
|
.text(format.name);
|
||||||
.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
|
// Number of players
|
||||||
@@ -260,6 +271,22 @@ var GempLotrHallUI = Class.extend({
|
|||||||
.attr({ type: "number", id: "numPlayers", name: "numPlayers", min: 1 })
|
.attr({ type: "number", id: "numPlayers", name: "numPlayers", min: 1 })
|
||||||
.val(4);
|
.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
|
// Pairing type
|
||||||
const $pairingLabel = $("<label>").attr("for", "pairingType").text("Pairing type:");
|
const $pairingLabel = $("<label>").attr("for", "pairingType").text("Pairing type:");
|
||||||
const $pairingSelect = $("<select>")
|
const $pairingSelect = $("<select>")
|
||||||
|
|||||||
@@ -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 static class Format {
|
||||||
public String adventure;
|
public String adventure;
|
||||||
public String code;
|
public String code;
|
||||||
@@ -91,7 +104,7 @@ public class JSONDefs {
|
|||||||
public static class PlayerMadeTournamentAvailableFormats {
|
public static class PlayerMadeTournamentAvailableFormats {
|
||||||
public List<ItemStub> sealed;
|
public List<ItemStub> sealed;
|
||||||
public List<ItemStub> soloDrafts;
|
public List<ItemStub> soloDrafts;
|
||||||
public List<ItemStub> tableDrafts;
|
public List<LiveDraftInfo> tableDrafts;
|
||||||
public List<String> draftTimerTypes;
|
public List<String> draftTimerTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user