From 3b7b861990958b59e38f4c883248f75ccba27573 Mon Sep 17 00:00:00 2001 From: ThiML10 <157675695+ThiML10@users.noreply.github.com> Date: Tue, 16 Apr 2024 04:30:11 +0000 Subject: [PATCH 1/6] lobby html --- html/lobby.html | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/html/lobby.html b/html/lobby.html index 652a7c0..07d7b92 100644 --- a/html/lobby.html +++ b/html/lobby.html @@ -10,6 +10,7 @@
+
@@ -117,16 +118,44 @@

The Word Search Game

socket.send(JSON.stringify(data)); } - // event listener for the leave button + // the leave button document.getElementById('leaveButton').addEventListener('click', function() { var nick = document.getElementById('nickInput').value; leaveGame(nick); }); - // add an event listener for the refresh button to request the game list + // refresh button to request the game list document.getElementById('refreshButton').addEventListener('click', function() { requestGameList(); }); + + //the help content + document.getElementById('helpButton').addEventListener('click', function() { + displayHelp(); + }); + + function displayHelp() { + alert("This is the rules of this game."); + } + + //the standby button + document.getElementById('standbyButton').addEventListener('click', function() { + var nick = document.getElementById('nickInput').value.trim(); + var mode = document.getElementById('modeSelect').value; + + putOnStandby(nick, mode); + }); + + function putOnStandby(nick, mode) { + var data = { + type: "JoinGame", + nick: nick, + gameIndex: "standby", + modeIndex: mode + }; + socket.send(JSON.stringify(data)); + alert("You are now on standby."); + } From f6db75f1c103ddad9a9756bf1b2ca1d1199e4de3 Mon Sep 17 00:00:00 2001 From: ThiML10 <157675695+ThiML10@users.noreply.github.com> Date: Tue, 16 Apr 2024 04:36:24 +0000 Subject: [PATCH 2/6] lobby html --- html/lobby.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/html/lobby.html b/html/lobby.html index 07d7b92..62f5c7f 100644 --- a/html/lobby.html +++ b/html/lobby.html @@ -52,6 +52,10 @@

The Word Search Game

