From 8352507a1c074ae708cf22a88a14e21688712f4f Mon Sep 17 00:00:00 2001 From: parasoc Date: Thu, 2 Feb 2023 12:41:52 +0100 Subject: [PATCH] Additional button for non-participating members (e.g. Scrum Masters) --- Dockerfile | 28 ++++---- PlanningPoker.Web/Game/GameInstance.cs | 6 ++ PlanningPoker.Web/Game/Player.cs | 2 + PlanningPoker.Web/Pages/Game.razor | 69 ++++++++++++------- PlanningPoker.Web/PlanningPoker.Web.csproj | 2 +- PlanningPoker.Web/ViewModels/GameViewModel.cs | 5 ++ 6 files changed, 72 insertions(+), 40 deletions(-) diff --git a/Dockerfile b/Dockerfile index 432d0e2..23b26e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,14 @@ -FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base -WORKDIR /app -EXPOSE 5000 - -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build -WORKDIR /src -COPY . . -WORKDIR "/src/PlanningPoker.Web" -RUN dotnet publish "PlanningPoker.Web.csproj" -c Release -o /app/publish - -FROM base AS final -WORKDIR /app -COPY --from=build /app/publish . -ENTRYPOINT ["dotnet", "PlanningPoker.Web.dll"] +FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base +WORKDIR /app +EXPOSE 5000 + +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +WORKDIR /src +COPY . . +WORKDIR "/src/PlanningPoker.Web" +RUN dotnet publish "PlanningPoker.Web.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=build /app/publish . +ENTRYPOINT ["dotnet", "PlanningPoker.Web.dll"] diff --git a/PlanningPoker.Web/Game/GameInstance.cs b/PlanningPoker.Web/Game/GameInstance.cs index a97b9e4..2a8f0dc 100644 --- a/PlanningPoker.Web/Game/GameInstance.cs +++ b/PlanningPoker.Web/Game/GameInstance.cs @@ -44,6 +44,12 @@ internal void Join(Player player) this.RaiseChanged(); } + internal void AllowVote(Player player, bool canVote = true) + { + player.HasCards = canVote; + this.RaiseChanged(); + } + private void RaiseChanged() { this.Changed?.Invoke(this, EventArgs.Empty); diff --git a/PlanningPoker.Web/Game/Player.cs b/PlanningPoker.Web/Game/Player.cs index afe02dc..fa7500c 100644 --- a/PlanningPoker.Web/Game/Player.cs +++ b/PlanningPoker.Web/Game/Player.cs @@ -8,6 +8,8 @@ public class Player : IEquatable public string Name { get; set; } public Guid Secret { get; set; } + public bool HasCards { get; set; } = true; + public bool Equals([AllowNull] Player other) { if (other is null) diff --git a/PlanningPoker.Web/Pages/Game.razor b/PlanningPoker.Web/Pages/Game.razor index bb67e05..70bd6e5 100644 --- a/PlanningPoker.Web/Pages/Game.razor +++ b/PlanningPoker.Web/Pages/Game.razor @@ -27,6 +27,15 @@ + @if (this.Player != null) + { +
+
+ + +
+
+ } } @@ -42,22 +51,29 @@
- @if (this.Game.CurrentRound.Cards.ContainsKey(player) == true) + @if (player.HasCards == true) { - if (this.Game.CurrentRound.IsRevealed == true) + if (this.Game.CurrentRound.Cards.ContainsKey(player) == true) { -
- @this.Game.CurrentRound.Cards[player] -
+ if (this.Game.CurrentRound.IsRevealed == true) + { +
+ @this.Game.CurrentRound.Cards[player] +
+ } + else + { + @:🃏 + } } else { - @:🃏 + @:❌ } } else { - @:❌ + @:👑 }
@@ -66,26 +82,29 @@ } -
-
- @if (this.Game != null && this.Game.CurrentRound != null && this.Game.CurrentRound.IsRevealed == false && this.Player != null) - { - @foreach (var card in this.Game.CardDeck) + @if (this.Player != null && this.Player.HasCards == true) + { +
+
+ @if (this.Game != null && this.Game.CurrentRound != null && this.Game.CurrentRound.IsRevealed == false && this.Player != null) { - + } + + } } - } +
-
+ }
\ No newline at end of file diff --git a/PlanningPoker.Web/PlanningPoker.Web.csproj b/PlanningPoker.Web/PlanningPoker.Web.csproj index 615adf0..1b95ad3 100644 --- a/PlanningPoker.Web/PlanningPoker.Web.csproj +++ b/PlanningPoker.Web/PlanningPoker.Web.csproj @@ -8,7 +8,7 @@ - net6.0 + net7.0 diff --git a/PlanningPoker.Web/ViewModels/GameViewModel.cs b/PlanningPoker.Web/ViewModels/GameViewModel.cs index 8fa6fa5..92ca647 100644 --- a/PlanningPoker.Web/ViewModels/GameViewModel.cs +++ b/PlanningPoker.Web/ViewModels/GameViewModel.cs @@ -119,6 +119,11 @@ protected async Task NameChanged(ChangeEventArgs e) await this.LocalStorage.SetItemAsync(nameof(this.Player), this.Player); } + protected void HasCardsChanged(ChangeEventArgs e) + { + this.Game.AllowVote(this.Player, (bool)e.Value); + } + private void Game_Changed(object sender, EventArgs e) { _ = this.InvokeAsync(() => this.StateHasChanged());