From 767189821d0a1673008833cf919b0d6bc9895cb9 Mon Sep 17 00:00:00 2001 From: Martin Berg Alstad <600878@stud.hvl.no> Date: Wed, 19 Jul 2023 16:03:43 +0200 Subject: [PATCH] Players can rejoin when refreshing window, changed Name to UserName --- BackendTests/Services/ActionServiceTests.cs | 10 ++++----- BackendTests/TestUtils/Players.cs | 4 ++-- .../ClientApp/src/components/gameBoard.tsx | 4 ++-- .../src/components/gameComponent.tsx | 6 +++-- .../ClientApp/src/components/playerStats.tsx | 7 +++--- .../ClientApp/src/game/player.ts | 9 ++++---- .../ClientApp/src/pages/home.tsx | 2 +- .../ClientApp/src/types/props.d.ts | 2 +- .../ClientApp/src/utils/actions.ts | 4 ++-- .../ClientApp/src/utils/state.ts | 2 +- pac-man-board-game/GameStuff/Items/Player.cs | 9 ++++---- pac-man-board-game/Services/ActionService.cs | 17 ++++++++++++-- pac-man-board-game/Services/Game.cs | 4 ++-- pac-man-board-game/Services/GameService.cs | 22 ++++++++++++++----- 14 files changed, 64 insertions(+), 38 deletions(-) diff --git a/BackendTests/Services/ActionServiceTests.cs b/BackendTests/Services/ActionServiceTests.cs index 00bb70a..279ec3b 100644 --- a/BackendTests/Services/ActionServiceTests.cs +++ b/BackendTests/Services/ActionServiceTests.cs @@ -165,7 +165,7 @@ public class ActionServiceTests // If selected the state is changed to InGame _whitePlayer.State = State.InGame; var players = result.GetType().GetProperty("Players")?.GetValue(result) as IEnumerable; - Assert.That(players?.First().Name, Is.EqualTo(_whitePlayer.Name)); + Assert.That(players?.First().UserName, Is.EqualTo(_whitePlayer.UserName)); } [Test] @@ -185,7 +185,7 @@ public class ActionServiceTests result = _service.Ready(); var players = result.GetType().GetProperty("Players")?.GetValue(result) as IEnumerable; - Assert.That(players?.First().Name, Is.EqualTo(_blackPlayer.Name).Or.EqualTo(_whitePlayer.Name)); + Assert.That(players?.First().UserName, Is.EqualTo(_blackPlayer.UserName).Or.EqualTo(_whitePlayer.UserName)); } #endregion @@ -208,7 +208,7 @@ public class ActionServiceTests { Players = { _whitePlayer } }; var name = _service.FindNextPlayer(); - Assert.That(name, Is.EqualTo(_whitePlayer.Name)); + Assert.That(name, Is.EqualTo(_whitePlayer.UserName)); } [Test] @@ -222,9 +222,9 @@ public class ActionServiceTests })) { Players = { _whitePlayer, _blackPlayer } }; var first = _service.FindNextPlayer(); - Assert.That(first, Is.EqualTo(_blackPlayer.Name)); + Assert.That(first, Is.EqualTo(_blackPlayer.UserName)); var second = _service.FindNextPlayer(); - Assert.That(second, Is.EqualTo(_whitePlayer.Name)); + Assert.That(second, Is.EqualTo(_whitePlayer.UserName)); } #endregion diff --git a/BackendTests/TestUtils/Players.cs b/BackendTests/TestUtils/Players.cs index 5c68b9f..07e46da 100644 --- a/BackendTests/TestUtils/Players.cs +++ b/BackendTests/TestUtils/Players.cs @@ -8,7 +8,7 @@ internal static class Players internal static IPlayer Create(string colour) => new Player { - Name = colour, + UserName = colour, Colour = colour, PacMan = CreatePacMan(colour), Box = CreateBox(colour) @@ -33,7 +33,7 @@ internal static class Players { Box = player.Box, Colour = player.Colour, - Name = player.Name, + UserName = player.UserName, PacMan = player.PacMan }; } diff --git a/pac-man-board-game/ClientApp/src/components/gameBoard.tsx b/pac-man-board-game/ClientApp/src/components/gameBoard.tsx index 5f888db..c6b6092 100644 --- a/pac-man-board-game/ClientApp/src/components/gameBoard.tsx +++ b/pac-man-board-game/ClientApp/src/components/gameBoard.tsx @@ -181,8 +181,8 @@ const SelectPlayerModal: Component = () => { { allPlayers.map(player => -
- {player.Name} has {player.Box.count} pellets +
+ {player.UserName} has {player.Box.count} pellets