From 43361897ff06d246ff29fb9f9a269e617523e004 Mon Sep 17 00:00:00 2001 From: Simon Bussmann Date: Tue, 23 Mar 2021 22:27:14 +0100 Subject: [PATCH] Added deployment options for the client - Client can be downloaded under www.cato447.tech - Added support for numbers notated in "," and "." form --- .idea/artifacts/Client_jar.xml | 2 +- Client/src/networking/Client.java | 2 -- Server/src/res/TicTacToe_GameRules.java | 11 +++++++++-- deployment/client/deployClient | 6 ++++++ deployment/client/package/startClient.bat | 2 ++ deployment/client/startClient | 3 +++ 6 files changed, 21 insertions(+), 5 deletions(-) create mode 100755 deployment/client/deployClient create mode 100644 deployment/client/package/startClient.bat create mode 100755 deployment/client/startClient diff --git a/.idea/artifacts/Client_jar.xml b/.idea/artifacts/Client_jar.xml index 114e9cc..43fd0d3 100644 --- a/.idea/artifacts/Client_jar.xml +++ b/.idea/artifacts/Client_jar.xml @@ -1,5 +1,5 @@ - + $PROJECT_DIR$/out/artifacts/Client_jar diff --git a/Client/src/networking/Client.java b/Client/src/networking/Client.java index 1d95352..b9234e1 100644 --- a/Client/src/networking/Client.java +++ b/Client/src/networking/Client.java @@ -55,14 +55,12 @@ public class Client { } public void sendToServer(String message) { - int availableBits = 0; try { out.writeUTF(message); out.flush(); boolean success = in.readBoolean(); clientLogger.printLog(String.format("Sent the message: %s", message), serverName, success, LogType.Output); if(in.available() > 0){ - availableBits = in.available(); throw new Exception("More than just a boolean sent"); } } catch (IOException e) { diff --git a/Server/src/res/TicTacToe_GameRules.java b/Server/src/res/TicTacToe_GameRules.java index f7c3df2..a283c86 100644 --- a/Server/src/res/TicTacToe_GameRules.java +++ b/Server/src/res/TicTacToe_GameRules.java @@ -35,8 +35,15 @@ public class TicTacToe_GameRules { } public boolean makeClientMove(String input, int id) { - int column = Double.valueOf(input.split("\\|")[0]).intValue() / 300; - int row = Double.valueOf(input.split("\\|")[1]).intValue() / 300; + int column = 0; + 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; if (isLegalMove(column, row)) { diff --git a/deployment/client/deployClient b/deployment/client/deployClient new file mode 100755 index 0000000..1157bce --- /dev/null +++ b/deployment/client/deployClient @@ -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 \ No newline at end of file diff --git a/deployment/client/package/startClient.bat b/deployment/client/package/startClient.bat new file mode 100644 index 0000000..469a5ab --- /dev/null +++ b/deployment/client/package/startClient.bat @@ -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 diff --git a/deployment/client/startClient b/deployment/client/startClient new file mode 100755 index 0000000..5564d07 --- /dev/null +++ b/deployment/client/startClient @@ -0,0 +1,3 @@ +#!/bin/sh +cd ~/Code/ArcadeMachine/deployment/client +java -jar package/TicTacToe_Client.jar linux