Added - queue configurator early start option; Modified - minimum number of players moved to 1 from 2

This commit is contained in:
jakub.salavec
2025-06-13 14:37:17 +02:00
parent a7057ee042
commit 3a6722b104
3 changed files with 33 additions and 15 deletions

View File

@@ -35,7 +35,6 @@ import java.time.ZonedDateTime;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Predicate;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class TournamentRequestHandler extends LotroServerRequestHandler implements UriRequestHandler { public class TournamentRequestHandler extends LotroServerRequestHandler implements UriRequestHandler {
@@ -139,6 +138,9 @@ public class TournamentRequestHandler extends LotroServerRequestHandler implemen
String competitiveStr = getFormParameterSafely(postDecoder, "competitive"); String competitiveStr = getFormParameterSafely(postDecoder, "competitive");
boolean competitive = Throw400IfNullOrNonBoolean("competitive", competitiveStr); boolean competitive = Throw400IfNullOrNonBoolean("competitive", competitiveStr);
String startableStr = getFormParameterSafely(postDecoder, "startable");
boolean startable = Throw400IfNullOrNonBoolean("startable", startableStr);
String sealedFormatCodeStr = getFormParameterSafely(postDecoder, "sealedFormatCode"); String sealedFormatCodeStr = getFormParameterSafely(postDecoder, "sealedFormatCode");
String soloDraftFormatCodeStr = getFormParameterSafely(postDecoder, "soloDraftFormatCode"); String soloDraftFormatCodeStr = getFormParameterSafely(postDecoder, "soloDraftFormatCode");
@@ -164,7 +166,7 @@ public class TournamentRequestHandler extends LotroServerRequestHandler implemen
String competitivePrefix = "Competitive "; String competitivePrefix = "Competitive ";
String prefix = competitive ? competitivePrefix : casualPrefix; String prefix = competitive ? competitivePrefix : casualPrefix;
//TODO ready check, ready check time, startable early //TODO ready check, ready check time
if(type == Tournament.TournamentType.SEALED) { if(type == Tournament.TournamentType.SEALED) {
var sealedParams = new SealedTournamentParams(); var sealedParams = new SealedTournamentParams();
@@ -264,7 +266,7 @@ public class TournamentRequestHandler extends LotroServerRequestHandler implemen
return; return;
} }
if (_hallServer.addPlayerMadeLimitedQueue(info, resourceOwner, false, -1)) { if (_hallServer.addPlayerMadeLimitedQueue(info, resourceOwner, startable, -1)) {
responseWriter.sendJsonOK(); responseWriter.sendJsonOK();
} else { } else {
Throw400IfValidationFails("Error", "Error", false, "Error while creating queue or joining"); Throw400IfValidationFails("Error", "Error", false, "Error while creating queue or joining");

View File

@@ -1445,7 +1445,7 @@ var GempLotrCommunication = Class.extend({
}); });
}, },
createTournament:function (type, maxPlayers, sealedFormatCode, soloDraftFormatCode, tableDraftFormatCode, tableDraftTimer, createTournament:function (type, maxPlayers, sealedFormatCode, soloDraftFormatCode, tableDraftFormatCode, tableDraftTimer,
playoff, deckbuildingDuration, competitive, callback, errorMap) { playoff, deckbuildingDuration, competitive, startable, callback, errorMap) {
$.ajax({ $.ajax({
type:"POST", type:"POST",
url:this.url + "/tournament/create", url:this.url + "/tournament/create",
@@ -1460,6 +1460,7 @@ var GempLotrCommunication = Class.extend({
playoff:playoff, playoff:playoff,
deckbuildingDuration:deckbuildingDuration, deckbuildingDuration:deckbuildingDuration,
competitive:competitive, competitive:competitive,
startable:startable,
participantId:getUrlParam("participantId") participantId:getUrlParam("participantId")
}, },
success:this.deliveryCheck(callback), success:this.deliveryCheck(callback),

View File

@@ -185,8 +185,10 @@ var GempLotrHallUI = Class.extend({
const playerCount = parseInt($("#numPlayers").val(), 10); const playerCount = parseInt($("#numPlayers").val(), 10);
const deckDuration = parseInt($("#deckDuration").val(), 10); const deckDuration = parseInt($("#deckDuration").val(), 10);
const draftTimer = $("#draftTimer").val(); const draftTimer = $("#draftTimer").val();
const competitive = $("#competitiveSelect").val();
const startableEarly = $("#startableEarlySelect").val();
const validPlayerCount = Number.isInteger(playerCount) && playerCount >= 2; const validPlayerCount = Number.isInteger(playerCount) && playerCount >= 1;
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;
@@ -196,6 +198,8 @@ var GempLotrHallUI = Class.extend({
pairingType && pairingType &&
validPlayerCount && validPlayerCount &&
validDeckDuration && validDeckDuration &&
competitive &&
startableEarly &&
draftValid; draftValid;
$("#createTournamentButton").prop("disabled", !allValid); $("#createTournamentButton").prop("disabled", !allValid);
@@ -249,7 +253,7 @@ var GempLotrHallUI = Class.extend({
// Number of players // Number of players
const $playersLabel = $("<label>").attr("for", "numPlayers").text("Number of players:"); const $playersLabel = $("<label>").attr("for", "numPlayers").text("Number of players:");
const $playersInput = $("<input>") const $playersInput = $("<input>")
.attr({ type: "number", id: "numPlayers", name: "numPlayers", min: 2 }) .attr({ type: "number", id: "numPlayers", name: "numPlayers", min: 1 })
.val(4); .val(4);
// Pairing type // Pairing type
@@ -259,6 +263,12 @@ var GempLotrHallUI = Class.extend({
.append($("<option>").val("SWISS").text("Swiss")) .append($("<option>").val("SWISS").text("Swiss"))
.append($("<option>").val("SINGLE_ELIMINATION").text("Single elimination")); .append($("<option>").val("SINGLE_ELIMINATION").text("Single elimination"));
// Deck-building duration
const $durationLabel = $("<label>").attr("for", "deckDuration").text("Deck-building duration (minutes, minimum 5):");
const $durationInput = $("<input>")
.attr({ type: "number", id: "deckDuration", name: "deckDuration", min: 5 })
.val(15);
// Competitive // Competitive
const $competitiveLabel = $("<label>").attr("for", "competitiveSelect").text("Competitive:"); const $competitiveLabel = $("<label>").attr("for", "competitiveSelect").text("Competitive:");
const $competitiveSelect = $("<select>") const $competitiveSelect = $("<select>")
@@ -266,11 +276,12 @@ var GempLotrHallUI = Class.extend({
.append($("<option>").val("false").text("Games can be spectated")) .append($("<option>").val("false").text("Games can be spectated"))
.append($("<option>").val("true").text("No spectate; hidden names in queue")); .append($("<option>").val("true").text("No spectate; hidden names in queue"));
// Deck-building duration // Early start
const $durationLabel = $("<label>").attr("for", "deckDuration").text("Deck-building duration (minutes, minimum 5):"); const $earlyStartLabel = $("<label>").attr("for", "startableEarlySelect").text("Early start:");
const $durationInput = $("<input>") const $earlyStartSelect = $("<select>")
.attr({ type: "number", id: "deckDuration", name: "deckDuration", min: 5 }) .attr({ id: "startableEarlySelect", name: "startableEarly" })
.val(15); .append($("<option>").val("true").text("Can be started with less players"))
.append($("<option>").val("false").text("Starts only with all player slots filled"));
// Append to form // Append to form
$fields.append( $fields.append(
@@ -305,7 +316,9 @@ var GempLotrHallUI = Class.extend({
$("<div>").append($durationLabel), $("<div>").append($durationLabel),
$("<div>").append($durationInput), $("<div>").append($durationInput),
$("<div>").append($competitiveLabel), $("<div>").append($competitiveLabel),
$("<div>").append($competitiveSelect) $("<div>").append($competitiveSelect),
$("<div>").append($earlyStartLabel),
$("<div>").append($earlyStartSelect)
); );
// Add validating listeners // Add validating listeners
@@ -313,6 +326,8 @@ var GempLotrHallUI = Class.extend({
$playersInput.on("input", validateTournamentForm); $playersInput.on("input", validateTournamentForm);
$pairingSelect.on("change", validateTournamentForm); $pairingSelect.on("change", validateTournamentForm);
$durationInput.on("input", validateTournamentForm); $durationInput.on("input", validateTournamentForm);
$competitiveSelect.on("change", validateTournamentForm);
$earlyStartSelect.on("change", validateTournamentForm);
if (gameType === "table_draft") { if (gameType === "table_draft") {
$timerSelect.on("change", validateTournamentForm); $timerSelect.on("change", validateTournamentForm);
} }
@@ -350,13 +365,12 @@ var GempLotrHallUI = Class.extend({
// Draft timer only applies to table draft // Draft timer only applies to table draft
const tableDraftTimer = type === "table_draft" ? $("#draftTimer").val() : null; const tableDraftTimer = type === "table_draft" ? $("#draftTimer").val() : null;
// Pairing
const playoff = $("#pairingType").val(); const playoff = $("#pairingType").val();
const competitive = $("#competitiveSelect").val(); const competitive = $("#competitiveSelect").val();
const startableEarly = $("#startableEarlySelect").val();
// Deck building duration (number input) // Number input
const deckbuildingDuration = parseInt($("#deckDuration").val(), 10) || 15; const deckbuildingDuration = parseInt($("#deckDuration").val(), 10) || 15;
const maxPlayers = parseInt($("#numPlayers").val(), 10) || 4; const maxPlayers = parseInt($("#numPlayers").val(), 10) || 4;
@@ -371,6 +385,7 @@ var GempLotrHallUI = Class.extend({
playoff, playoff,
deckbuildingDuration, deckbuildingDuration,
competitive, competitive,
startableEarly,
function(json) { function(json) {
// Success callback — handle your response here // Success callback — handle your response here
console.log("Tournament created successfully:", json); console.log("Tournament created successfully:", json);