Skip to content

Commit

Permalink
feat(forge16): add weighted random command selection
Browse files Browse the repository at this point in the history
  • Loading branch information
danorris709 committed Nov 6, 2022
1 parent 5905e19 commit 44de95b
Showing 1 changed file with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ public static class TeamPossibilities {
private int startFloor = 0;
private int endFloor = 1000;
private ConfigRandomWeightedSet<PokePaste> 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() {
}
Expand All @@ -159,13 +158,15 @@ public static class PokePaste {

private String paste;
private transient List<Pokemon> team;
private List<String> playerWinCommands;
private List<String> playerLossCommands;
private ConfigRandomWeightedSet<Commands> playerWinCommands = new ConfigRandomWeightedSet<>(
new ConfigRandomWeightedSet.WeightedObject<>(10, new Commands(Lists.newArrayList("broadcast %player%")))
);
private ConfigRandomWeightedSet<Commands> playerLossCommands = new ConfigRandomWeightedSet<>(
new ConfigRandomWeightedSet.WeightedObject<>(10, new Commands(Lists.newArrayList("broadcast %player%")))
);

public PokePaste(String paste, List<String> playerWinCommands, List<String> playerLossCommands) {
public PokePaste(String paste) {
this.paste = paste;
this.playerWinCommands = playerWinCommands;
this.playerLossCommands = playerLossCommands;
}

public PokePaste() {
Expand All @@ -180,11 +181,28 @@ public List<Pokemon> getTeam() {
}

public List<String> getPlayerWinCommands() {
return this.playerWinCommands;
return this.playerWinCommands.getRandom().getCommands();
}

public List<String> getPlayerLossCommands() {
return this.playerLossCommands;
return this.playerLossCommands.getRandom().getCommands();
}
}

@ConfigSerializable
public static class Commands {

private List<String> commands;

public Commands(List<String> commands) {
this.commands = commands;
}

public Commands() {
}

public List<String> getCommands() {
return this.commands;
}
}
}

0 comments on commit 44de95b

Please sign in to comment.