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 {
|
||||
hook.editOriginal(response.getMessage()).queue();
|
||||
}
|
||||
if(response.hasSelectMenu() || response.hasButtons()) {
|
||||
if((response.hasSelectMenu() || response.hasButtons() && !response.hasNoComponents())) {
|
||||
List<LayoutComponent> components = new ArrayList<>();
|
||||
if(response.hasButtons()) components.add(ActionRow.of(response.getButtons()));
|
||||
if(response.hasSelectMenu()) components.add(ActionRow.of(response.getSelectMenu()));
|
||||
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.Command;
|
||||
import net.tylermurphy.ken.util.Checks;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
|
@ -162,18 +163,25 @@ class AkinatorGame {
|
|||
}
|
||||
|
||||
private Response respondQuestion(String label) {
|
||||
switch (label) {
|
||||
case "yes":
|
||||
wrapper.answer(Akiwrapper.Answer.YES);
|
||||
break;
|
||||
case "no":
|
||||
wrapper.answer(Akiwrapper.Answer.NO);
|
||||
break;
|
||||
case "idk":
|
||||
wrapper.answer(Akiwrapper.Answer.DONT_KNOW);
|
||||
break;
|
||||
case "back":
|
||||
return back();
|
||||
try {
|
||||
switch (label) {
|
||||
case "yes":
|
||||
wrapper.answer(Akiwrapper.Answer.YES);
|
||||
break;
|
||||
case "no":
|
||||
wrapper.answer(Akiwrapper.Answer.NO);
|
||||
break;
|
||||
case "idk":
|
||||
wrapper.answer(Akiwrapper.Answer.DONT_KNOW);
|
||||
break;
|
||||
case "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();
|
||||
}
|
||||
|
@ -184,6 +192,7 @@ class AkinatorGame {
|
|||
if(guess.isPresent()) {
|
||||
status = AkiStatus.GUESS;
|
||||
sequence.add(guess.get());
|
||||
guesses.add(guess.get().getId());
|
||||
attemptedGuesses++;
|
||||
return sendGuess(guess.get());
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue