|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package eu.jonahbauer.wizard.core.model;
|
|
|
|
|
|
|
|
|
|
import eu.jonahbauer.wizard.common.model.Configuration;
|
|
|
|
|
import eu.jonahbauer.wizard.core.model.deck.Decks;
|
|
|
|
|
import lombok.experimental.UtilityClass;
|
|
|
|
|
import org.jetbrains.annotations.Contract;
|
|
|
|
@ -12,55 +13,55 @@ import java.util.NoSuchElementException;
|
|
|
|
|
|
|
|
|
|
@UtilityClass
|
|
|
|
|
public class Configurations {
|
|
|
|
|
private static final Map<String, Configuration> CONFIGURATIONS = new HashMap<>();
|
|
|
|
|
private static final Map<Configuration, GameConfiguration> CONFIGURATIONS = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
public static final Configuration DEFAULT = register("DEFAULT", new Configuration(
|
|
|
|
|
public static final GameConfiguration DEFAULT = register(Configuration.DEFAULT, new GameConfiguration(
|
|
|
|
|
Decks.DEFAULT,
|
|
|
|
|
true,
|
|
|
|
|
10 * 60 * 1000
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
public static final Configuration DEFAULT_PM1 = register("DEFAULT_PM1", new Configuration(
|
|
|
|
|
public static final GameConfiguration DEFAULT_PM1 = register(Configuration.DEFAULT_PM1, new GameConfiguration(
|
|
|
|
|
Decks.DEFAULT,
|
|
|
|
|
false,
|
|
|
|
|
10 * 60 * 1000
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
public static final Configuration ANNIVERSARY_2016 = register("ANNIVERSARY_2016", new Configuration(
|
|
|
|
|
public static final GameConfiguration ANNIVERSARY_2016 = register(Configuration.ANNIVERSARY_2016, new GameConfiguration(
|
|
|
|
|
Decks.ANNIVERSARY_2016,
|
|
|
|
|
true,
|
|
|
|
|
10 * 60 * 1000
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
public static final Configuration ANNIVERSARY_2016_PM1 = register("ANNIVERSARY_2016_PM1", new Configuration(
|
|
|
|
|
public static final GameConfiguration ANNIVERSARY_2016_PM1 = register(Configuration.ANNIVERSARY_2016_PM1, new GameConfiguration(
|
|
|
|
|
Decks.ANNIVERSARY_2016,
|
|
|
|
|
false,
|
|
|
|
|
10 * 60 * 1000
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
public static final Configuration ANNIVERSARY_2021 = register("ANNIVERSARY_2021", new Configuration(
|
|
|
|
|
public static final GameConfiguration ANNIVERSARY_2021 = register(Configuration.ANNIVERSARY_2021, new GameConfiguration(
|
|
|
|
|
Decks.ANNIVERSARY_2021,
|
|
|
|
|
true,
|
|
|
|
|
10 * 60 * 1000
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
public static final Configuration ANNIVERSARY_2021_PM1 = register("ANNIVERSARY_2021_PM1", new Configuration(
|
|
|
|
|
public static final GameConfiguration ANNIVERSARY_2021_PM1 = register(Configuration.ANNIVERSARY_2021_PM1, new GameConfiguration(
|
|
|
|
|
Decks.ANNIVERSARY_2021,
|
|
|
|
|
false,
|
|
|
|
|
10 * 60 * 1000
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
@Contract("_,_ -> param2")
|
|
|
|
|
private static Configuration register(@NotNull String name, @NotNull Configuration configuration) {
|
|
|
|
|
if (CONFIGURATIONS.putIfAbsent(name.toUpperCase(Locale.ROOT), configuration) != null) {
|
|
|
|
|
private static GameConfiguration register(@NotNull Configuration name, @NotNull GameConfiguration configuration) {
|
|
|
|
|
if (CONFIGURATIONS.putIfAbsent(name, configuration) != null) {
|
|
|
|
|
throw new IllegalArgumentException("Name already taken.");
|
|
|
|
|
}
|
|
|
|
|
return configuration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@NotNull
|
|
|
|
|
public static Configuration get(@NotNull String name) {
|
|
|
|
|
var out = CONFIGURATIONS.get(name.toUpperCase(Locale.ROOT));
|
|
|
|
|
public static GameConfiguration get(@NotNull Configuration name) {
|
|
|
|
|
var out = CONFIGURATIONS.get(name);
|
|
|
|
|
if (out == null) throw new NoSuchElementException("Configuration with name '" + name + "' does not exist.");
|
|
|
|
|
return out;
|
|
|
|
|
}
|
|
|
|
|