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,18 +163,25 @@ class AkinatorGame {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Response respondQuestion(String label) {
|
private Response respondQuestion(String label) {
|
||||||
switch (label) {
|
try {
|
||||||
case "yes":
|
switch (label) {
|
||||||
wrapper.answer(Akiwrapper.Answer.YES);
|
case "yes":
|
||||||
break;
|
wrapper.answer(Akiwrapper.Answer.YES);
|
||||||
case "no":
|
break;
|
||||||
wrapper.answer(Akiwrapper.Answer.NO);
|
case "no":
|
||||||
break;
|
wrapper.answer(Akiwrapper.Answer.NO);
|
||||||
case "idk":
|
break;
|
||||||
wrapper.answer(Akiwrapper.Answer.DONT_KNOW);
|
case "idk":
|
||||||
break;
|
wrapper.answer(Akiwrapper.Answer.DONT_KNOW);
|
||||||
case "back":
|
break;
|
||||||
return back();
|
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();
|
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