socket.onclose = function(evt) { console.log("WebSocket connection closed."); + var nick = document.getElementById('nickInput').value.trim(); + if (nick) { + leaveGame(nick); + } document.getElementById("topMessage").innerText = "Server Offline"; }; From 9069277b744b10a2e0a7dfc857b96f9a0d6f78db Mon Sep 17 00:00:00 2001 From: antmorales1 <122925857+antmorales1@users.noreply.github.com> Date: Tue, 16 Apr 2024 04:38:29 +0000 Subject: [PATCH 3/6] updated char req --- src/main/java/uta/cse3310/WordList.java | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/java/uta/cse3310/WordList.java b/src/main/java/uta/cse3310/WordList.java index c741886..ab9bb16 100644 --- a/src/main/java/uta/cse3310/WordList.java +++ b/src/main/java/uta/cse3310/WordList.java @@ -33,14 +33,26 @@ public void shuffleWords() Collections.shuffle(list); } - public List updatedWordList(List wordBank) { - if (wordBank.size() < 500) { - System.err.println("Word bank does not contain at least 500 words."); - return Collections.emptyList(); + public List updatedWordList(List wordBank) + { + int totalCharacters = 0; + int index = 0; + List updatedList = new ArrayList<>(); + + while (totalCharacters < 2000 && index < wordBank.size()) + { + String word = wordBank.get(index); + if (totalCharacters + word.length() <= 2000) + { + updatedList.add(word); + totalCharacters += word.length(); + } else + { + break; + } + index++; } - List updatedList = new ArrayList<>(wordBank.subList(0, 500)); - return updatedList; } From 4ca039552e248c5a88e29ea3c31b645b9010390b Mon Sep 17 00:00:00 2001 From: manuelh20013 <112411017+manuelh20013@users.noreply.github.com> Date: Mon, 15 Apr 2024 23:42:34 -0500 Subject: [PATCH 4/6] Create main.yml --- .github/workflows/main.yml | 74 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..b81645e --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,74 @@ +# Derived from an example provided by https://blog.benoitblanchon.fr/github-action-run-ssh-commands/ +# https://github.blog/2015-06-16-read-only-deploy-keys/ +# +# +# +# +# +name: Deploy +on: [push] +jobs: + deploy: + name: "Deploy to server" + runs-on: ubuntu-latest + steps: + - name: configure SSH + run: | + # These are very useful for debugging + echo "Repository = ${{ github.repository }}" + echo "github url = ${{ github.server_url }}" + echo "Owner = ${{ github.repository_owner }}" + echo "Repository name = ${{ github.event.repository.name }}" + echo "Service name = ${{ vars.service_name }}" + echo "http port = ${{ vars.http_port }}" + echo "websocket port = ${{ vars.websocket_port }}" + echo "version = $${ github.sha }}" + # On to the work at hand. + mkdir -p ~/.ssh/ + echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/production.key + chmod 600 ~/.ssh/production.key + cat >>~/.ssh/config <> .config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "Description=${{ vars.service_name }}" >> .config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "[Service]" >> .config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "Type=simple" >> .config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "Restart=always" >> .config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "RestartSec=5" >> .config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "Environment=VERSION=\"${{ github.sha }}\"" >>.config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "Environment=WEBSOCKET_PORT=${{ vars.websocket_port }}" >>.config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "Environment=HTTP_PORT=${{ vars.http_port }}" >>.config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "ExecStart=mvn exec:java -Dexec.mainClass=uta.cse3310.App" >> .config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "WorkingDirectory=$PWD/${{ github.event.repository.name }}" >> .config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "[Install]" >>.config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "WantedBy=default.target" >>.config/systemd/user/${{ vars.service_name }}.service' + - name: systemd reload + run: | + ssh production "systemctl --user daemon-reload" + + - name: restart daemon + run: | + ssh production "systemctl --user enable ${{ vars.service_name }}" + ssh production "systemctl --user restart ${{ vars.service_name }}" + ssh production "systemctl --user status ${{ vars.service_name }}" + From b6872d1c7eff0cdf91385b751819076a655bf256 Mon Sep 17 00:00:00 2001 From: manuelh20013 <112411017+manuelh20013@users.noreply.github.com> Date: Mon, 15 Apr 2024 23:55:49 -0500 Subject: [PATCH 5/6] Delete .github/workflows directory --- .github/workflows/main.yml | 74 -------------------------------------- 1 file changed, 74 deletions(-) delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index b81645e..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,74 +0,0 @@ -# Derived from an example provided by https://blog.benoitblanchon.fr/github-action-run-ssh-commands/ -# https://github.blog/2015-06-16-read-only-deploy-keys/ -# -# -# -# -# -name: Deploy -on: [push] -jobs: - deploy: - name: "Deploy to server" - runs-on: ubuntu-latest - steps: - - name: configure SSH - run: | - # These are very useful for debugging - echo "Repository = ${{ github.repository }}" - echo "github url = ${{ github.server_url }}" - echo "Owner = ${{ github.repository_owner }}" - echo "Repository name = ${{ github.event.repository.name }}" - echo "Service name = ${{ vars.service_name }}" - echo "http port = ${{ vars.http_port }}" - echo "websocket port = ${{ vars.websocket_port }}" - echo "version = $${ github.sha }}" - # On to the work at hand. - mkdir -p ~/.ssh/ - echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/production.key - chmod 600 ~/.ssh/production.key - cat >>~/.ssh/config <> .config/systemd/user/${{ vars.service_name }}.service' - ssh production 'echo "Description=${{ vars.service_name }}" >> .config/systemd/user/${{ vars.service_name }}.service' - ssh production 'echo "[Service]" >> .config/systemd/user/${{ vars.service_name }}.service' - ssh production 'echo "Type=simple" >> .config/systemd/user/${{ vars.service_name }}.service' - ssh production 'echo "Restart=always" >> .config/systemd/user/${{ vars.service_name }}.service' - ssh production 'echo "RestartSec=5" >> .config/systemd/user/${{ vars.service_name }}.service' - ssh production 'echo "Environment=VERSION=\"${{ github.sha }}\"" >>.config/systemd/user/${{ vars.service_name }}.service' - ssh production 'echo "Environment=WEBSOCKET_PORT=${{ vars.websocket_port }}" >>.config/systemd/user/${{ vars.service_name }}.service' - ssh production 'echo "Environment=HTTP_PORT=${{ vars.http_port }}" >>.config/systemd/user/${{ vars.service_name }}.service' - ssh production 'echo "ExecStart=mvn exec:java -Dexec.mainClass=uta.cse3310.App" >> .config/systemd/user/${{ vars.service_name }}.service' - ssh production 'echo "WorkingDirectory=$PWD/${{ github.event.repository.name }}" >> .config/systemd/user/${{ vars.service_name }}.service' - ssh production 'echo "[Install]" >>.config/systemd/user/${{ vars.service_name }}.service' - ssh production 'echo "WantedBy=default.target" >>.config/systemd/user/${{ vars.service_name }}.service' - - name: systemd reload - run: | - ssh production "systemctl --user daemon-reload" - - - name: restart daemon - run: | - ssh production "systemctl --user enable ${{ vars.service_name }}" - ssh production "systemctl --user restart ${{ vars.service_name }}" - ssh production "systemctl --user status ${{ vars.service_name }}" - From 6d0453b5a3cb14b812ad16e63a95352a200b8a1e Mon Sep 17 00:00:00 2001 From: manuelh20013 <112411017+manuelh20013@users.noreply.github.com> Date: Mon, 15 Apr 2024 23:56:30 -0500 Subject: [PATCH 6/6] Create main.yml --- .github/workflows/main.yml | 74 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..b81645e --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,74 @@ +# Derived from an example provided by https://blog.benoitblanchon.fr/github-action-run-ssh-commands/ +# https://github.blog/2015-06-16-read-only-deploy-keys/ +# +# +# +# +# +name: Deploy +on: [push] +jobs: + deploy: + name: "Deploy to server" + runs-on: ubuntu-latest + steps: + - name: configure SSH + run: | + # These are very useful for debugging + echo "Repository = ${{ github.repository }}" + echo "github url = ${{ github.server_url }}" + echo "Owner = ${{ github.repository_owner }}" + echo "Repository name = ${{ github.event.repository.name }}" + echo "Service name = ${{ vars.service_name }}" + echo "http port = ${{ vars.http_port }}" + echo "websocket port = ${{ vars.websocket_port }}" + echo "version = $${ github.sha }}" + # On to the work at hand. + mkdir -p ~/.ssh/ + echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/production.key + chmod 600 ~/.ssh/production.key + cat >>~/.ssh/config <> .config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "Description=${{ vars.service_name }}" >> .config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "[Service]" >> .config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "Type=simple" >> .config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "Restart=always" >> .config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "RestartSec=5" >> .config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "Environment=VERSION=\"${{ github.sha }}\"" >>.config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "Environment=WEBSOCKET_PORT=${{ vars.websocket_port }}" >>.config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "Environment=HTTP_PORT=${{ vars.http_port }}" >>.config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "ExecStart=mvn exec:java -Dexec.mainClass=uta.cse3310.App" >> .config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "WorkingDirectory=$PWD/${{ github.event.repository.name }}" >> .config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "[Install]" >>.config/systemd/user/${{ vars.service_name }}.service' + ssh production 'echo "WantedBy=default.target" >>.config/systemd/user/${{ vars.service_name }}.service' + - name: systemd reload + run: | + ssh production "systemctl --user daemon-reload" + + - name: restart daemon + run: | + ssh production "systemctl --user enable ${{ vars.service_name }}" + ssh production "systemctl --user restart ${{ vars.service_name }}" + ssh production "systemctl --user status ${{ vars.service_name }}" +