Skip to content

Commit 393e1ed

Browse files
committed
only show post-season teams by default in /plangame
1 parent a523038 commit 393e1ed

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/main/java/pw/chew/mlb/util/MLBAPIUtil.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import java.time.Duration;
1212
import java.util.ArrayList;
13+
import java.util.Arrays;
1314
import java.util.Collections;
1415
import java.util.HashMap;
1516
import java.util.List;
@@ -143,10 +144,25 @@ public List<Command.Choice> asChoices() {
143144
return choices.subList(0, Math.min(choices.size(), 25));
144145
}
145146

147+
public List<Command.Choice> asPostSeasonChoices() {
148+
// we only want people in the post-season. These teams are: 147, 110, 114, 118, 116, 117, 143, 121, 158, 119, 135, 109, 144
149+
List<Integer> postSeason = Arrays.asList(147, 110, 114, 118, 116, 117, 143, 121, 158, 119, 135, 109, 144);
150+
151+
List<Command.Choice> choices = new ArrayList<>();
152+
for (int i = 0; i < raw.length(); i++) {
153+
JSONObject team = raw.getJSONObject(i);
154+
if (postSeason.contains(team.getInt("id"))) {
155+
choices.add(new Command.Choice(team.getString("name"), team.getInt("id")));
156+
}
157+
}
158+
159+
return choices;
160+
}
161+
146162
public List<Command.Choice> potentialChoices(String query) {
147163
// If we don't have an input, return all choices
148164
if (query.isBlank()) {
149-
return asChoices();
165+
return asPostSeasonChoices();
150166
}
151167

152168
List<Command.Choice> potential = new ArrayList<>();

0 commit comments

Comments
 (0)