From bf1d8bc44a455a00ea5b8ca1325491018e74ba8e Mon Sep 17 00:00:00 2001 From: Lisiasty <69064684+Lisiasty-Pazurek@users.noreply.github.com> Date: Fri, 26 Jan 2024 22:26:58 +0100 Subject: [PATCH 01/10] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 68d5019..ac9c3f1 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# KJ2024 \ No newline at end of file +# KJ2024 + +REEEEEEEEEEEEEEEEEEEEEEEEE From 6052cb2dac23222b480447ba90a5fb5cc1db94cb Mon Sep 17 00:00:00 2001 From: Adam Siwek <41082766+Timmlion@users.noreply.github.com> Date: Sun, 28 Jan 2024 09:06:06 +0100 Subject: [PATCH 02/10] Add or update the Azure App Service build and deployment workflow config --- .../workflows/main_magicthememeingapiprod.yml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/main_magicthememeingapiprod.yml diff --git a/.github/workflows/main_magicthememeingapiprod.yml b/.github/workflows/main_magicthememeingapiprod.yml new file mode 100644 index 0000000..6c69998 --- /dev/null +++ b/.github/workflows/main_magicthememeingapiprod.yml @@ -0,0 +1,57 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Build and deploy ASP.Net Core app to Azure Web App - magicthememeingapiprod + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '8.x' + include-prerelease: true + + - name: Build with dotnet + run: dotnet build --configuration Release + + - name: dotnet publish + run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v3 + with: + name: .net-app + path: ${{env.DOTNET_ROOT}}/myapp + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: 'Production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v3 + with: + name: .net-app + + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: 'magicthememeingapiprod' + slot-name: 'Production' + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_77A194824F824B37818FD3C0F15D3D48 }} + package: . From 194984a8fee2572966e182124d30fcdfe242c960 Mon Sep 17 00:00:00 2001 From: Adam Siwek <41082766+Timmlion@users.noreply.github.com> Date: Sun, 28 Jan 2024 09:39:00 +0100 Subject: [PATCH 03/10] ci: add Azure Static Web Apps workflow file on-behalf-of: @Azure opensource@microsoft.com --- ...-static-web-apps-mango-water-0ba859b03.yml | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/azure-static-web-apps-mango-water-0ba859b03.yml diff --git a/.github/workflows/azure-static-web-apps-mango-water-0ba859b03.yml b/.github/workflows/azure-static-web-apps-mango-water-0ba859b03.yml new file mode 100644 index 0000000..7891e21 --- /dev/null +++ b/.github/workflows/azure-static-web-apps-mango-water-0ba859b03.yml @@ -0,0 +1,46 @@ +name: Azure Static Web Apps CI/CD + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened, closed] + branches: + - main + +jobs: + build_and_deploy_job: + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') + runs-on: ubuntu-latest + name: Build and Deploy Job + steps: + - uses: actions/checkout@v3 + with: + submodules: true + lfs: false + - name: Build And Deploy + id: builddeploy + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_MANGO_WATER_0BA859B03 }} + repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) + action: "upload" + ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### + # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig + app_location: "/" # App source code path + api_location: "" # Api source code path - optional + output_location: "/" # Built app content directory - optional + ###### End of Repository/Build Configurations ###### + + close_pull_request_job: + if: github.event_name == 'pull_request' && github.event.action == 'closed' + runs-on: ubuntu-latest + name: Close Pull Request Job + steps: + - name: Close Pull Request + id: closepullrequest + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_MANGO_WATER_0BA859B03 }} + action: "close" From 4011426360c9f85347c4cc68116a542c32b3d06e Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 28 Jan 2024 09:43:24 +0100 Subject: [PATCH 04/10] prod coon string --- client/static/js/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/static/js/main.js b/client/static/js/main.js index 593a008..d537a20 100644 --- a/client/static/js/main.js +++ b/client/static/js/main.js @@ -12,7 +12,8 @@ $(document).ready(function () { function initServer() { connection = new signalR.HubConnectionBuilder() - .withUrl("https://memethegatheringapi.azurewebsites.net/GameHub") + .withUrl("https://magicthememeingapiprod.azurewebsites.net/GameHub") + //.withUrl("https://memethegatheringapi.azurewebsites.net/GameHub") // .withUrl("https://578d-87-206-130-93.ngrok-free.app/GameHub") .withAutomaticReconnect() .configureLogging(signalR.LogLevel.Information) From bc573a8e7ccfe707928ffcfb0e0aad0223094121 Mon Sep 17 00:00:00 2001 From: Adam Siwek <41082766+Timmlion@users.noreply.github.com> Date: Sun, 28 Jan 2024 11:04:00 +0100 Subject: [PATCH 05/10] Update azure-static-web-apps-mango-water-0ba859b03.yml --- .../workflows/azure-static-web-apps-mango-water-0ba859b03.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/azure-static-web-apps-mango-water-0ba859b03.yml b/.github/workflows/azure-static-web-apps-mango-water-0ba859b03.yml index 7891e21..d3fbca7 100644 --- a/.github/workflows/azure-static-web-apps-mango-water-0ba859b03.yml +++ b/.github/workflows/azure-static-web-apps-mango-water-0ba859b03.yml @@ -28,9 +28,9 @@ jobs: action: "upload" ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig - app_location: "/" # App source code path + app_location: "/client" # App source code path api_location: "" # Api source code path - optional - output_location: "/" # Built app content directory - optional + output_location: "" # Built app content directory - optional ###### End of Repository/Build Configurations ###### close_pull_request_job: From 44555b08acb21e7b4231ed5a52c00edae74acbe8 Mon Sep 17 00:00:00 2001 From: Adam Siwek <41082766+Timmlion@users.noreply.github.com> Date: Sun, 28 Jan 2024 11:06:25 +0100 Subject: [PATCH 06/10] Update Program.cs --- backend/MemeBE/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/MemeBE/Program.cs b/backend/MemeBE/Program.cs index 5462b3e..6147e34 100644 --- a/backend/MemeBE/Program.cs +++ b/backend/MemeBE/Program.cs @@ -13,7 +13,7 @@ { options.AddPolicy("MyCorsPolicy", builder => { - builder.WithOrigins("https://nice-water-0ee9aa403.4.azurestaticapps.net", "http://localhost:63342", "https://memethegathering.wielki.ch", "https://mtg.wielki.ch/") // URL innego serwera + builder.WithOrigins("https://nice-water-0ee9aa403.4.azurestaticapps.net", "http://localhost:63342", "https://memethegathering.wielki.ch", "https://mtg.wielki.ch") // URL innego serwera .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials(); // Ważne dla SignalR From 2f56ec3c6ae15093ff86d4cae719d5e23c32338e Mon Sep 17 00:00:00 2001 From: pmadry Date: Sun, 28 Jan 2024 11:48:17 +0100 Subject: [PATCH 07/10] grumpy --- client/index.html | 15 +++++++++++---- client/static/css/style.css | 10 ++++++++++ client/static/js/main.js | 5 +++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/client/index.html b/client/index.html index 8692084..a1a6e33 100644 --- a/client/index.html +++ b/client/index.html @@ -13,7 +13,7 @@
-

