forked from IF-LK-2020/wordle
parent
0c77b295d1
commit
5e14802934
|
@ -103,13 +103,12 @@ public class Game {
|
||||||
|
|
||||||
databaseConnector.executeStatement("SELECT word FROM words WHERE id = " + getWOTDIndex());
|
databaseConnector.executeStatement("SELECT word FROM words WHERE id = " + getWOTDIndex());
|
||||||
QueryResult result = databaseConnector.getCurrentQueryResult();
|
QueryResult result = databaseConnector.getCurrentQueryResult();
|
||||||
System.out.println(databaseConnector.getErrorMessage());
|
|
||||||
if (result != null && result.getData().length > 0) {
|
if (result != null && result.getData().length > 0) {
|
||||||
wordle = result.getData()[0][0];
|
wordle = result.getData()[0][0];
|
||||||
phase = GAME_PHASE;
|
phase = GAME_PHASE;
|
||||||
send("+OK game ready");
|
send("+OK game ready");
|
||||||
} else {
|
} else {
|
||||||
send("-ERR fatal error: WOTD could not be generated.");
|
send("-ERR Fatal error: WOTD could not be generated.");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (msg.startsWith("play")) {
|
} else if (msg.startsWith("play")) {
|
||||||
|
@ -125,48 +124,9 @@ public class Game {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void gamePhase(String msg) {
|
private void gamePhase(String msg) {
|
||||||
if (msg.startsWith("send ")) {
|
if (msg.startsWith("send")) {
|
||||||
|
|
||||||
String args = msg.substring(5);
|
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
|
//vergleichen von wotd mit
|
||||||
//ja = spiel beendet und ausgabe word 11111
|
//ja = spiel beendet und ausgabe word 11111
|
||||||
//nein = ausgabe 01102 oder so und pr<EFBFBD>fen ob man noch ein wort eingebn kann
|
//nein = ausgabe 01102 oder so und pr<EFBFBD>fen ob man noch ein wort eingebn kann
|
||||||
|
|
Loading…
Reference in New Issue