Added - draft json files may contain timer preference (to allow hobbit draft to be slower)
This commit is contained in:
@@ -12,7 +12,7 @@ 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.TableDraftDefinitions;
|
||||
import com.gempukku.lotro.draft3.timer.DraftTimerFactory;
|
||||
import com.gempukku.lotro.draft3.timer.DraftTimer;
|
||||
import com.gempukku.lotro.game.CardCollection;
|
||||
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
|
||||
import com.gempukku.lotro.game.Player;
|
||||
@@ -1049,7 +1049,7 @@ public class AdminRequestHandler extends LotroServerRequestHandler implements Ur
|
||||
tableDraftParams.tableDraftFormatCode = tableDraftFormatCodeStr;
|
||||
tableDraftParams.format = tableDraftDefinition.getFormat();
|
||||
tableDraftParams.requiresDeck = false;
|
||||
tableDraftParams.draftTimerType = DraftTimerFactory.getTypeFromString(tableDraftTimer);
|
||||
tableDraftParams.draftTimerType = DraftTimer.getTypeFromString(tableDraftTimer);
|
||||
tableDraftParams.maximumPlayers = tableDraftDefinition.getMaxPlayers();
|
||||
params = tableDraftParams;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.gempukku.lotro.db.DeckDAO;
|
||||
import com.gempukku.lotro.db.DeckSerialization;
|
||||
import com.gempukku.lotro.draft2.SoloDraftDefinitions;
|
||||
import com.gempukku.lotro.draft3.TableDraftDefinitions;
|
||||
import com.gempukku.lotro.draft3.timer.DraftTimerFactory;
|
||||
import com.gempukku.lotro.draft3.timer.DraftTimer;
|
||||
import com.gempukku.lotro.game.*;
|
||||
import com.gempukku.lotro.game.formats.LotroFormatLibrary;
|
||||
import com.gempukku.lotro.league.SealedEventDefinition;
|
||||
@@ -120,7 +120,7 @@ public class DeckRequestHandler extends LotroServerRequestHandler implements Uri
|
||||
data.TableDraftTemplates = _tableDraftDefinitions.getAllTableDrafts().stream()
|
||||
.map(tableDraftDefinition -> new JSONDefs.ItemStub(tableDraftDefinition.getCode(), tableDraftDefinition.getName()))
|
||||
.collect(Collectors.toMap(itemStub -> itemStub.name, itemStub -> itemStub));
|
||||
data.TableDraftTimerTypes = DraftTimerFactory.getAllTypes();
|
||||
data.TableDraftTimerTypes = DraftTimer.getAllTypes();
|
||||
|
||||
json = JsonUtils.Serialize(data);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"code": "hobbit_table_draft",
|
||||
"format": "limited_hobbit",
|
||||
"max-players": 4,
|
||||
"timer": "SLOW",
|
||||
"starting-collection": [
|
||||
{
|
||||
"size": 68,
|
||||
|
||||
@@ -11,4 +11,6 @@ public interface TableDraftDefinition {
|
||||
String getName();
|
||||
String getCode();
|
||||
String getFormat();
|
||||
|
||||
DraftTimer.Type getRecommendedTimer();
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ public class TableDraftDefinitionBuilder {
|
||||
String name = (String) definition.get("name");
|
||||
String code = (String) definition.get("code");
|
||||
String format = (String) definition.get("format");
|
||||
String timer = (String) definition.get("timer");
|
||||
|
||||
int maxPlayers = ((Number) definition.get("max-players")).intValue();
|
||||
|
||||
@@ -79,6 +80,15 @@ public class TableDraftDefinitionBuilder {
|
||||
public String getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DraftTimer.Type getRecommendedTimer() {
|
||||
if (timer == null) {
|
||||
return DraftTimer.Type.CLASSIC;
|
||||
} else {
|
||||
return DraftTimer.getTypeFromString(timer);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,56 @@
|
||||
package com.gempukku.lotro.draft3.timer;
|
||||
|
||||
public interface DraftTimer {
|
||||
int getSecondsAllotted(int cardsInPack);
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DraftTimer {
|
||||
private static final int CLASSIC_SECS_PER_CARD = 6;
|
||||
private static final int SLOW_SECS_PER_CARD = 10;
|
||||
|
||||
public enum Type {
|
||||
CLASSIC, SLOW, NO_TIMER
|
||||
}
|
||||
|
||||
private final int secsPerCard;
|
||||
|
||||
public static DraftTimer get(DraftTimer.Type type) {
|
||||
if (type == DraftTimer.Type.CLASSIC) {
|
||||
return new DraftTimer(CLASSIC_SECS_PER_CARD);
|
||||
} else if (type == DraftTimer.Type.SLOW) {
|
||||
return new DraftTimer(SLOW_SECS_PER_CARD);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private DraftTimer(int secsPerCard) {
|
||||
this.secsPerCard = secsPerCard;
|
||||
}
|
||||
|
||||
public int getSecondsAllotted(int cardsInPack) {
|
||||
int tbr = secsPerCard * (cardsInPack - 1);
|
||||
if (tbr <= 0) {
|
||||
return secsPerCard;
|
||||
} else {
|
||||
return tbr;
|
||||
}
|
||||
}
|
||||
|
||||
public static DraftTimer.Type getTypeFromString(String type) {
|
||||
try {
|
||||
return DraftTimer.Type.valueOf(type);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
return DraftTimer.Type.NO_TIMER;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getAllTypes() {
|
||||
List<String> tbr = new ArrayList<>();
|
||||
for (DraftTimer.Type value : DraftTimer.Type.values()) {
|
||||
tbr.add(value.name());
|
||||
}
|
||||
return tbr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.gempukku.lotro.draft3.timer;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class DraftTimerClassic implements DraftTimer{
|
||||
private Map<Integer, Integer> durations = new HashMap<>();
|
||||
private static final int SECS_PER_CARD = 6;
|
||||
|
||||
public DraftTimerClassic() {
|
||||
durations.put(1, 5);
|
||||
for (int i = 2; i <= 20; i++) {
|
||||
durations.put(i, (i - 1) * SECS_PER_CARD);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSecondsAllotted(int cardsInPack) {
|
||||
// Unknown duration
|
||||
if (!durations.containsKey(cardsInPack)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Look to map for info
|
||||
return durations.get(cardsInPack);
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.gempukku.lotro.draft3.timer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DraftTimerFactory {
|
||||
private DraftTimerFactory() {
|
||||
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
CLASSIC, FAST, NO_TIMER
|
||||
}
|
||||
|
||||
public static DraftTimer getDraftTimer(Type type) {
|
||||
if (type == Type.FAST) {
|
||||
return new DraftTimerFast();
|
||||
} else if (type == Type.CLASSIC) {
|
||||
return new DraftTimerClassic();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Type getTypeFromString(String type) {
|
||||
try {
|
||||
return Type.valueOf(type);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
return Type.NO_TIMER;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getAllTypes() {
|
||||
List<String> tbr = new ArrayList<>();
|
||||
for (Type value : Type.values()) {
|
||||
tbr.add(value.name());
|
||||
}
|
||||
return tbr;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.gempukku.lotro.draft3.timer;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class DraftTimerFast implements DraftTimer{
|
||||
private Map<Integer, Integer> durations = new HashMap<>();
|
||||
|
||||
public DraftTimerFast() {
|
||||
// MtG timer from Tournament Guides until 15 cards, then extended to 20
|
||||
durations.put(1, 5);
|
||||
durations.put(2, 5);
|
||||
durations.put(3, 5);
|
||||
durations.put(4, 5);
|
||||
durations.put(5, 10);
|
||||
durations.put(6, 10);
|
||||
durations.put(7, 15);
|
||||
durations.put(8, 20);
|
||||
durations.put(9, 20);
|
||||
durations.put(10, 25);
|
||||
durations.put(11, 25);
|
||||
durations.put(12, 30);
|
||||
durations.put(13, 35);
|
||||
durations.put(14, 40);
|
||||
durations.put(15, 40);
|
||||
durations.put(16, 45);
|
||||
durations.put(17, 45);
|
||||
durations.put(18, 50);
|
||||
durations.put(19, 50);
|
||||
durations.put(20, 55);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSecondsAllotted(int cardsInPack) {
|
||||
// Unknown duration
|
||||
if (!durations.containsKey(cardsInPack)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Look to map for info
|
||||
return durations.get(cardsInPack);
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import com.gempukku.lotro.draft.Draft;
|
||||
import com.gempukku.lotro.draft2.SoloDraftDefinitions;
|
||||
import com.gempukku.lotro.draft3.TableDraft;
|
||||
import com.gempukku.lotro.draft3.TableDraftDefinitions;
|
||||
import com.gempukku.lotro.draft3.timer.DraftTimerFactory;
|
||||
import com.gempukku.lotro.draft3.timer.DraftTimer;
|
||||
import com.gempukku.lotro.game.formats.LotroFormatLibrary;
|
||||
import com.gempukku.lotro.hall.TableHolder;
|
||||
import com.gempukku.lotro.logic.vo.LotroDeck;
|
||||
@@ -131,7 +131,7 @@ public class TableDraftTournament extends BaseTournament implements Tournament {
|
||||
private void createTable() {
|
||||
// Create one table for all players and start
|
||||
if (table == null) {
|
||||
table = _tableDraftLibrary.getTableDraftDefinition(tableDraftInfo.tableDraftParams.tableDraftFormatCode).getTableDraft(_collectionsManager, getCollectionType(), DraftTimerFactory.getDraftTimer(tableDraftInfo.tableDraftParams.draftTimerType));
|
||||
table = _tableDraftLibrary.getTableDraftDefinition(tableDraftInfo.tableDraftParams.tableDraftFormatCode).getTableDraft(_collectionsManager, getCollectionType(), DraftTimer.get(tableDraftInfo.tableDraftParams.draftTimerType));
|
||||
for (String playerName : _players) {
|
||||
table.registerPlayer(playerName);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.gempukku.lotro.tournament;
|
||||
|
||||
import com.gempukku.lotro.draft3.timer.DraftTimerFactory;
|
||||
import com.gempukku.lotro.draft3.timer.DraftTimer;
|
||||
|
||||
public class TableDraftTournamentParams extends TournamentParams {
|
||||
public DraftTimerFactory.Type draftTimerType;
|
||||
public DraftTimer.Type draftTimerType;
|
||||
public int deckbuildingDuration;
|
||||
public int turnInDuration;
|
||||
public String tableDraftFormatCode;
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.gempukku.lotro.db.vo.CollectionType;
|
||||
import com.gempukku.lotro.draft2.SoloDraftDefinitions;
|
||||
import com.gempukku.lotro.draft3.TableDraftDefinition;
|
||||
import com.gempukku.lotro.draft3.TableDraftDefinitions;
|
||||
import com.gempukku.lotro.draft3.timer.DraftTimerFactory;
|
||||
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
|
||||
import com.gempukku.lotro.game.Player;
|
||||
import com.gempukku.lotro.game.formats.LotroFormatLibrary;
|
||||
@@ -139,7 +138,7 @@ public class TournamentService {
|
||||
);
|
||||
}
|
||||
|
||||
private void addImmediateRecurringTableDraft(String queueId, String queueName, String prefix, String formatCode, int players, DraftTimerFactory.Type draftTimer) {
|
||||
private void addImmediateRecurringTableDraft(String queueId, String queueName, String prefix, String formatCode, int players) {
|
||||
TournamentQueueCallback callback = tournament -> _activeTournaments.put(tournament.getTournamentId(), tournament);
|
||||
|
||||
TableDraftTournamentParams draftParams = new TableDraftTournamentParams();
|
||||
@@ -147,11 +146,11 @@ public class TournamentService {
|
||||
|
||||
draftParams.deckbuildingDuration = 15;
|
||||
draftParams.turnInDuration = 2;
|
||||
draftParams.draftTimerType = draftTimer;
|
||||
|
||||
TableDraftDefinition tableDraft = _tableDraftLibrary.getTableDraftDefinition(formatCode);
|
||||
draftParams.tableDraftFormatCode = formatCode;
|
||||
draftParams.format = tableDraft.getFormat();
|
||||
draftParams.draftTimerType = tableDraft.getRecommendedTimer();
|
||||
draftParams.requiresDeck = false;
|
||||
|
||||
draftParams.tournamentId = prefix;
|
||||
@@ -216,7 +215,7 @@ public class TournamentService {
|
||||
|
||||
_tableDraftLibrary.getAllTableDrafts().forEach(tableDraftDefinition -> {
|
||||
String code = tableDraftDefinition.getCode();
|
||||
addImmediateRecurringTableDraft(code + "_queue", casual + tableDraftDefinition.getName(), code + "-", code, tableDraftDefinition.getMaxPlayers(), DraftTimerFactory.Type.CLASSIC);
|
||||
addImmediateRecurringTableDraft(code + "_queue", casual + tableDraftDefinition.getName(), code + "-", code, tableDraftDefinition.getMaxPlayers());
|
||||
});
|
||||
|
||||
addImmediateRecurringDraft("fotr_solo_draft_queue", casual + "FotR Solo Draft", "fotrSoloDraft-", "fotr_draft");
|
||||
|
||||
Reference in New Issue
Block a user