finish akinator
This commit is contained in:
parent
50af52f2e4
commit
b4495281f1
2 changed files with 25 additions and 13 deletions
|
@ -296,11 +296,14 @@ public class Responder extends ListenerAdapter {
|
||||||
} else {
|
} else {
|
||||||
hook.editOriginal(response.getMessage()).queue();
|
hook.editOriginal(response.getMessage()).queue();
|
||||||
}
|
}
|
||||||
if(response.hasSelectMenu() || response.hasButtons()) {
|
if((response.hasSelectMenu() || response.hasButtons() && !response.hasNoComponents())) {
|
||||||
List<LayoutComponent> components = new ArrayList<>();
|
List<LayoutComponent> components = new ArrayList<>();
|
||||||
if(response.hasButtons()) components.add(ActionRow.of(response.getButtons()));
|
if(response.hasButtons()) components.add(ActionRow.of(response.getButtons()));
|
||||||
if(response.hasSelectMenu()) components.add(ActionRow.of(response.getSelectMenu()));
|
if(response.hasSelectMenu()) components.add(ActionRow.of(response.getSelectMenu()));
|
||||||
hook.editOriginalComponents(components).queue();
|
hook.editOriginalComponents(components).queue();
|
||||||
|
} else if(response.hasNoComponents()) {
|
||||||
|
List<LayoutComponent> components = new ArrayList<>();
|
||||||
|
hook.editOriginalComponents(components).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import net.tylermurphy.ken.command.Response;
|
||||||
import net.tylermurphy.ken.command.annotation.ButtonCallback;
|
import net.tylermurphy.ken.command.annotation.ButtonCallback;
|
||||||
import net.tylermurphy.ken.command.annotation.Command;
|
import net.tylermurphy.ken.command.annotation.Command;
|
||||||
import net.tylermurphy.ken.util.Checks;
|
import net.tylermurphy.ken.util.Checks;
|
||||||
|
import org.json.JSONException;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -162,6 +163,7 @@ class AkinatorGame {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Response respondQuestion(String label) {
|
private Response respondQuestion(String label) {
|
||||||
|
try {
|
||||||
switch (label) {
|
switch (label) {
|
||||||
case "yes":
|
case "yes":
|
||||||
wrapper.answer(Akiwrapper.Answer.YES);
|
wrapper.answer(Akiwrapper.Answer.YES);
|
||||||
|
@ -175,6 +177,12 @@ class AkinatorGame {
|
||||||
case "back":
|
case "back":
|
||||||
return back();
|
return back();
|
||||||
}
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
// JSONEXception when aki cant make more questions
|
||||||
|
container.games.remove(gameId);
|
||||||
|
container.gameMappings.remove(userId);
|
||||||
|
return sendWin();
|
||||||
|
}
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,6 +192,7 @@ class AkinatorGame {
|
||||||
if(guess.isPresent()) {
|
if(guess.isPresent()) {
|
||||||
status = AkiStatus.GUESS;
|
status = AkiStatus.GUESS;
|
||||||
sequence.add(guess.get());
|
sequence.add(guess.get());
|
||||||
|
guesses.add(guess.get().getId());
|
||||||
attemptedGuesses++;
|
attemptedGuesses++;
|
||||||
return sendGuess(guess.get());
|
return sendGuess(guess.get());
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue