diff --git a/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/AdminRequestHandler.java b/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/AdminRequestHandler.java index 666d403be..e6b687d53 100644 --- a/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/AdminRequestHandler.java +++ b/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/AdminRequestHandler.java @@ -11,6 +11,8 @@ import com.gempukku.lotro.db.PlayerDAO; import com.gempukku.lotro.db.vo.CollectionType; import com.gempukku.lotro.db.vo.League; import com.gempukku.lotro.draft2.SoloDraftDefinitions; +import com.gempukku.lotro.draft3.DraftTimerProducer; +import com.gempukku.lotro.draft3.TableDraftDefinitions; import com.gempukku.lotro.game.CardCollection; import com.gempukku.lotro.game.LotroCardBlueprintLibrary; import com.gempukku.lotro.game.Player; @@ -58,6 +60,7 @@ public class AdminRequestHandler extends LotroServerRequestHandler implements Ur private final PlayerDAO _playerDAO; private final AdminService _adminService; private final ChatServer _chatServer; + private final TableDraftDefinitions _tableDraftLibrary; private static final Logger _log = LogManager.getLogger(AdminRequestHandler.class); @@ -76,6 +79,7 @@ public class AdminRequestHandler extends LotroServerRequestHandler implements Ur _cardLibrary = extractObject(context, LotroCardBlueprintLibrary.class); _productLibrary = extractObject(context, ProductLibrary.class); _chatServer = extractObject(context, ChatServer.class); + _tableDraftLibrary = extractObject(context, TableDraftDefinitions.class); } @Override @@ -921,6 +925,15 @@ public class AdminRequestHandler extends LotroServerRequestHandler implements Ur String soloDraftTurnInDurationStr = getFormParameterSafely(postDecoder, "soloDraftTurnInDuration"); String soloDraftFormatCodeStr = getFormParameterSafely(postDecoder, "soloDraftFormatCode"); + String soloTableDraftDeckbuildingDurationStr = getFormParameterSafely(postDecoder, "soloTableDraftDeckbuildingDuration"); + String soloTableDraftTurnInDurationStr = getFormParameterSafely(postDecoder, "soloTableDraftTurnInDuration"); + String soloTableDraftFormatCodeStr = getFormParameterSafely(postDecoder, "soloTableDraftFormatCode"); + + String tableDraftDeckbuildingDurationStr = getFormParameterSafely(postDecoder, "tableDraftDeckbuildingDuration"); + String tableDraftTurnInDurationStr = getFormParameterSafely(postDecoder, "tableDraftTurnInDuration"); + String tableDraftFormatCodeStr = getFormParameterSafely(postDecoder, "tableDraftFormatCode"); + String tableDraftTimer = getFormParameterSafely(postDecoder, "tableDraftTimer"); + String wcStr = getFormParameterSafely(postDecoder, "wc"); String tournamentId = getFormParameterSafely(postDecoder, "tournamentId"); String formatStr = getFormParameterSafely(postDecoder, "formatCode"); @@ -1004,6 +1017,38 @@ public class AdminRequestHandler extends LotroServerRequestHandler implements Ur soloDraftParams.requiresDeck = false; params = soloDraftParams; } + else if (type == Tournament.TournamentType.TABLE_SOLODRAFT) { + var soloTableDraftParams = new SoloTableDraftTournamentParams(); + soloTableDraftParams.type = Tournament.TournamentType.TABLE_SOLODRAFT; + + soloTableDraftParams.deckbuildingDuration = Throw400IfNullOrNonInteger("soloTableDraftDeckbuildingDuration", soloTableDraftDeckbuildingDurationStr); + soloTableDraftParams.turnInDuration = Throw400IfNullOrNonInteger("soloTableDraftTurnInDuration", soloTableDraftTurnInDurationStr); + + Throw400IfStringNull("soloTableDraftFormatCode", soloTableDraftFormatCodeStr); + var tableDraftDefinition = _tableDraftLibrary.getTableDraftDefinition(soloTableDraftFormatCodeStr); + Throw400IfValidationFails("soloTableDraftFormatCode", soloTableDraftFormatCodeStr,tableDraftDefinition != null); + soloTableDraftParams.soloTableDraftFormatCode = soloTableDraftFormatCodeStr; + soloTableDraftParams.format = tableDraftDefinition.getFormat(); + soloTableDraftParams.requiresDeck = false; + params = soloTableDraftParams; + } + else if (type == Tournament.TournamentType.TABLE_DRAFT) { + var tableDraftParams = new TableDraftTournamentParams(); + tableDraftParams.type = Tournament.TournamentType.TABLE_DRAFT; + + tableDraftParams.deckbuildingDuration = Throw400IfNullOrNonInteger("tableDraftDeckbuildingDuration", tableDraftDeckbuildingDurationStr); + tableDraftParams.turnInDuration = Throw400IfNullOrNonInteger("tableDraftTurnInDuration", tableDraftTurnInDurationStr); + + Throw400IfStringNull("tableDraftFormatCode", tableDraftFormatCodeStr); + var tableDraftDefinition = _tableDraftLibrary.getTableDraftDefinition(tableDraftFormatCodeStr); + Throw400IfValidationFails("tableDraftFormatCode", tableDraftFormatCodeStr,tableDraftDefinition != null); + tableDraftParams.tableDraftFormatCode = tableDraftFormatCodeStr; + tableDraftParams.format = tableDraftDefinition.getFormat(); + tableDraftParams.requiresDeck = false; + tableDraftParams.draftTimerProducerType = DraftTimerProducer.getDraftTimerProducer(tableDraftTimer); + tableDraftParams.maximumPlayers = tableDraftDefinition.getMaxPlayers(); + params = tableDraftParams; + } else { params.type = Tournament.TournamentType.CONSTRUCTED; var format = _formatLibrary.getFormat(formatStr); @@ -1027,6 +1072,15 @@ public class AdminRequestHandler extends LotroServerRequestHandler implements Ur if(type == Tournament.TournamentType.SEALED) { info = new SealedTournamentInfo(_tournamentService, _productLibrary, _formatLibrary, start, (SealedTournamentParams)params); } + else if (type == Tournament.TournamentType.SOLODRAFT) { + info = new SoloDraftTournamentInfo(_tournamentService, _productLibrary, _formatLibrary, start, ((SoloDraftTournamentParams) params), _soloDraftDefinitions); + } + else if (type == Tournament.TournamentType.TABLE_SOLODRAFT) { + info = new SoloTableDraftTournamentInfo(_tournamentService, _productLibrary, _formatLibrary, start, ((SoloTableDraftTournamentParams) params), _tableDraftLibrary); + } + else if (type == Tournament.TournamentType.TABLE_DRAFT) { + info = new TableDraftTournamentInfo(_tournamentService, _productLibrary, _formatLibrary, start, ((TableDraftTournamentParams) params), _tableDraftLibrary); + } else { info = new TournamentInfo(_tournamentService, _productLibrary, _formatLibrary, start, params); } diff --git a/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/DeckRequestHandler.java b/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/DeckRequestHandler.java index 0f7f3a796..1e7bcfc11 100644 --- a/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/DeckRequestHandler.java +++ b/gemp-lotr/gemp-lotr-async/src/main/java/com/gempukku/lotro/async/handler/DeckRequestHandler.java @@ -8,6 +8,8 @@ import com.gempukku.lotro.common.Side; import com.gempukku.lotro.db.DeckDAO; import com.gempukku.lotro.db.DeckSerialization; import com.gempukku.lotro.draft2.SoloDraftDefinitions; +import com.gempukku.lotro.draft3.DraftTimerProducer; +import com.gempukku.lotro.draft3.TableDraftDefinitions; import com.gempukku.lotro.game.*; import com.gempukku.lotro.game.formats.LotroFormatLibrary; import com.gempukku.lotro.league.SealedEventDefinition; @@ -41,6 +43,7 @@ public class DeckRequestHandler extends LotroServerRequestHandler implements Uri private final SoloDraftDefinitions _draftLibrary; private final LotroServer _lotroServer; private final MarkdownParser _markdownParser; + private final TableDraftDefinitions _tableDraftDefinitions; private static final Logger _log = LogManager.getLogger(DeckRequestHandler.class); @@ -53,6 +56,7 @@ public class DeckRequestHandler extends LotroServerRequestHandler implements Uri _lotroServer = extractObject(context, LotroServer.class); _draftLibrary = extractObject(context, SoloDraftDefinitions.class); _markdownParser = extractObject(context, MarkdownParser.class); + _tableDraftDefinitions = extractObject(context, TableDraftDefinitions.class); } @Override @@ -110,6 +114,10 @@ public class DeckRequestHandler extends LotroServerRequestHandler implements Uri data.DraftTemplates = _draftLibrary.getAllSoloDrafts().values().stream() .map(soloDraft -> new JSONDefs.ItemStub(soloDraft.getCode(), soloDraft.getFormat())) .collect(Collectors.toMap(x-> x.code, x-> x)); + data.TableDraftTemplates = _tableDraftDefinitions.getAllTableDrafts().values().stream() + .map(tableDraftDefinition -> new JSONDefs.ItemStub(tableDraftDefinition.getFormat(), tableDraftDefinition.getCode())) + .collect(Collectors.toMap(itemStub -> itemStub.name, itemStub -> itemStub)); + data.TableDraftTimerTypes = DraftTimerProducer.getAllTypes(); json = JsonUtils.Serialize(data); } diff --git a/gemp-lotr/gemp-lotr-async/src/main/web/includes/admin/tournamentAdmin.html b/gemp-lotr/gemp-lotr-async/src/main/web/includes/admin/tournamentAdmin.html index 0dff1614d..c5a0cfd0e 100644 --- a/gemp-lotr/gemp-lotr-async/src/main/web/includes/admin/tournamentAdmin.html +++ b/gemp-lotr/gemp-lotr-async/src/main/web/includes/admin/tournamentAdmin.html @@ -156,22 +156,44 @@ $(document).ready( $('.sealed-only').show(); $('.constructed-only').hide(); $('.solodraft-only').hide(); + $('.solo-table-draft-only').hide(); + $('.table-draft-only').hide(); } else if(type === "SOLODRAFT") { $('.sealed-only').hide(); $('.constructed-only').hide(); $('.solodraft-only').show(); + $('.solo-table-draft-only').hide(); + $('.table-draft-only').hide(); + } + else if(type === "TABLE_SOLODRAFT") { + $('.sealed-only').hide(); + $('.constructed-only').hide(); + $('.solodraft-only').hide(); + $('.solo-table-draft-only').show(); + $('.table-draft-only').hide(); + } + else if(type === "TABLE_DRAFT") { + $('.sealed-only').hide(); + $('.constructed-only').hide(); + $('.solodraft-only').hide(); + $('.solo-table-draft-only').hide(); + $('.table-draft-only').show(); } else { $('.sealed-only').hide(); $('.constructed-only').show(); $('.solodraft-only').hide(); + $('.solo-table-draft-only').hide(); + $('.table-draft-only').hide(); } }); $('.sealed-only').hide(); $('.solodraft-only').hide(); $('.constructed-only').show(); + $('.solo-table-draft-only').hide(); + $('.table-draft-only').hide(); hall.comm.getFormats(true, @@ -180,7 +202,9 @@ $(document).ready( //console.log(json); let drafts = json.DraftTemplates; let formats = json.Formats; - let sealed = json.SealedTemplates + let sealed = json.SealedTemplates; + let tableDrafts = json.TableDraftTemplates; + let tableDraftTimers = json.TableDraftTimerTypes; for (var prop in formats) { if (Object.prototype.hasOwnProperty.call(formats, prop)) { @@ -247,6 +271,34 @@ $(document).ready( $("#sch-tourney-solodraft-format").append(item); } } + + for (var prop in tableDrafts) { + if (Object.prototype.hasOwnProperty.call(tableDrafts, prop)) { + //console.log(prop); + + let code = tableDrafts[prop].format; + let id = tableDrafts[prop].id; + + var item = $("") + .attr("value", id) + .text(prop); + $("#sch-tourney-solo-table-draft-format").append(item); + var item2 = $("") + .attr("value", id) + .text(prop); + $("#sch-tourney-table-draft-format").append(item2); + } + } + + for (var prop in tableDraftTimers) { + if (Object.prototype.hasOwnProperty.call(tableDraftTimers, prop)) { + //console.log(prop); + var item = $("") + .attr("value", tableDraftTimers[prop]) + .text(tableDraftTimers[prop]); + $("#sch-tourney-table-draft-timer").append(item); + } + } }, tourneyErrorMap()); }); @@ -275,6 +327,15 @@ function processScheduledTournament(preview, resultdiv, callback) { $("#sch-tourney-solodraft-format").val(), $("#sch-tourney-solodraft-deckbuild").val(), $("#sch-tourney-solodraft-registration").val(), + + $("#sch-tourney-solo-table-draft-format").val(), + $("#sch-tourney-solo-table-draft-deckbuild").val(), + $("#sch-tourney-solo-table-draft-registration").val(), + + $("#sch-tourney-table-draft-format").val(), + $("#sch-tourney-table-draft-timer").val(), + $("#sch-tourney-table-draft-deckbuild").val(), + $("#sch-tourney-table-draft-registration").val(), $("#sch-tourney-start").val(), $("#sch-tourney-cost").val(), @@ -414,7 +475,8 @@ function tourneyErrorMap(outputControl, callback=null) { - + + @@ -452,6 +514,41 @@ function tourneyErrorMap(outputControl, callback=null) {