Added - queue configurator ready check option

This commit is contained in:
jakub.salavec
2025-06-13 15:26:10 +02:00
parent 3a6722b104
commit 71f6b33503
4 changed files with 48 additions and 10 deletions

View File

@@ -141,6 +141,9 @@ public class TournamentRequestHandler extends LotroServerRequestHandler implemen
String startableStr = getFormParameterSafely(postDecoder, "startable");
boolean startable = Throw400IfNullOrNonBoolean("startable", startableStr);
String readyCheckStr = getFormParameterSafely(postDecoder, "readyCheck");
int readyCheck = Throw400IfNullOrNonInteger("readyCheck", readyCheckStr);
String sealedFormatCodeStr = getFormParameterSafely(postDecoder, "sealedFormatCode");
String soloDraftFormatCodeStr = getFormParameterSafely(postDecoder, "soloDraftFormatCode");
@@ -161,13 +164,10 @@ public class TournamentRequestHandler extends LotroServerRequestHandler implemen
var params = new TournamentParams();
String casualPrefix = "Casual ";
String competitivePrefix = "Competitive ";
String prefix = competitive ? competitivePrefix : casualPrefix;
//TODO ready check, ready check time
if(type == Tournament.TournamentType.SEALED) {
var sealedParams = new SealedTournamentParams();
sealedParams.type = Tournament.TournamentType.SEALED;
@@ -266,7 +266,7 @@ public class TournamentRequestHandler extends LotroServerRequestHandler implemen
return;
}
if (_hallServer.addPlayerMadeLimitedQueue(info, resourceOwner, startable, -1)) {
if (_hallServer.addPlayerMadeLimitedQueue(info, resourceOwner, startable, readyCheck)) {
responseWriter.sendJsonOK();
} else {
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,
playoff, deckbuildingDuration, competitive, startable, callback, errorMap) {
playoff, deckbuildingDuration, competitive, startable, readyCheck, callback, errorMap) {
$.ajax({
type:"POST",
url:this.url + "/tournament/create",
@@ -1461,6 +1461,7 @@ var GempLotrCommunication = Class.extend({
deckbuildingDuration:deckbuildingDuration,
competitive:competitive,
startable:startable,
readyCheck:readyCheck,
participantId:getUrlParam("participantId")
},
success:this.deliveryCheck(callback),

View File

@@ -187,10 +187,12 @@ var GempLotrHallUI = Class.extend({
const draftTimer = $("#draftTimer").val();
const competitive = $("#competitiveSelect").val();
const startableEarly = $("#startableEarlySelect").val();
const readyCheck = $("#readyCheckSelect").val();
const validPlayerCount = Number.isInteger(playerCount) && playerCount >= 1;
const validDeckDuration = Number.isInteger(deckDuration) && deckDuration >= 5;
const draftValid = gameType !== "table_draft" || draftTimer;
const validPlayerReadyCombo = playerCount > 2 || readyCheck < 0;
const allValid =
gameType &&
@@ -200,6 +202,8 @@ var GempLotrHallUI = Class.extend({
validDeckDuration &&
competitive &&
startableEarly &&
readyCheck &&
validPlayerReadyCombo &&
draftValid;
$("#createTournamentButton").prop("disabled", !allValid);
@@ -283,6 +287,16 @@ var GempLotrHallUI = Class.extend({
.append($("<option>").val("true").text("Can be started with less players"))
.append($("<option>").val("false").text("Starts only with all player slots filled"));
// Ready check
const $readyCheckLabel = $("<label>").attr("for", "readyCheckSelect").text("Ready check:");
const $readyCheckSelect = $("<select>")
.attr({ id: "readyCheckSelect", name: "readyCheck" })
.append($("<option>").val("-1").text("No ready check, just start the tournament"))
.append($("<option>").val("90").text("90 seconds to confirm"))
.append($("<option>").val("180").text("3 minutes to confirm"));
// Set default to 90 seconds as we start with 4 players
$readyCheckSelect.val("90");
// Append to form
$fields.append(
$("<div>").append($label),
@@ -318,20 +332,44 @@ var GempLotrHallUI = Class.extend({
$("<div>").append($competitiveLabel),
$("<div>").append($competitiveSelect),
$("<div>").append($earlyStartLabel),
$("<div>").append($earlyStartSelect)
$("<div>").append($earlyStartSelect),
$("<div>").append($readyCheckLabel),
$("<div>").append($readyCheckSelect)
);
// Add validating listeners
$select.on("change", validateTournamentForm);
$playersInput.on("input", validateTournamentForm);
$pairingSelect.on("change", validateTournamentForm);
$durationInput.on("input", validateTournamentForm);
$competitiveSelect.on("change", validateTournamentForm);
$earlyStartSelect.on("change", validateTournamentForm);
$readyCheckSelect.on("change", validateTournamentForm);
if (gameType === "table_draft") {
$timerSelect.on("change", validateTournamentForm);
}
// Add listener for ready check / player count combo
$playersInput.on("input", function () {
const playerCount = parseInt($(this).val(), 10);
const $readyCheck = $("#readyCheckSelect");
if (playerCount <= 2) {
// Set to -1 (no ready check) and disable other options
$readyCheck.val("-1");
$readyCheck.find("option").each(function () {
if ($(this).val() !== "-1") {
$(this).prop("disabled", true);
}
});
} else {
// Enable all options and select 90 seconds
$readyCheck.find("option").prop("disabled", false);
$readyCheck.val("90");
}
validateTournamentForm();
});
// Submit button
$('#createTournamentButton').show();
$('#createTournamentButton').off('click').on('click', () => {
@@ -368,6 +406,7 @@ var GempLotrHallUI = Class.extend({
const playoff = $("#pairingType").val();
const competitive = $("#competitiveSelect").val();
const startableEarly = $("#startableEarlySelect").val();
const readyCheck = $("#readyCheckSelect").val();
// Number input
@@ -386,6 +425,7 @@ var GempLotrHallUI = Class.extend({
deckbuildingDuration,
competitive,
startableEarly,
readyCheck,
function(json) {
// Success callback — handle your response here
console.log("Tournament created successfully:", json);

View File

@@ -9,9 +9,6 @@ public class PlayerMadeLimitedQueue extends AbstractTournamentQueue implements T
public PlayerMadeLimitedQueue(TournamentService tournamentService, String queueId, String queueName, TournamentInfo info, boolean startableEarly, int readyCheckTimeSecs,
TournamentQueueCallback tournamentQueueCallback, CollectionsManager collectionsManager) {
super(tournamentService, queueId, queueName, info, startableEarly, readyCheckTimeSecs, tournamentQueueCallback, collectionsManager, true);
System.out.println("PLAYER MADE QUEUE");
System.out.println(queueId);
System.out.println(queueName);
}
@Override