ze poker hand checker

This commit is contained in:
Gardient
2016-07-01 00:31:12 +03:00
committed by Petrutiu Mihai
parent 0a6d290c3e
commit b5997ced99
34 changed files with 612 additions and 183 deletions

View File

@@ -0,0 +1,22 @@
using System.Linq;
namespace ChainOfResponssibility.Poker.Validators.HandValidators
{
public class StraightValidation : HandValidation
{
protected override string IsValid(Card[] hand)
{
var Value2Index = hand.Select((i, j) => i.GetIntValue() - j).Distinct();
if (!Value2Index.Skip(1).Any())// consecutive
return "You have a Straight with " + string.Join(", ", hand.Select(x => x.ToString()));
//special case for A,2,3,4,5
if (Value2Index.Count() == 2
&& Value2Index.First() == 2//for 2,3,4,5
&& Value2Index.Last() == 10)//for A
return "You have a Straight with " + string.Join(", ", hand.Select(x => x.ToString()));
return string.Empty;
}
}
}