Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix trivia solver glitch #89

Merged
merged 2 commits into from
Oct 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Trivia extends ChatPatternListener {
private List<String> solutions = Collections.emptyList();

public Trivia() {
super("^ +(?:([A-Za-z' ]*\\?)|§6 ([ⓐⓑⓒ]) §a([a-zA-Z0-9 ]+))$");
super("^ +(?:([A-Za-z,' ]*\\?)|§6 ([ⓐⓑⓒ]) §a([a-zA-Z0-9 ]+))$");
}

@Override
Expand All @@ -40,13 +40,14 @@ public boolean onMatch(Text message, Matcher matcher) {
}

private void updateSolutions(String question) {
if (question.equals("What SkyBlock year is it?")) {
String trimmedQuestion = question.trim();
if (trimmedQuestion.equals("What SkyBlock year is it?")) {
long currentTime = System.currentTimeMillis() / 1000L;
long diff = currentTime - 1560276000;
int year = (int) (diff / 446400 + 1);
solutions = Collections.singletonList("Year " + year);
} else {
solutions = Arrays.asList(answers.get(question));
solutions = Arrays.asList(answers.get(trimmedQuestion));
}
}

Expand All @@ -63,6 +64,7 @@ private void updateSolutions(String question) {
answers.put("What is the status of Goldor?", new String[]{"The Wither Lords"});
answers.put("What is the status of Storm?", new String[]{"The Wither Lords"});
answers.put("What is the status of Necron?", new String[]{"The Wither Lords"});
answers.put("What is the status of Maxor, Storm, Goldor and Necron?", new String[]{"The Wither Lords"});
answers.put("How many total Fairy Souls are there?", new String[]{"238 Fairy Souls"});
answers.put("How many Fairy Souls are there in Spider's Den?", new String[]{"19 Fairy Souls"});
answers.put("How many Fairy Souls are there in The End?", new String[]{"12 Fairy Souls"});
Expand Down