This commit is contained in:
Tim Tersch 2022-03-17 11:37:10 +01:00
parent 5e14802934
commit bf90f74b03
1 changed files with 42 additions and 2 deletions

View File

@ -103,12 +103,13 @@ public class Game {
databaseConnector.executeStatement("SELECT word FROM words WHERE id = " + getWOTDIndex());
QueryResult result = databaseConnector.getCurrentQueryResult();
System.out.println(databaseConnector.getErrorMessage());
if (result != null && result.getData().length > 0) {
wordle = result.getData()[0][0];
phase = GAME_PHASE;
send("+OK game ready");
} else {
send("-ERR Fatal error: WOTD could not be generated.");
send("-ERR fatal error: WOTD could not be generated.");
}
} else if (msg.startsWith("play")) {
@ -124,9 +125,48 @@ public class Game {
}
private void gamePhase(String msg) {
if (msg.startsWith("send")) {
if (msg.startsWith("send ")) {
String args = msg.substring(5);
if (args.length() == 5) {
databaseConnector.executeStatement("SELECT word FROM words WHERE word LIKE '" + args + "'");
QueryResult result = databaseConnector.getCurrentQueryResult();
if (result.getData().length > 0) {
String input = result.getData()[0][0];
String code = "";
code = input;
send(code);
if (code.equals("11111")) {
send("game won");
if (user != null) {
phase = END_PHASE;
} else {
phase = LOGIN_PHASE;
}
} else if (count == 6) {
send("game lost");
if (user != null) {
phase = END_PHASE;
} else {
phase = LOGIN_PHASE;
}
} else {
send("game continues");
}
} else {
send("-ERR word not in dictionary.");
}
} else {
send("-ERR wrong format.");
}
//vergleichen von wotd mit
//ja = spiel beendet und ausgabe word 11111
//nein = ausgabe 01102 oder so und pr<EFBFBD>fen ob man noch ein wort eingebn kann