added lib and changed db

This commit is contained in:
Alperen Semih Baldan 2022-03-03 11:28:20 +01:00
parent a5ffccc596
commit 55fe449643
6 changed files with 138 additions and 113 deletions

1
.gitignore vendored
View File

@ -13,7 +13,6 @@ Dokumente*
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear

Binary file not shown.

View File

@ -1,95 +1,118 @@
public class Game {
// Instanzvariablen - ersetzen Sie das folgende Beispiel mit Ihren Variablen
WordleServer wordleServer;
User user;
static DatabaseConnector databaseConnector;// Datenbankverbindung aufstellen
private String ip;
private int port;
private String wordle;
private String[] words;
private int count;
private int phase;
public Game(WordleServer wordleServer, String pClientIP, int pClientPort) {
this.wordleServer = wordleServer;
this.ip = pClientIP;
this.port = pClientPort;
send("+OK Hello there");
}
public void processMessage(String msg) {
msg = msg.toLowerCase().trim();
if (msg.equals("quit")) {
send("+OK bye");
wordleServer.closeConnection(ip, port);
}
switch (phase) {
case 0:
loginPhase(msg);
break;
case 1:
gamePhase(msg);
break;
case 2:
endPhase(msg);
break;
}
}
private void loginPhase(String msg) {
if (msg.startsWith("user")) {
} else if (msg.startsWith("pass")) {
} else if (msg.startsWith("wotd")) {
} else if (msg.startsWith("play")) {
}
}
private void gamePhase(String msg) {
if (msg.startsWith("send")) {
} else if (msg.startsWith("info")) {
} else if (msg.startsWith("exit")) {
}
}
private void endPhase(String msg) {
if (msg.startsWith("stat")) {
} else if (msg.startsWith("play")) {
}
}
private void send(String msg) {
wordleServer.send(ip, port, msg);
}
public String getIp() {
return ip;
}
// Instanzvariablen - ersetzen Sie das folgende Beispiel mit Ihren Variablen
WordleServer wordleServer;
User user;
static DatabaseConnector databaseConnector = new DatabaseConnector("", 0, "wordle.db", "", "");;// Datenbankverbindung aufstellen
private String ip;
private int port;
private String wordle;
private String[] words;
private int count;
private int phase;
public Game(WordleServer wordleServer, String pClientIP, int pClientPort) {
this.wordleServer = wordleServer;
this.ip = pClientIP;
this.port = pClientPort;
send("+OK Hello there");
}
public void processMessage(String msg) {
msg = msg.toLowerCase().trim();
if (msg.equals("quit")) {
send("+OK bye");
wordleServer.closeConnection(ip, port);
}
switch (phase) {
case 0:
loginPhase(msg);
break;
case 1:
gamePhase(msg);
break;
case 2:
endPhase(msg);
break;
}
}
private void loginPhase(String msg) {
if (msg.startsWith("user")) {
} else if (msg.startsWith("pass")) {
} else if (msg.startsWith("wotd")) {
} else if (msg.startsWith("play")) {
}
}
private void gamePhase(String msg) {
if (msg.startsWith("send")) {
String args = msg.substring(5);
//vergleichen von wotd mit
//ja = spiel beendet und ausgabe word 11111
//nein = ausgabe 01102 oder so und prüfen ob man noch ein wort eingebn kann
// ja game continues nein = game lost
} else if (msg.startsWith("info")) {
} else if (msg.startsWith("exit")) {
}
}
private void endPhase(String msg) {
if (msg.startsWith("stat")) {
} else if (msg.startsWith("play")) {
}
}
private void spielstandAbrufen(String name)
{
databaseConnector.executeStatement("SELECT password FROM User Where name =" + this.name);
String result = databaseConnector.getCurrentQueryResult().getData()[0][0];
return result;
}
private void send(String msg) {
wordleServer.send(ip, port, msg);
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public int getPort() {
return port;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public void setPort(int port) {
this.port = port;
}
}

View File

@ -151,4 +151,7 @@ public class User
int[] result = {getWonInTurn(1),getWonInTurn(2),getWonInTurn(3),getWonInTurn(4),getWonInTurn(5),getWonInTurn(6)};
return result;
}
}

View File

@ -2,7 +2,7 @@
dependency1.from=DatabaseConnector
dependency1.to=QueryResult
dependency1.type=UsesDependency
dependency10.from=User
dependency10.from=Game
dependency10.to=DatabaseConnector
dependency10.type=UsesDependency
dependency2.from=DatabaseConnector
@ -11,26 +11,26 @@ dependency2.type=UsesDependency
dependency3.from=Server
dependency3.to=List
dependency3.type=UsesDependency
dependency4.from=Game
dependency4.to=WordleServer
dependency4.from=User
dependency4.to=DatabaseConnector
dependency4.type=UsesDependency
dependency5.from=Game
dependency5.to=User
dependency5.from=WordleServer
dependency5.to=List
dependency5.type=UsesDependency
dependency6.from=Game
dependency6.to=DatabaseConnector
dependency6.from=WordleServer
dependency6.to=Game
dependency6.type=UsesDependency
dependency7.from=WordleServer
dependency7.to=List
dependency7.to=DatabaseConnector
dependency7.type=UsesDependency
dependency8.from=WordleServer
dependency8.to=Game
dependency8.from=Game
dependency8.to=WordleServer
dependency8.type=UsesDependency
dependency9.from=WordleServer
dependency9.to=DatabaseConnector
dependency9.from=Game
dependency9.to=User
dependency9.type=UsesDependency
editor.fx.0.height=1026
editor.fx.0.width=1696
editor.fx.0.width=856
editor.fx.0.x=-8
editor.fx.0.y=-8
objectbench.height=153
@ -65,8 +65,8 @@ target10.name=GUI
target10.showInterface=false
target10.type=ClassTarget
target10.width=120
target10.x=140
target10.y=150
target10.x=10
target10.y=270
target11.height=60
target11.name=Queue
target11.showInterface=false
@ -79,8 +79,8 @@ target2.name=DatabaseConnector
target2.showInterface=false
target2.type=ClassTarget
target2.width=150
target2.x=180
target2.y=70
target2.x=220
target2.y=80
target3.height=60
target3.name=QueryResult
target3.showInterface=false
@ -93,14 +93,14 @@ target4.name=Game
target4.showInterface=false
target4.type=ClassTarget
target4.width=180
target4.x=630
target4.y=340
target4.x=680
target4.y=320
target5.height=70
target5.name=User
target5.showInterface=false
target5.type=ClassTarget
target5.width=130
target5.x=900
target5.x=930
target5.y=180
target6.height=70
target6.name=Server
@ -121,8 +121,8 @@ target8.name=Guest
target8.showInterface=false
target8.type=ClassTarget
target8.width=130
target8.x=900
target8.y=310
target8.x=10
target8.y=180
target9.height=60
target9.name=List
target9.showInterface=false

BIN
wordle.db

Binary file not shown.