Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ on:
branches: [ "main" ]
workflow_dispatch:

permissions:
id-token: write
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 10.0.x
- name: Restore dependencies
run: dotnet restore Homestead
- name: Build
Expand All @@ -30,7 +34,7 @@ jobs:
- name: Publish
run: dotnet publish Homestead/Server/Homestead.Server.csproj -c Release -o website
- name: Upload a Build Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: website
path: website/**
Expand All @@ -42,14 +46,22 @@ jobs:

steps:
- name: Download a Build Artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: website
path: website
- name: Azure Login
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Deploy to Azure
uses: azure/webapps-deploy@v2
uses: azure/webapps-deploy@v3
with:
app-name: HomesteadGame
publish-profile: ${{ secrets.azureWebAppPublishProfile }}
package: website
- name: logout
run: |
az logout

10 changes: 5 additions & 5 deletions Homestead/Client/Homestead.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand All @@ -11,10 +11,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.11" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.0" />
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="10.0.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="10.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Homestead/Client/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@

protected override async Task OnInitializedAsync()
{
Lobby.PlayerId = await localStorage.GetItemAsync<string>("PlayerId");
Lobby.PlayerId = await localStorage.GetItemAsync<string>("PlayerId") ?? string.Empty;
if (string.IsNullOrEmpty(Lobby.PlayerId))
{
Lobby.PlayerId = Guid.NewGuid().ToString();
Expand Down
10 changes: 5 additions & 5 deletions Homestead/Homestead.Client.Tests/Homestead.Client.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="MSTest.TestAdapter" Version="4.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="4.0.2" />
<PackageReference Include="coverlet.collector" Version="6.0.4" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion Homestead/Homestead.Client.Tests/Usings.cs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
global using Microsoft.VisualStudio.TestTools.UnitTesting;
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]
41 changes: 20 additions & 21 deletions Homestead/Homestead.Shared.Tests/GameEngineTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using NuGet.Frameworks;


namespace Homestead.Shared.Tests
{
[TestClass]
Expand Down Expand Up @@ -70,7 +69,7 @@ public void DrawFromDiscardTest()
game = engine.ProcessAction(game, action);
Assert.IsFalse(game.DiscardPile.Any());
Assert.IsTrue(game.Players[game.ActivePlayer].Hand.Any());
Assert.IsTrue(game.Players[game.ActivePlayer].Hand[0] is Cards.Well);
Assert.AreEqual(Cards.Well, game.Players[game.ActivePlayer].Hand[0]);

Assert.IsFalse(game.AvailableActions.Any(a => a.Type is PlayerAction.ActionType.DrawFromDeck));
Assert.IsFalse(game.AvailableActions.Any(a => a.Type is PlayerAction.ActionType.DrawFromDiscard));
Expand All @@ -97,11 +96,11 @@ public void DrawFromDiscardWhenMultipleOfSameTypeExist()

game = engine.ProcessAction(game, action);
Assert.IsTrue(game.Players[game.ActivePlayer].Hand.Any());
Assert.IsTrue(game.Players[game.ActivePlayer].Hand[0] is Cards.Well);
Assert.AreEqual(Cards.Well, game.Players[game.ActivePlayer].Hand[0]);

Assert.IsTrue(game.DiscardPile.Any());
Assert.IsTrue(game.DiscardPile.First() is Cards.Well);
Assert.IsTrue(game.DiscardPile.Last() is Cards.Wood);
Assert.AreEqual(Cards.Well, game.DiscardPile.First());
Assert.AreEqual(Cards.Wood, game.DiscardPile.Last());
}

// Draw from discard with no discard
Expand Down Expand Up @@ -130,7 +129,7 @@ public void PlayCardWithoutCardInHandThrowsKeyNotFound()
PlayerAction action = new(PlayerAction.ActionType.Play, game.ActivePlayer);
action.PlayerCard = Cards.Well;

Assert.ThrowsException<KeyNotFoundException>(() => engine.ProcessAction(game, action));
Assert.Throws<KeyNotFoundException>(() => engine.ProcessAction(game, action));
}

// Active Player reverts to 1 after 4
Expand All @@ -152,13 +151,13 @@ public void PlayCardGiveCard()
action.TargetCard = Cards.Well;
//action.PlayerCard = "Give";

Assert.AreEqual(2, game.Players[game.ActivePlayer].Hand.Count);
Assert.AreEqual(0, game.Players[2].Hand.Count);
Assert.HasCount(2, game.Players[game.ActivePlayer].Hand);
Assert.IsEmpty(game.Players[2].Hand);

game = engine.ProcessAction(game, action);

Assert.AreEqual(0, game.Players[game.ActivePlayer].Hand.Count);
Assert.AreEqual(1, game.Players[2].Hand.Count);
Assert.IsEmpty(game.Players[game.ActivePlayer].Hand);
Assert.HasCount(1, game.Players[2].Hand);
}

[TestMethod]
Expand All @@ -173,13 +172,13 @@ public void PlayCardGiveCardWithoutAdditionalCardInHand()
PlayerAction action = new(PlayerAction.ActionType.Play, game.ActivePlayer);
action.PlayerCard = Cards.GoodNeighbor;

Assert.AreEqual(1, game.Players[game.ActivePlayer].Hand.Count);
Assert.AreEqual(0, game.Players[2].Hand.Count);
Assert.HasCount(1, game.Players[game.ActivePlayer].Hand);
Assert.IsEmpty(game.Players[2].Hand);

Assert.ThrowsException<NullReferenceException>(() => engine.ProcessAction(game, action));
Assert.Throws<NullReferenceException>(() => engine.ProcessAction(game, action));

Assert.AreEqual(0, game.Players[game.ActivePlayer].Hand.Count);
Assert.AreEqual(0, game.Players[2].Hand.Count);
Assert.IsEmpty(game.Players[game.ActivePlayer].Hand);
Assert.IsEmpty(game.Players[2].Hand);
}

[TestMethod]
Expand All @@ -198,13 +197,13 @@ public void PlayCardStealCard()
action.TargetCard = Cards.Well;
//action.PlayerCard = "Give";

Assert.AreEqual(1, game.Players[game.ActivePlayer].Hand.Count);
Assert.AreEqual(1, game.Players[2].Hand.Count);
Assert.HasCount(1, game.Players[game.ActivePlayer].Hand);
Assert.HasCount(1, game.Players[2].Hand);

game = engine.ProcessAction(game, action);

Assert.AreEqual(1, game.Players[game.ActivePlayer].Hand.Count);
Assert.AreEqual(0, game.Players[2].Hand.Count);
Assert.HasCount(1, game.Players[game.ActivePlayer].Hand);
Assert.IsEmpty(game.Players[2].Hand);
}

// Player cannot draw two cards from deck
Expand Down Expand Up @@ -243,7 +242,7 @@ public void Wolves()
PlayerAction action = new(PlayerAction.ActionType.Play, game.ActivePlayer, Cards.WolfAll);

game = engine.ProcessAction(game, action);
Assert.AreEqual(4, game.AvailableActions.Count);
Assert.HasCount(4, game.AvailableActions);
Assert.IsTrue(game.AvailableActions.All(a => a.Type is PlayerAction.ActionType.Discard));
}

Expand Down
9 changes: 5 additions & 4 deletions Homestead/Homestead.Shared.Tests/GameLookupTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ namespace Homestead.Shared.Tests
[TestClass]
public class GameLookupTest
{
GameLookup _lookup { get; set; }
GameLookupTest(GameLookup lookup)
GameLookup _lookup { get; set; } = new GameLookup();

[TestInitialize]
public void Initialize()
{
_lookup = lookup;
_lookup = new GameLookup();
}
[TestInitialize]

[TestMethod]
public void addGame()
Expand Down
4 changes: 2 additions & 2 deletions Homestead/Homestead.Shared.Tests/GameTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public void CreateGame()
GameEngineWithActions engine = new();
Game game = engine.Start("test");

Assert.AreEqual(4, game.Players.Count);
Assert.IsTrue(game.Players[3].Name != null);
Assert.HasCount(4, game.Players);
Assert.IsNotNull(game.Players[3].Name);
}
}
}
10 changes: 5 additions & 5 deletions Homestead/Homestead.Shared.Tests/Homestead.Shared.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="MSTest.TestAdapter" Version="4.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="4.0.2" />
<PackageReference Include="coverlet.collector" Version="6.0.4" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion Homestead/Homestead.Shared.Tests/Usings.cs
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
global using Microsoft.VisualStudio.TestTools.UnitTesting;
global using Microsoft.VisualStudio.TestTools.UnitTesting;

[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]
8 changes: 4 additions & 4 deletions Homestead/Server/Homestead.Server.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="6.0.11" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="10.0.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Homestead/Shared/Actions/ActionPlayCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private void DoDisaster(string card, int? targetPlayer)
CurrentPlayer.Hand.Remove(card);
}

private bool RemoveCardsBasedOnDisaster(int playerNumber, string impactedCard, string preventionCard)
private bool RemoveCardsBasedOnDisaster(int playerNumber, string impactedCard, string? preventionCard)
{
if (preventionCard==null || !RemoveCardFromPlayersHand(playerNumber, preventionCard))
{
Expand Down
1 change: 0 additions & 1 deletion Homestead/Shared/Cards.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public static class Cards
static Cards()
{
int extreme = 20;
int tons = 15;
int lots = 10;
int some = 2;
int few = 1;
Expand Down
4 changes: 2 additions & 2 deletions Homestead/Shared/Homestead.Shared.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="10.0.2" />
<PackageReference Include="RandomNameGeneratorLibrary" Version="1.2.2" />
</ItemGroup>

Expand Down