Skip to content

Commit

Permalink
Documentation/Code-Clean-up: cleaned up the project and and updated R…
Browse files Browse the repository at this point in the history
…EADME and INSTRUCTIONS documentation
  • Loading branch information
vaananart committed Jan 6, 2021
1 parent 3a6144c commit f12ffe5
Show file tree
Hide file tree
Showing 59 changed files with 718 additions and 130 deletions.
Binary file added INSTRUCTIONS.md
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@

using PokerHandDomainModels;

namespace AppFramework.Services
namespace GameFramework.Services
{
/// <summary>
/// The purpose of this interface is to use later in Dependency Injection
/// for web app/service. The interface helps to keeps the user of the interface and
/// the implementation loosely coupled. We can have different Game rule service for
/// different games.
/// </summary>
public interface IGameService
{
GameModel SetupMatch(string matchInput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>X:\digital-CV\Argenti\argenti-repository\argenti-cloud-poker-hand-sorter\PokerHandSorterConsoleApp\output\</OutputPath>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\PokerHanderSorterService\AppServices.csproj" />
<ProjectReference Include="..\PokerHanderSorterService\GameServices.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using System.Collections.Generic;
using System.Linq;

using PokerHanderSorterService;
using GameService;

namespace PokerHandSorterConsoleApp
namespace PokerHandConsole
{
class Program
{
Expand All @@ -25,7 +25,7 @@ static void Main(string[] args)
} while ( noNewLines != true );


var gameService = new GameService(inputs.ToArray());
var gameService = new PokerHandService(inputs.ToArray());
var gamesReport = gameService.ExecuteAllGamesAndProcessReport();

Console.WriteLine("Player 1: " + gamesReport.Player1WonTotal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,44 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30804.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PokerHandSorterConsoleApp", "PokerHandSorterConsoleApp\PokerHandSorterConsoleApp.csproj", "{82FB2456-091E-43E2-8C3A-023A7C9F10AA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AppServices", "PokerHanderSorterService\AppServices.csproj", "{F69F2713-5791-42A6-B850-F40CE612738C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GameServices", "PokerHanderSorterService\GameServices.csproj", "{F69F2713-5791-42A6-B850-F40CE612738C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PokerHandSorterServiceTests", "PokerHandSorterServiceTests\PokerHandSorterServiceTests.csproj", "{199FF6FD-05A3-4046-BB78-4F72A84BFE9A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PokerHandDomainModels", "PokerHandDomain\PokerHandDomainModels.csproj", "{0C1F6175-BC7D-43A4-8295-50B7355F92AF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PokerHandLogicHandlers", "PokerHandLogicHandler\PokerHandLogicHandlers.csproj", "{ADE26051-852B-44EC-AAD3-9F7F689E0220}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PokerHandLogicRuleHandlers", "PokerHandLogicHandler\PokerHandLogicRuleHandlers.csproj", "{ADE26051-852B-44EC-AAD3-9F7F689E0220}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{F1697E6C-9248-4530-8CD6-97963E74A3B4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PokerHandLogicHandlersTests", "PokerHandLogicHandlerTests\PokerHandLogicHandlersTests.csproj", "{17BB428B-CF9F-4180-B4F8-45523599E9EB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PokerHandDomainModels.Extensions", "PokerHandDomainModels.Extensions\PokerHandDomainModels.Extensions.csproj", "{9AA5813D-9FDC-4157-9FCB-224DBCD8E7C4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PokerHandDomainModels.Extensions", "PokerHandDomainModels.Extensions\PokerHandDomainModels.Extensions.csproj", "{9AA5813D-9FDC-4157-9FCB-224DBCD8E7C4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Interfaces", "Interfaces", "{28B1A074-245B-4D37-B269-88BCA51C84DF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Implementations", "Implementations", "{F19BAA81-46CD-4736-8AE3-2E62B93C723E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppFramework", "AppFramework\AppFramework.csproj", "{9267CA39-E75E-4AA1-BB47-B236A0672BE4}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GameModels", "GameModels", "{D4555EBA-DE48-4BC2-A173-01F92CC09079}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PokerHand", "PokerHand", "{BA5E61AE-7917-4AF8-9F56-505EBD8A44EF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PokerHand", "PokerHand", "{B14EF8D3-E4CF-4296-B462-1B21B64DF1C6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GameRules", "GameRules", "{EABBA59C-09F4-48D1-9C37-8F20E0C93992}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PokerHand", "PokerHand", "{2240E6A7-3D12-45AD-9262-B2BA7AD8DEEE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GameFramework", "GameFramework\GameFramework.csproj", "{FCFBE5D4-8ADC-4498-AEB6-454FE4EE3B0E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PokerHandConsole", "PokerHandConsoleApp\PokerHandConsole.csproj", "{33AA77B7-6070-4D3C-9D28-0A865918AEA7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{82FB2456-091E-43E2-8C3A-023A7C9F10AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{82FB2456-091E-43E2-8C3A-023A7C9F10AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{82FB2456-091E-43E2-8C3A-023A7C9F10AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{82FB2456-091E-43E2-8C3A-023A7C9F10AA}.Release|Any CPU.Build.0 = Release|Any CPU
{F69F2713-5791-42A6-B850-F40CE612738C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F69F2713-5791-42A6-B850-F40CE612738C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F69F2713-5791-42A6-B850-F40CE612738C}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -59,19 +65,29 @@ Global
{9AA5813D-9FDC-4157-9FCB-224DBCD8E7C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9AA5813D-9FDC-4157-9FCB-224DBCD8E7C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9AA5813D-9FDC-4157-9FCB-224DBCD8E7C4}.Release|Any CPU.Build.0 = Release|Any CPU
{9267CA39-E75E-4AA1-BB47-B236A0672BE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9267CA39-E75E-4AA1-BB47-B236A0672BE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9267CA39-E75E-4AA1-BB47-B236A0672BE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9267CA39-E75E-4AA1-BB47-B236A0672BE4}.Release|Any CPU.Build.0 = Release|Any CPU
{FCFBE5D4-8ADC-4498-AEB6-454FE4EE3B0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FCFBE5D4-8ADC-4498-AEB6-454FE4EE3B0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FCFBE5D4-8ADC-4498-AEB6-454FE4EE3B0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FCFBE5D4-8ADC-4498-AEB6-454FE4EE3B0E}.Release|Any CPU.Build.0 = Release|Any CPU
{33AA77B7-6070-4D3C-9D28-0A865918AEA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33AA77B7-6070-4D3C-9D28-0A865918AEA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33AA77B7-6070-4D3C-9D28-0A865918AEA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33AA77B7-6070-4D3C-9D28-0A865918AEA7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{F69F2713-5791-42A6-B850-F40CE612738C} = {F19BAA81-46CD-4736-8AE3-2E62B93C723E}
{199FF6FD-05A3-4046-BB78-4F72A84BFE9A} = {F1697E6C-9248-4530-8CD6-97963E74A3B4}
{17BB428B-CF9F-4180-B4F8-45523599E9EB} = {F1697E6C-9248-4530-8CD6-97963E74A3B4}
{9267CA39-E75E-4AA1-BB47-B236A0672BE4} = {28B1A074-245B-4D37-B269-88BCA51C84DF}
{199FF6FD-05A3-4046-BB78-4F72A84BFE9A} = {B14EF8D3-E4CF-4296-B462-1B21B64DF1C6}
{0C1F6175-BC7D-43A4-8295-50B7355F92AF} = {BA5E61AE-7917-4AF8-9F56-505EBD8A44EF}
{ADE26051-852B-44EC-AAD3-9F7F689E0220} = {2240E6A7-3D12-45AD-9262-B2BA7AD8DEEE}
{17BB428B-CF9F-4180-B4F8-45523599E9EB} = {B14EF8D3-E4CF-4296-B462-1B21B64DF1C6}
{9AA5813D-9FDC-4157-9FCB-224DBCD8E7C4} = {BA5E61AE-7917-4AF8-9F56-505EBD8A44EF}
{BA5E61AE-7917-4AF8-9F56-505EBD8A44EF} = {D4555EBA-DE48-4BC2-A173-01F92CC09079}
{B14EF8D3-E4CF-4296-B462-1B21B64DF1C6} = {F1697E6C-9248-4530-8CD6-97963E74A3B4}
{2240E6A7-3D12-45AD-9262-B2BA7AD8DEEE} = {EABBA59C-09F4-48D1-9C37-8F20E0C93992}
{FCFBE5D4-8ADC-4498-AEB6-454FE4EE3B0E} = {28B1A074-245B-4D37-B269-88BCA51C84DF}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1DDA806A-1A88-432B-84BD-03C8200EF17C}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace PokerHandDomainModels.CardModelVariants
{
/// <summary>
/// This holds the definition of Full House rank.
/// </summary>
public class FullHouseModel
{
public IEnumerable<CardModel> ThreeOfAKind { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

namespace PokerHandDomainModels
{
/// <summary>
/// This model is reponsible to consolidate the winnings after Nth nubmer of poke games.
/// </summary>
public class ConsolidatedWonHandsReportModel
{
public IList<GameModel> Games { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
namespace PokerHandDomainModels.Enums
{
/// <summary>
/// This is used with the numerical valued cards.
/// The special cards need to hold a certain value.
/// This helps to decide in ordering and in processing
/// Straight and Straight Flush ranks.
/// </summary>
public enum SpecialCardEnum
{
T = 10,
Expand Down
5 changes: 5 additions & 0 deletions PokerHandSorterConsoleApp/PokerHandDomain/GameModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

namespace PokerHandDomainModels
{
/// <summary>
/// The model that holds all the relavent dependencies together.
/// It helps to streamline the processing as the state of the
/// game traverses from start to end.
/// </summary>
public class GameModel
{
public PlayerModel Player1 { get; set; }
Expand Down
3 changes: 3 additions & 0 deletions PokerHandSorterConsoleApp/PokerHandDomain/GameWonModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace PokerHandDomainModels
{
/// <summary>
/// Used in reporting the outcome of the game.
/// </summary>
public class GameWonModel
{
public bool Player1_Won { get; set; }
Expand Down
7 changes: 0 additions & 7 deletions PokerHandSorterConsoleApp/PokerHandDomain/PlayerModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,12 @@ public class PlayerModel
public PlayerModel(string cards)
{
var cardString = cards.Split(" ");
if (cardString.Length != 5)
Console.WriteLine("Something happened to data. there is no 5 cards");
this.CardsAtHand = new List<CardModel>();

foreach (string card in cardString)
{
this.CardsAtHand.Add(new CardModel(card));
}
}
public int GetRank()
{
return -1;
}

}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

namespace PokerHandDomainModels.Extensions
{
/// <summary>
/// This extension helps to simplify the coding pattern and clearly
/// under the responsibility of the player since the player holds the cards to
/// determine the ranks in the card collection.
/// </summary>
public static class PlayerModelExtension
{
public static bool HasAFlush(this PlayerModel player)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\PokerHandDomain\PokerHandDomainModels.csproj" />
<ProjectReference Include="..\PokerHandLogicHandler\PokerHandLogicHandlers.csproj" />
<ProjectReference Include="..\PokerHandLogicHandler\PokerHandLogicRuleHandlers.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ namespace PokerHandLogicHandlers
{
internal static class CardsLookupBuilder
{
/// <summary>
/// The method prepares the structure required to lookup the content
/// in the card. At series of cards are passed to make a dictionary
/// lookup to determine the rank cleanly.
/// </summary>
/// <param name="sampleCards"></param>
/// <returns></returns>
public static IDictionary<char, int> Build(IList<CardModel> sampleCards)
{
IDictionary<char, int> cardSummaryLookup = new Dictionary<char, int>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;

using PokerHandDomainModels;
using PokerHandDomainModels.Enums;

namespace PokerHandLogicHandlers.ModelExtensions
{
public static class CardModelExtension
{
/// <summary>
/// I found it a challenge to determine the next high value card.
/// So the CardModel have the responsibility and the ability to tell me
/// what the next high-value card after itself.
/// </summary>
/// <param name="card"></param>
/// <returns></returns>
public static CardModel NextCardInAscOrder(this CardModel card)
{
int convertedValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ namespace PokerHandLogicHandlers.Finders
{
public static class DoublePairFinder
{
/// <summary>
/// The Finder to identify Double Pair rank in the card collection.
/// </summary>
/// <param name="sampleCards"></param>
/// <returns></returns>
public static IEnumerable<CardModel> FindTwoPair(IList<CardModel> sampleCards)
{
IDictionary<char, int> cardSummaryLookup = CardsLookupBuilder.Build(sampleCards);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ namespace PokerHandLogicHandlers.Finders
{
public static class FlushFinder
{
/// <summary>
/// The Finder to identify Flush rank in the card collection.
/// </summary>
/// <param name="sampleCards"></param>
/// <returns></returns>
public static bool IsFlush(IList<CardModel> sampleCards)
{
var initCard = sampleCards[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ namespace PokerHandLogicHandlers.Finders
{
public static class FourOfAKindFinder
{
/// <summary>
/// The Finder to identify Four-of-a-Kind rank in the card collection.
/// </summary>
/// <param name="sampleCards"></param>
/// <returns></returns>
public static IEnumerable<CardModel> FindFourOfAKind(IList<CardModel> sampleCards)
{
IDictionary<char, int> cardSummaryLookup = CardsLookupBuilder.Build(sampleCards);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ namespace PokerHandLogicHandlers.Finders
{
public static class FullHouseFinder
{
/// <summary>
/// The Finder to identify Full House rank in the card collection.
/// </summary>
/// <param name="sampleCards"></param>
/// <returns></returns>
public static FullHouseModel FindFullHouse(IList<CardModel> sampleCards)
{
var threeOfAKing = ThreeOfAKindFinder.FindThreeOfKind(sampleCards);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ namespace PokerHandLogicHandlers.Finders
{
public static class HighestValueFinder
{

/// <summary>
/// The Finder to identify Highest value card in the card collection.
/// </summary>
/// <param name="cards"></param>
/// <returns></returns>
public static CardModel HighestValue(IList<CardModel> cards)
{
CardModel HighestValueCard = new CardModel(null);
Expand Down Expand Up @@ -53,6 +57,12 @@ public static CardModel HighestValue(IList<CardModel> cards)
return new CardModel(HighestValueCard.Value.ToString() + HighestValueCard.Suit);
}

/// <summary>
/// This method will give me the next highest card from the given card reference.
/// </summary>
/// <param name="cards"></param>
/// <param name="givenCard"></param>
/// <returns></returns>
public static CardModel FindTheNextHighCardFromTheGiven(IList<CardModel> cards, CardModel givenCard)
{
var orderedCardsByValue = cards.OrderBy(x => x.Value).ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ namespace PokerHandLogicHandlers.Finders
{
public static class PairFinder
{
/// <summary>
/// The Finder to identify a Pair rank in the card collection.
/// </summary>
/// <param name="sampleCards"></param>
/// <returns></returns>
public static IEnumerable<CardModel> FindAPair(IList<CardModel> sampleCards)
{
IDictionary<char, int> cardSummaryLookup = CardsLookupBuilder.Build(sampleCards);
Expand Down
Loading

0 comments on commit f12ffe5

Please sign in to comment.