From 44de95bbf6fcf30bc3efbde464e233717ea9ea62 Mon Sep 17 00:00:00 2001 From: Daniel Norris Date: Sun, 6 Nov 2022 10:27:57 +0000 Subject: [PATCH] feat(forge16): add weighted random command selection --- .../tower/config/BattleTowerConfig.java | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/forge16/src/main/java/com/envyful/battle/tower/config/BattleTowerConfig.java b/forge16/src/main/java/com/envyful/battle/tower/config/BattleTowerConfig.java index 41f1420..e7e932e 100644 --- a/forge16/src/main/java/com/envyful/battle/tower/config/BattleTowerConfig.java +++ b/forge16/src/main/java/com/envyful/battle/tower/config/BattleTowerConfig.java @@ -135,8 +135,7 @@ public static class TeamPossibilities { private int startFloor = 0; private int endFloor = 1000; private ConfigRandomWeightedSet teams = new ConfigRandomWeightedSet<>( - new ConfigRandomWeightedSet.WeightedObject<>(10, new PokePaste("https://pokepast.es/", Lists.newArrayList("ay %player%"), Lists.newArrayList("be %player%"))) - ); + new ConfigRandomWeightedSet.WeightedObject<>(10, new PokePaste("https://pokepast.es/"))); public TeamPossibilities() { } @@ -159,13 +158,15 @@ public static class PokePaste { private String paste; private transient List team; - private List playerWinCommands; - private List playerLossCommands; + private ConfigRandomWeightedSet playerWinCommands = new ConfigRandomWeightedSet<>( + new ConfigRandomWeightedSet.WeightedObject<>(10, new Commands(Lists.newArrayList("broadcast %player%"))) + ); + private ConfigRandomWeightedSet playerLossCommands = new ConfigRandomWeightedSet<>( + new ConfigRandomWeightedSet.WeightedObject<>(10, new Commands(Lists.newArrayList("broadcast %player%"))) + ); - public PokePaste(String paste, List playerWinCommands, List playerLossCommands) { + public PokePaste(String paste) { this.paste = paste; - this.playerWinCommands = playerWinCommands; - this.playerLossCommands = playerLossCommands; } public PokePaste() { @@ -180,11 +181,28 @@ public List getTeam() { } public List getPlayerWinCommands() { - return this.playerWinCommands; + return this.playerWinCommands.getRandom().getCommands(); } public List getPlayerLossCommands() { - return this.playerLossCommands; + return this.playerLossCommands.getRandom().getCommands(); + } + } + + @ConfigSerializable + public static class Commands { + + private List commands; + + public Commands(List commands) { + this.commands = commands; + } + + public Commands() { + } + + public List getCommands() { + return this.commands; } } }