forked from IF-LK-2020/wordle
Compare commits
5 Commits
37736dbfad
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc8d803d32 | ||
|
|
68549bbc8b | ||
|
|
92d4f15e75 | ||
|
|
a78fac1baf | ||
|
|
84a81bf2b4 |
@@ -1,6 +1,5 @@
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
public class Game {
|
public class Game {
|
||||||
|
|
||||||
@@ -53,7 +52,6 @@ public class Game {
|
|||||||
}
|
}
|
||||||
send("+OK bye");
|
send("+OK bye");
|
||||||
wordleServer.closeConnection(ip, port);
|
wordleServer.closeConnection(ip, port);
|
||||||
System.exit(0); // TODO remove: Einfacher zum testen
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (phase) {
|
switch (phase) {
|
||||||
@@ -149,8 +147,6 @@ public class Game {
|
|||||||
|
|
||||||
String args = msg.substring(5);
|
String args = msg.substring(5);
|
||||||
|
|
||||||
System.out.println(wordle);
|
|
||||||
|
|
||||||
if (args.length() == 5) {
|
if (args.length() == 5) {
|
||||||
|
|
||||||
databaseConnector.executeStatement("SELECT word FROM words WHERE word LIKE '" + args + "'");
|
databaseConnector.executeStatement("SELECT word FROM words WHERE word LIKE '" + args + "'");
|
||||||
@@ -207,6 +203,38 @@ public class Game {
|
|||||||
|
|
||||||
} else if (msg.startsWith("info")) {
|
} else if (msg.startsWith("info")) {
|
||||||
|
|
||||||
|
if (msg.length() == 4) {
|
||||||
|
send("+OK");
|
||||||
|
for (int i = 0; i < words.length; i++) {
|
||||||
|
if (words[i] == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
send(words[i] + " " + generateCode(words[i]));
|
||||||
|
}
|
||||||
|
send(".");
|
||||||
|
} else if (msg.length() == 6) {
|
||||||
|
|
||||||
|
String rawLine = msg.substring(5);
|
||||||
|
int line = -1;
|
||||||
|
try {
|
||||||
|
line = Integer.parseInt(rawLine) - 1;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
send("-ERR wrong argument.");
|
||||||
|
}
|
||||||
|
if (line >= 0 && line < 5) {
|
||||||
|
if (words[line] != null) {
|
||||||
|
send("+OK " + words[line] + " " + generateCode(words[line]));
|
||||||
|
} else {
|
||||||
|
send("-ERR game hasn't progressed to this line yet.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
send("-ERR couldn't parse line.");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
sendUniversalError();
|
||||||
|
}
|
||||||
|
|
||||||
} else if (msg.startsWith("exit")) {
|
} else if (msg.startsWith("exit")) {
|
||||||
|
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
@@ -269,11 +297,14 @@ public class Game {
|
|||||||
|
|
||||||
databaseConnector.executeStatement("SELECT * FROM Spielstand WHERE Username = '" + user.getName() + "'");
|
databaseConnector.executeStatement("SELECT * FROM Spielstand WHERE Username = '" + user.getName() + "'");
|
||||||
QueryResult result = databaseConnector.getCurrentQueryResult();
|
QueryResult result = databaseConnector.getCurrentQueryResult();
|
||||||
if (result != null && result.getData().length > 0) {
|
if (result != null && result.getData().length > 0 && !result.getData()[0][0].equals("null")) {
|
||||||
for (int i = 0; i < result.getData().length; i++) {
|
boolean foundEnd = false;
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
if (!result.getData()[0][i].equals("null")) {
|
||||||
words[i] = result.getData()[0][i];
|
words[i] = result.getData()[0][i];
|
||||||
if (result.getData()[0][i] == null) {
|
} else if (!foundEnd) {
|
||||||
count = i - 1;
|
count = i;
|
||||||
|
foundEnd = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
send("+OK game running");
|
send("+OK game running");
|
||||||
|
|||||||
Reference in New Issue
Block a user