Meme: The Gathering

+

Meme: The Gathering

@@ -36,9 +36,16 @@

Meme: The Gathering

-
-
Invite your friends - Room ID:
-
+
+
+ +
+
+
Invite your friends - Room ID:
+
+ +
+
diff --git a/client/static/css/style.css b/client/static/css/style.css index 4ea5116..a728eb4 100644 --- a/client/static/css/style.css +++ b/client/static/css/style.css @@ -145,6 +145,16 @@ body { flex-direction: row; } +.middle .lastDetails { + display: flex; + flex-direction: row; + flex-grow: 1; +} + +.middle #lastCard { + width: 250px; +} + .middle .lastMessage { flex-grow: 1; display: flex; diff --git a/client/static/js/main.js b/client/static/js/main.js index d88d6d8..ce33a99 100644 --- a/client/static/js/main.js +++ b/client/static/js/main.js @@ -121,6 +121,11 @@ function initReceiveMethods() { document.querySelector('#playersZones .other.player[data-player-name="' + target + '"] .points').innerHTML = points; }); + connection.on("GameEnded", function (message) { + yourTurn = false; + ShowEndGameScreen(message); + }); + connection.on("TurnStarted", function () { yourTurn = true; }); From 9505427b6418868f48a232eca5a6e97e2dbcff72 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 28 Jan 2024 11:58:58 +0100 Subject: [PATCH 08/10] update --- backend/MemeBE/Models/Player.cs | 46 +++++++++++++++++++++------------ backend/MemeBE/hubs/GameHub.cs | 5 ++-- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/backend/MemeBE/Models/Player.cs b/backend/MemeBE/Models/Player.cs index 3b6339c..1548b57 100644 --- a/backend/MemeBE/Models/Player.cs +++ b/backend/MemeBE/Models/Player.cs @@ -36,9 +36,11 @@ public Result AddCardToPersistentSlot(Card card) public int PrepareLaugh(int value, out List cardsToDelete) { - cardsToDelete = new List(); int result = value; - foreach (var card in PersistentSlot) + cardsToDelete = new List(); + var cardsCopy = new List(PersistentSlot); + PersistentSlot.Clear(); + foreach (var card in cardsCopy) { foreach (Effect effect in card.EffectList) { @@ -47,6 +49,10 @@ public int PrepareLaugh(int value, out List cardsToDelete) result += effect.Value; cardsToDelete.Add(card.DeckId); } + else + { + PersistentSlot.Add(card); + } } } @@ -55,9 +61,9 @@ public int PrepareLaugh(int value, out List cardsToDelete) return result; } - public void ReceiveLaugh(int laughValue,out List cardsToDelete) + public int PrepareGrumpy(int value, out List cardsToDelete) { - var laughReceived = laughValue; + int result = value; cardsToDelete = new List(); var cardsCopy = new List(PersistentSlot); PersistentSlot.Clear(); @@ -65,42 +71,48 @@ public void ReceiveLaugh(int laughValue,out List cardsToDelete) { foreach (Effect effect in card.EffectList) { - if (effect.EffectName.Equals("Shield")) + if (effect.EffectName.Equals("Buff")) { - Console.WriteLine("Shiled used laugh"); - laughReceived -= effect.Value; + result += effect.Value; cardsToDelete.Add(card.DeckId); } else { PersistentSlot.Add(card); } - + } } - laughReceived = laughReceived < 0 ? 0 : laughReceived; - LaughPoints += laughReceived; + return result; } - public int PrepareGrumpy(int value, out List cardsToDelete) + public void ReceiveLaugh(int laughValue,out List cardsToDelete) { - int result = value; + var laughReceived = laughValue; cardsToDelete = new List(); - foreach (var card in PersistentSlot) + var cardsCopy = new List(PersistentSlot); + PersistentSlot.Clear(); + foreach (var card in cardsCopy) { foreach (Effect effect in card.EffectList) { - if (effect.EffectName.Equals("Buff")) + if (effect.EffectName.Equals("Shield")) { - result += effect.Value; + Console.WriteLine("Shiled used laugh"); + laughReceived -= effect.Value; cardsToDelete.Add(card.DeckId); } + else + { + PersistentSlot.Add(card); + } } } - - return result; + laughReceived = laughReceived < 0 ? 0 : laughReceived; + LaughPoints += laughReceived; + } public void ReceiveGrumpy(int grumpyValue,out List cardsToDelete) diff --git a/backend/MemeBE/hubs/GameHub.cs b/backend/MemeBE/hubs/GameHub.cs index bb8fab5..65b159c 100644 --- a/backend/MemeBE/hubs/GameHub.cs +++ b/backend/MemeBE/hubs/GameHub.cs @@ -340,7 +340,7 @@ public async Task MakeGrumpy(Room room, int value, string? targetNick = null) Console.WriteLine("MakeGrumpy - To All"); foreach (var player in room.Players.Values) { - Console.WriteLine("Player " +player.Nick +" is gone take laugh: " + grumpyValue); + Console.WriteLine("Player " +player.Nick +" is gone take grumpy: " + grumpyValue); player.ReceiveGrumpy(grumpyValue, out List cardsToDeleteFromShieldBuff); // Emit await Clients.Client(player.ConnectionID).SendAsync("TakeGrumpy",player.LaughPoints); @@ -359,8 +359,7 @@ await Clients.Group(room.RoomId) } else // Single player { - Console.WriteLine("MakeGrumpy - To: " + targetNick); - Console.WriteLine("Player " +targetNick +" is gone take laugh: " + grumpyValue); + Console.WriteLine("Player " +targetNick +" is gone take grumpy " + grumpyValue); var targetPlayer = room.GetPlayerByNick(targetNick); targetPlayer.ReceiveGrumpy(grumpyValue,out List cardsToDeleteFromShieldBuff); // emit From 5304365d78607e44f827a72ed668edb4534c6e69 Mon Sep 17 00:00:00 2001 From: pmadry Date: Sun, 28 Jan 2024 12:04:10 +0100 Subject: [PATCH 09/10] lst card --- client/static/css/style.css | 5 +++++ client/static/js/main.js | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/client/static/css/style.css b/client/static/css/style.css index a728eb4..3c81784 100644 --- a/client/static/css/style.css +++ b/client/static/css/style.css @@ -155,6 +155,11 @@ body { width: 250px; } +.middle #lastCard img { + width: 200px; + margin: 25px; +} + .middle .lastMessage { flex-grow: 1; display: flex; diff --git a/client/static/js/main.js b/client/static/js/main.js index ce33a99..658c045 100644 --- a/client/static/js/main.js +++ b/client/static/js/main.js @@ -126,6 +126,10 @@ function initReceiveMethods() { ShowEndGameScreen(message); }); + connection.on("LastCard", function (url) { + ShowLastPlayedCard(url); + }); + connection.on("TurnStarted", function () { yourTurn = true; }); @@ -296,6 +300,13 @@ function PlacePersistentCard(deckId, url, target, owner) { } } +function ShowLastPlayedCard(url){ + let card = CreateCard('', url, ''); + + document.querySelector('#lastCard').innerHTML = card.innerHTML; + +} + function RemoveCard(deckId, handOnly) { if(handOnly){ $("#playerHand .card[data-deck-id='" + deckId + "']").remove(); From bb7cfeb51d0e9022b277558bfbc20727c41b24ad Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 28 Jan 2024 12:04:25 +0100 Subject: [PATCH 10/10] add show last card --- backend/MemeBE/hubs/GameHub.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/MemeBE/hubs/GameHub.cs b/backend/MemeBE/hubs/GameHub.cs index 65b159c..5681aac 100644 --- a/backend/MemeBE/hubs/GameHub.cs +++ b/backend/MemeBE/hubs/GameHub.cs @@ -151,6 +151,7 @@ public async Task SendCard(int cardId, string targetNick) // tutaj jest aktywny gracz w odpowiednim pokoju // Wyliczanie akcjki var activeCard = room.ActivePlayer.CardsOnHand.SingleOrDefault(card => card.DeckId == cardId); + Clients.Group(room.RoomId).SendAsync("LastCard", activeCard.URL); foreach (var effect in activeCard.EffectList) {