Skip to content

Commit

Permalink
Starting to integrate Spectre
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegerMan committed Apr 19, 2024
1 parent 4bc21a3 commit 9df203e
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 40 deletions.
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"robbowen.synthwave-vscode"
]
}
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": []
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using MattEland.WhereDoggo.Core.Engine.Phases;
using MattEland.WhereDoggo.Core.Events;
using MattEland.WhereDoggo.Core.Events;
using Spectre.Console;

namespace MattEland.WhereDoggo.WhereDoggoConsole;

Expand Down Expand Up @@ -28,13 +28,13 @@ public static List<GameEventBase> FindEventsForPhase(this Game game, string phas

public static void DisplayNightActions(this Game game)
{
Console.WriteLine("During the Night:");
AnsiConsole.MarkupLine("During the [Cyan]Night[/]:");
List<GameEventBase> events = game.FindEventsForPhase("Night");
foreach (GameEventBase e in events)
{
Console.WriteLine($"\t{e}");
AnsiConsole.WriteLine($"\t{e}");
}
Console.WriteLine();
AnsiConsole.WriteLine();
}

public static void DisplayPlayerKnowledge(this Game game, bool includeProbabilities)
Expand All @@ -48,40 +48,40 @@ public static void DisplayPlayerKnowledge(this Game game, bool includeProbabilit
continue;
}

Console.WriteLine($"{player.Name} Assumed Probabilities:");
AnsiConsole.MarkupLine($"[Orange1]{player.Name}[/] Assumed Probabilities:");

IDictionary<IHasCard, CardProbabilities> probabilities = player.Brain.BuildFinalRoleProbabilities();

foreach (KeyValuePair<IHasCard, CardProbabilities> kvp in probabilities)
{
Console.WriteLine($"\t{kvp.Key.Name} probabilities ({kvp.Value})");
AnsiConsole.WriteLine($"\t{kvp.Key.Name} probabilities ({kvp.Value})");
}

Console.WriteLine();
AnsiConsole.WriteLine();
}
}

public static void DisplayPlayerKnowledge(this GamePlayer player)
{
Console.WriteLine(player.Name + " knows:");
AnsiConsole.MarkupLine($"[Orange1]{player.Name}[/] knows:");

foreach (GameEventBase @event in player.Events)
{
Console.WriteLine($"\t{@event}");
AnsiConsole.WriteLine($"\t{@event}");
}

Console.WriteLine();
AnsiConsole.WriteLine();
}

public static void DisplayAllEvents(this Game game)
{
Console.WriteLine("All Game Events:");
AnsiConsole.WriteLine("All Game Events:");

foreach (GameEventBase @event in game.Events)
{
Console.WriteLine($"\t{@event}");
AnsiConsole.WriteLine($"\t{@event}");
}

Console.WriteLine();
AnsiConsole.WriteLine();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
<ProjectReference Include="..\MattEland.Util\MattEland.Util.csproj" />
<ProjectReference Include="..\MattEland.WhereDoggo.Core\MattEland.WhereDoggo.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Spectre.Console" Version="0.48.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using MattEland.WhereDoggo.Core.Engine.Phases;
using MattEland.WhereDoggo.Core.Roles;
using Spectre.Console;

static GameResult RunAndShowGame(bool showUi)
{
Expand All @@ -17,35 +18,34 @@ static GameResult RunAndShowGame(bool showUi)

if (showUi)
{
Console.WriteLine($"Starting a new game of \"{game.Name}\"");
Console.WriteLine();
AnsiConsole.MarkupLine($"Starting a new game of [Yellow]{game.Name}[/]");
AnsiConsole.WriteLine();
}

GamePhaseBase phase = game.CurrentPhase;
GamePhaseBase phase;
while (!game.RunNextPhase())
{
phase = game.CurrentPhase;

if (!showUi) continue;

if (showUi)
if (phase.Name == "Night")
{
if (phase.Name == "Night")
{
game.DisplayNightActions();
}
game.DisplayNightActions();
}

if (phase.Name != "Day")
{
Console.WriteLine($"After {phase} Phase...");
game.DisplayGameState();
}
else
{
game.DisplayPlayerKnowledge(includeProbabilities: true);
}
if (phase.Name != "Day")
{
AnsiConsole.MarkupLine($"After [Cyan]{phase}[/]...");
game.DisplayGameState();
}
else
{
game.DisplayPlayerKnowledge(includeProbabilities: true);
}
}

// Log all game events
// Log all game events
if (showUi)
{
game.DisplayAllEvents();
Expand All @@ -72,4 +72,4 @@ static GameResult RunAndShowGame(bool showUi)
}
}

Console.WriteLine($"After {numRuns} runs, there were {villageWins} village wins and {wolfWins} wolf wins.");
AnsiConsole.MarkupLine($"After [Yellow]{numRuns}[/] runs, there were [Blue]{villageWins} village wins[/] and [Red]{wolfWins} wolf team[/] wins.");
6 changes: 0 additions & 6 deletions MattEland.WhereDoggo/MattEland.WhereDoggo.sln
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MattEland.WhereDoggo.Core.T
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MattEland.Util", "MattEland.Util\MattEland.Util.csproj", "{A59B7B80-B3B6-4771-9740-491921257ACB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MattEland.WhereDoggo.WPFClient", "MattEland.WhereDoggo.WPFClient\MattEland.WhereDoggo.WPFClient.csproj", "{6A029BA6-6587-49D1-A7E1-F0580FE3DD7A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -42,10 +40,6 @@ Global
{A59B7B80-B3B6-4771-9740-491921257ACB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A59B7B80-B3B6-4771-9740-491921257ACB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A59B7B80-B3B6-4771-9740-491921257ACB}.Release|Any CPU.Build.0 = Release|Any CPU
{6A029BA6-6587-49D1-A7E1-F0580FE3DD7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6A029BA6-6587-49D1-A7E1-F0580FE3DD7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6A029BA6-6587-49D1-A7E1-F0580FE3DD7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6A029BA6-6587-49D1-A7E1-F0580FE3DD7A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit 9df203e

Please sign in to comment.