Added deployment options for the client

- Client can be downloaded under www.cato447.tech
- Added support for numbers notated in "," and "." form
This commit is contained in:
2021-03-23 22:27:14 +01:00
parent e96708b64e
commit 43361897ff
6 changed files with 21 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
<component name="ArtifactManager"> <component name="ArtifactManager">
<artifact type="jar" name="Client:jar"> <artifact type="jar" build-on-make="true" name="Client:jar">
<output-path>$PROJECT_DIR$/out/artifacts/Client_jar</output-path> <output-path>$PROJECT_DIR$/out/artifacts/Client_jar</output-path>
<root id="archive" name="Client.jar"> <root id="archive" name="Client.jar">
<element id="module-output" name="Client" /> <element id="module-output" name="Client" />

View File

@@ -55,14 +55,12 @@ public class Client {
} }
public void sendToServer(String message) { public void sendToServer(String message) {
int availableBits = 0;
try { try {
out.writeUTF(message); out.writeUTF(message);
out.flush(); out.flush();
boolean success = in.readBoolean(); boolean success = in.readBoolean();
clientLogger.printLog(String.format("Sent the message: %s", message), serverName, success, LogType.Output); clientLogger.printLog(String.format("Sent the message: %s", message), serverName, success, LogType.Output);
if(in.available() > 0){ if(in.available() > 0){
availableBits = in.available();
throw new Exception("More than just a boolean sent"); throw new Exception("More than just a boolean sent");
} }
} catch (IOException e) { } catch (IOException e) {

View File

@@ -35,8 +35,15 @@ public class TicTacToe_GameRules {
} }
public boolean makeClientMove(String input, int id) { public boolean makeClientMove(String input, int id) {
int column = Double.valueOf(input.split("\\|")[0]).intValue() / 300; int column = 0;
int row = Double.valueOf(input.split("\\|")[1]).intValue() / 300; int row = 0;
if (input.contains(",")){
column = Integer.valueOf(input.split("\\|")[0].split(",")[0]) / 300;
row = Integer.valueOf(input.split("\\|")[1].split(",")[0]) / 300;
} else {
column = (int) Double.valueOf(input.split("\\|")[0]).doubleValue() / 300;
row = (int) Double.valueOf(input.split("\\|")[1]).doubleValue() / 300;
}
int index = column * 3 + row; int index = column * 3 + row;
if (isLegalMove(column, row)) { if (isLegalMove(column, row)) {

6
deployment/client/deployClient Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/sh
cp ~/Code/ArcadeMachine/out/artifacts/Client_jar/Client.jar ~/Code/ArcadeMachine/deployment/client/package
cd /var/www/html
scp * root@server:/var/www/html/
scp files/* root@server:/var/www/html/files
ssh root@server systemctl restart apache2

View File

@@ -0,0 +1,2 @@
set /p playerName=Gebe deinen Spielernamen ein:
java -jar --module-path openjfx-11.012_windows-x64_bin-sdk\javafx-sdk-11.0.2\lib --add-modules javafx.controls TicTacToe_Client.jar playerName

3
deployment/client/startClient Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
cd ~/Code/ArcadeMachine/deployment/client
java -jar package/TicTacToe_Client.jar linux