private string FaceToString(CardFace cardFace) { string result; if (this.Face <= CardFace.Ten) { result = ((int)this.Face).ToString(); } else { switch (this.Face) { case CardFace.Jack: result = "J"; break; case CardFace.Queen: result = "Q"; break; case CardFace.King: result = "K"; break; case CardFace.Ace: result = "A"; break; default: throw new ArgumentException("CardFace", "Card face in invalid."); } } return result; }
/////////////////////////////////////////////////////////////////////////////////////// // Constructors /////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Construct a new card /// </summary> /// <param name="theColor"></param> /// <param name="theFace"></param> public Card(CardColor theColor, CardFace theFace) { // Check the card is value, otherwise throw a runtime error if (!IsValidCard(theColor, theFace)) throw new Exception(CardColorToString(theColor) + " " + CardFaceToString(theFace) + " is not a valid Uno card"); // Save parameters in private attributes color = theColor; face = theFace; }
public Card(Image sourceImage, CardFace face) { SourceImage = sourceImage; Face = face; SourceImage.Projection = Projection; SourceImage.Width = 200; SourceImage.Height = 300; SetImage("Back.png"); Storyboard.SetTarget(FlipAnimation, Projection); Storyboard.SetTargetProperty(FlipAnimation, "RotationY"); FlipStoryboard.Children.Add(FlipAnimation); }
public static void AddEachColor(List<NumberCard> ec, CardFace cf, int amt, bool super) { while (amt > 0) { ec.Add(new NumberCard(CardColor.Red, cf)); ec.Add(new NumberCard(CardColor.Green, cf)); ec.Add(new NumberCard(CardColor.Yellow, cf)); ec.Add(new NumberCard(CardColor.Blue, cf)); if (super) { ec.Add(new NumberCard(CardColor.Orange, cf)); ec.Add(new NumberCard(CardColor.Purple, cf)); } amt--; } }
private static string CardFaceToString(CardFace cardFace) { string result; switch (cardFace) { case CardFace.Two: result = "2"; break; case CardFace.Three: result = "3"; break; case CardFace.Four: result = "4"; break; case CardFace.Five: result = "5"; break; case CardFace.Six: result = "6"; break; case CardFace.Seven: result = "7"; break; case CardFace.Eight: result = "8"; break; case CardFace.Nine: result = "9"; break; case CardFace.Ten: result = "10"; break; case CardFace.Jack: result = "J"; break; case CardFace.Queen: result = "Q"; break; case CardFace.King: result = "K"; break; case CardFace.Ace: result = "A"; break; default: throw new ArgumentException(string.Format("Invalid value for card face : '{0}'.", cardFace)); } return result; }
private string CheckCardFace(CardFace cardFace) { string result = ""; if ((int)cardFace <= 10) { return result = ((int)cardFace).ToString(); } else { string cardName = cardFace.ToString(); char firstLetter = cardName[0]; return result = firstLetter.ToString(); } }
public static string FaceToString(CardFace cardType) { string cardTypeAsString = null; switch (cardType) { case CardFace.Ace: cardTypeAsString = "A"; break; case CardFace.King: cardTypeAsString = "K"; break; case CardFace.Queen: cardTypeAsString = "Q"; break; case CardFace.Jack: cardTypeAsString = "J"; break; case CardFace.Ten: cardTypeAsString = "10"; break; case CardFace.Nine: cardTypeAsString = "9"; break; case CardFace.Eight: cardTypeAsString = "8"; break; case CardFace.Seven: cardTypeAsString = "7"; break; case CardFace.Six: cardTypeAsString = "6"; break; case CardFace.Five: cardTypeAsString = "5"; break; case CardFace.Four: cardTypeAsString = "4"; break; case CardFace.Three: cardTypeAsString = "3"; break; case CardFace.Two: cardTypeAsString = "2"; break; } return cardTypeAsString; }
public void IsTwoPairTestValid(CardFace face1, CardSuit suit1, CardFace face2, CardSuit suit2, CardFace face3, CardSuit suit3, CardFace face4, CardSuit suit4, CardFace face5, CardSuit suit5) { // Didn't found better way to implement many cards with NUnit var cards = new List<ICard>() { new Card(face1, suit1), new Card(face2, suit2), new Card(face3, suit3), new Card(face4, suit4), new Card(face5, suit5), }; var hand = new Hand(cards); Assert.IsTrue(this.checker.IsOnePair(hand)); }
private CardButton CreateCardButton(CardFace f1, CardFace f2, bool suited) { CardButton button = new CardButton(); button.HoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); button.Selected = false; button.SelectedColor = System.Drawing.Color.Yellow; button.Size = new System.Drawing.Size(BUTTON_SIZE, BUTTON_SIZE); button.TabIndex = 0; String value; if (suited) value = HoldemHand.ConvertToString(f1, CardSuit.Clubs, f2, CardSuit.Clubs); else value = HoldemHand.ConvertToString(f1, CardSuit.Clubs, f2, CardSuit.Diamonds); button.Name = "btn" + value; button.Value = value; return button; }
/* Helper method to convert a CardFace enum value into a char */ public static Char CardFaceToChar(CardFace c) { switch (c) { case CardFace.Ace: return 'A'; case CardFace.Two: return '2'; case CardFace.Three: return '3'; case CardFace.Four: return '4'; case CardFace.Five: return '5'; case CardFace.Six: return '6'; case CardFace.Seven: return '7'; case CardFace.Eight: return '8'; case CardFace.Nine: return '9'; case CardFace.Ten: return 'T'; case CardFace.Jack: return 'J'; case CardFace.Queen: return 'Q'; case CardFace.King: return 'K'; default: Trace.Assert(false, "Invalid cardface detected during conversion to char: " + c); return 'A'; // Never to be executed } }
public Card() { suit = CardSuit.Heart; face = CardFace.Ace; }
/// <summary> /// Get the Uno scoring value for a card face /// </summary> /// <param name="face">The face value of the card</param> /// <returns>The integer value</returns> public static int ScoringValueForFace(CardFace face) { int value = 0; switch (face) { case CardFace.Zero: case CardFace.One: case CardFace.Two: case CardFace.Three: case CardFace.Four: case CardFace.Five: case CardFace.Six: case CardFace.Seven: case CardFace.Eight: case CardFace.Nine: value = CardFaceToInt(face); break; case CardFace.Draw2: case CardFace.Reverse: case CardFace.Skip: value = 20; break; case CardFace.None: case CardFace.Draw4: value = 50; break; } return value; }
/// <summary> /// Get the string for a card /// </summary> /// <param name="color"></param> /// <param name="face"></param> /// <returns></returns> public static string StringForCard(CardColor color, CardFace face) { return CardColorToString(color) + CardFaceToString(face); }
/////////////////////////////////////////////////////////////////////////////////////// // Operators /////////////////////////////////////////////////////////////////////////////////////// // Based on code from http://www.blackwasp.co.uk/CSharpRelationalOverload.aspx /* public static bool operator >(Card v1, Card v2) { return (v1.Length > v2.Length); } public static bool operator <(Card v1, Card v2) { return (v1.Length < v2.Length); } public static bool operator >=(Card v1, Card v2) { return (v1.Length >= v2.Length); } public static bool operator <=(Card v1, Card v2) { return (v1.Length <= v2.Length); } */ /////////////////////////////////////////////////////////////////////////////////////// // Static Methods /////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Convert a CardFace into its integer. Action cards return -1. /// </summary> /// <param name="cardFace">The CardFace</param> /// <returns>The face's integer value, or -1 for action cards</returns> public static int CardFaceToInt(CardFace cardFace) { int value = (int)cardFace; return value > 9 ? -1 : value; }
/// <summary> /// Get the Image for a card /// </summary> /// <param name="color"></param> /// <param name="face"></param> /// <returns></returns> public static Image ImageForCard(CardColor color, CardFace face) { // Check the card's valid, otherwise just return the back of a card! if (!IsValidCard(color, face)) return Properties.Resources.back; string card = StringForCard(color, face); return (Image)Properties.Resources.ResourceManager.GetObject(card); }
public Bitmap FrontToBitmap(int width, int height, CardSuit suit, CardFace face, Color color) { return this.ToBitmap(width, height, CardRenderer.GetCardIndex(suit, face), CardType.InvertedFront, color); }
internal PlayingCard(CardSuit suit, CardFace face, CardStatues statues) { this.Suit = suit; this.Face = face; this.Statues = statues; }
/// <summary> /// Initializes a new instance of the <see cref="Card"/> class. /// </summary> /// <param name="suit">Specifies the card suit (hearts, spades, etc).</param> /// <param name="face">Specifies the card face (10, Jack, etc).</param> public Card(CardSuit suit, CardFace face) { this.Suit = suit; this.Face = face; }
public int GetValue(CardFace pukeFaceValue) { return(cardInfoList[(int)pukeFaceValue].value); }
public void CardToString_ShouldWorkProperly(CardSuit suit, CardFace face, string expected) { var card = new Card(face, suit); Assert.AreEqual(expected, card.ToString()); }
public Card(CardFace face, CardSuit suit) { Face = face; Suit = suit; }
void CreateEvalInfo(EvalFuncParamDatas paramDatas) { CardFace[] cardFaces = paramDatas.cardFaces; CardsTypeInfo? curtSlotCardTypeInfo = paramDatas.curtSlotCardTypeInfo; List <SlotCardsEvalInfo> slotCardsEvalGroup = paramDatas.slotCardsEvalGroup; List <CardFace>[] evalDatas = paramDatas.evalDatas; CardsTypeInfo?[] cardsTypeInfos = paramDatas.cardsTypeInfos; int slotDepth = paramDatas.slotDepth; if (curtSlotCardTypeInfo != null) { //去除当道牌型大于前道牌型的组合 if (slotDepth >= 1 && curtSlotCardTypeInfo.Value.type > cardsTypeInfos[slotDepth - 1].Value.type) { return; } //根据赖子牌使用数量,移除当前槽相同数量的赖子牌 CardFace[] removeLaizi = new CardFace[5]; if (curtSlotCardTypeInfo.Value.laiziCount > 0) { cardFaces = CardsTransform.Instance.RemoveLaiziByCount( cardFaces, laizi, curtSlotCardTypeInfo.Value.laiziCount, removeLaizi); } //移除当前槽已使用的牌型牌 CardInfo[] cardInfos = CardsTransform.Instance.CreateRemoveFaceValues( cardFaces, curtSlotCardTypeInfo.Value.cardFaceValues); cardFaces = CardsTransform.Instance.CreateCardFaces(cardInfos); //添加数据 evalDatas[slotDepth].AddRange(curtSlotCardTypeInfo.Value.cardFaceValues); for (int i = 0; i < curtSlotCardTypeInfo.Value.laiziCount; i++) { evalDatas[slotDepth].Add(removeLaizi[i]); } // cardsTypeInfos[slotDepth] = curtSlotCardTypeInfo; } if (slotDepth == 2) { int mustSingleCardCount = 5 - evalDatas[0].Count + 5 - evalDatas[1].Count + 3 - evalDatas[2].Count; if (cardFaces.Length < mustSingleCardCount) { return; } int n = 0; int valueIdx = 0; int[] value = new int[5]; //尾道 SlotCardsEvalInfo evalInfo = new SlotCardsEvalInfo(); evalInfo.slotCardFaceList[0].AddRange(evalDatas[0]); for (int i = 0; i < 5 - evalDatas[0].Count; i++) { value[valueIdx++] = CardsTransform.Instance.GetValue(cardFaces[n]); if (value[valueIdx - 1] == 1) { value[valueIdx - 1] = 14; } evalInfo.slotCardFaceList[0].Add(cardFaces[n++]); } if (cardsTypeInfos[0] == null) { evalInfo.slotCardsType[0] = CardsType.Single; } else { evalInfo.slotCardsType[0] = cardsTypeInfos[0].Value.type; } evalInfo.slotScore[0] = CalCardsScore(cardsTypeInfos[0], null); evalInfo.slotShuiScore[0] = GetCardsTypeShuiScore(cardsTypeInfos[0], 0); //中道 valueIdx = 0; Array.Clear(value, 0, value.Length); evalInfo.slotCardFaceList[1].AddRange(evalDatas[1]); for (int i = 0; i < 5 - evalDatas[1].Count; i++) { value[valueIdx++] = CardsTransform.Instance.GetValue(cardFaces[n]); if (value[valueIdx - 1] == 1) { value[valueIdx - 1] = 14; } evalInfo.slotCardFaceList[1].Add(cardFaces[n++]); } if (cardsTypeInfos[1] == null) { evalInfo.slotCardsType[1] = CardsType.Single; } else { evalInfo.slotCardsType[1] = cardsTypeInfos[1].Value.type; } evalInfo.slotScore[1] = CalCardsScore(cardsTypeInfos[1], null); evalInfo.slotShuiScore[1] = GetCardsTypeShuiScore(cardsTypeInfos[1], 1); if (evalInfo.slotScore[1] > evalInfo.slotScore[0]) { return; } if (evalInfo.slotScore[1] == evalInfo.slotScore[0]) { int cmp = CmpScoreEqualCards( evalInfo.slotCardFaceList[1].ToArray(), evalInfo.slotCardFaceList[0].ToArray()); if (cmp == 1) { return; } } //头道 valueIdx = 0; Array.Clear(value, 0, value.Length); evalInfo.slotCardFaceList[2].AddRange(evalDatas[2]); CardFace cf; if (3 - evalDatas[2].Count > 0 && CardsTransform.Instance.GetValue(cardFaces[n]) == 1) { int m = newCardFaces.Length - 1; newCardFaces[m--] = cardFaces[n]; for (int i = cardFaces.Length - 1; i > n; i--) { newCardFaces[m--] = cardFaces[i]; } for (int i = 0; i < 3 - evalDatas[2].Count; i++) { cf = newCardFaces[newCardFaces.Length - i - 1]; value[valueIdx++] = CardsTransform.Instance.GetValue(cf); if (value[valueIdx - 1] == 1) { value[valueIdx - 1] = 14; } evalInfo.slotCardFaceList[2].Add(cf); } } else { for (int i = 0; i < 3 - evalDatas[2].Count; i++) { cf = cardFaces[cardFaces.Length - i - 1]; value[valueIdx++] = CardsTransform.Instance.GetValue(cf); evalInfo.slotCardFaceList[2].Add(cf); } } if (cardsTypeInfos[2] == null) { evalInfo.slotCardsType[2] = CardsType.Single; } else { evalInfo.slotCardsType[2] = cardsTypeInfos[2].Value.type; } evalInfo.slotScore[2] = CalCardsScore(cardsTypeInfos[2], null); if (evalInfo.slotScore[2] > evalInfo.slotScore[1]) { return; } if (evalInfo.slotScore[2] == evalInfo.slotScore[1]) { int cmp = CmpScoreEqualCards(evalInfo.slotCardFaceList[2].ToArray(), evalInfo.slotCardFaceList[1].ToArray()); if (cmp == 1) { return; } } if (cardsTypeInfos[2] != null && cardsTypeInfos[2].Value.type == CardsType.SanTiao) { evalInfo.slotScore[2] += 600; } evalInfo.slotShuiScore[2] = GetCardsTypeShuiScore(cardsTypeInfos[2], 2); //综合估值 evalInfo.totalScore = evalInfo.slotScore[0] + evalInfo.slotScore[1] + evalInfo.slotScore[2]; evalInfo.totalShuiScore = evalInfo.slotShuiScore[0] + evalInfo.slotShuiScore[1] + evalInfo.slotShuiScore[2]; evalInfo.scoreAndShuiEval = evalInfo.totalScore / maxScore * scoreAndShuiWeight + evalInfo.totalShuiScore / maxShui * (1 - scoreAndShuiWeight); //获取三个槽的分值相对总分的偏离方差 //当总分很高的情况下,如果三个槽的分值相差太大,那么方差会比较高, //反之,即三个槽分值相差太不算太大,这时候方差会比较小 evalInfo.variance = SolveVariance(evalInfo.slotScore); //根据偏离程度(方差),取分值的权重, //即当偏离值很高时,偏离值对分值的权重影响将会很高,会让分值变的比较低,这种组牌策略为平衡型 //可以通过调节varianceCubicRange的值来控制影响程度,当varianceCubicRange = 0时,意味着不受 //偏离程度的影响 float normalVar = evalInfo.variance / varianceLimit; float weight = 1 - InOutCubic(normalVar, 0f, varianceCubicRange, 1); evalInfo.compEval = weight * evalInfo.scoreAndShuiEval; // slotCardsEvalGroup.Add(evalInfo); return; } //为下一个槽准备数据 CardsTypeInfo[] info; if (slotDepth < 1) { nextSlotCreater.CreateAllCardsTypeArray(cardFaces); if (nextSlotCreater.IsExistNotSingleCardsType()) { info = nextSlotCreater.GetAllCardsTypeInfo(); } else { info = nextSlotCreater.GetAllCardsTypeInfo(false); } } else { nextSlotCreater.CreateAllCardsTypeArray(cardFaces, 3); List <CardsTypeInfo> tmpInfo = new List <CardsTypeInfo>(); tmpInfo.AddRange(nextSlotCreater.SantiaoList); tmpInfo.AddRange(nextSlotCreater.DuiziList); int count = Math.Min(5, nextSlotCreater.Single3List.Count); for (int i = 0; i < count; i++) { tmpInfo.Add(nextSlotCreater.Single3List[i]); } info = tmpInfo.ToArray(); if (info.Length == 0) { EvalFuncParamDatas paramDatas2 = new EvalFuncParamDatas() { cardFaces = cardFaces, curtSlotCardTypeInfo = null, slotCardsEvalGroup = slotCardsEvalGroup, evalDatas = evalDatas, cardsTypeInfos = cardsTypeInfos, slotDepth = slotDepth + 1, }; CreateEvalInfo(paramDatas2); evalDatas[slotDepth + 1].Clear(); cardsTypeInfos[slotDepth + 1] = null; return; } } //添加一个随机选取后maxCount个牌型数据算法 int richCount = 0; if (slotDepth < 1 && info.Length > maxCount) { Random rnd = new Random(); int n; int maxRandCount = Math.Min(5, info.Length - maxCount); richCount = info.Length - maxCount; idxs[0] = -1; for (int i = 0; i < maxRandCount; i++) { n = rnd.Next(maxCount, info.Length - 1); for (int j = 0; j < i; j++) { if (idxs[j] == n) { n = -1; break; } } idxs[i] = n; } for (int i = 0; i < maxRandCount; i++) { if (idxs[i] == -1) { continue; } EvalFuncParamDatas paramDatas2 = new EvalFuncParamDatas() { cardFaces = cardFaces, curtSlotCardTypeInfo = info[idxs[i]], slotCardsEvalGroup = slotCardsEvalGroup, evalDatas = evalDatas, cardsTypeInfos = cardsTypeInfos, slotDepth = slotDepth + 1, }; CreateEvalInfo(paramDatas2); evalDatas[slotDepth + 1].Clear(); cardsTypeInfos[slotDepth + 1] = null; } } for (int i = 0; i < info.Length - richCount; i++) { EvalFuncParamDatas paramDatas2 = new EvalFuncParamDatas() { cardFaces = cardFaces, curtSlotCardTypeInfo = info[i], slotCardsEvalGroup = slotCardsEvalGroup, evalDatas = evalDatas, cardsTypeInfos = cardsTypeInfos, slotDepth = slotDepth + 1, }; CreateEvalInfo(paramDatas2); evalDatas[slotDepth + 1].Clear(); cardsTypeInfos[slotDepth + 1] = null; } }
public PlayingCard(CardSuit suit, CardFace face) { Suit = suit; Face = face; }
public Card(Card _card) { suit = _card.suit; face = _card.face; }
public Bitmap FrontToBitmap(CardSuit suit, CardFace face) { return this.FrontToBitmap(this.Size, suit, face); }
public int GetSuit(CardFace pukeFaceValue) { return(cardInfoList[(int)pukeFaceValue].suit); }
public Bitmap FrontToBitmap(Size size, CardSuit suit, CardFace face, Color color) { return this.FrontToBitmap(size.Width, size.Height, suit, face, color); }
/////////////////////////////////////////////////////////////////////////////////////// // Operators /////////////////////////////////////////////////////////////////////////////////////// // Based on code from http://www.blackwasp.co.uk/CSharpRelationalOverload.aspx /* * * public static bool operator >(Card v1, Card v2) * { * return (v1.Length > v2.Length); * } * * public static bool operator <(Card v1, Card v2) * { * return (v1.Length < v2.Length); * } * * public static bool operator >=(Card v1, Card v2) * { * return (v1.Length >= v2.Length); * } * * public static bool operator <=(Card v1, Card v2) * { * return (v1.Length <= v2.Length); * } * */ /////////////////////////////////////////////////////////////////////////////////////// // Static Methods /////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Convert a CardFace into its integer. Action cards return -1. /// </summary> /// <param name="cardFace">The CardFace</param> /// <returns>The face's integer value, or -1 for action cards</returns> public static int CardFaceToInt(CardFace cardFace) { int value = (int)cardFace; return(value > 9 ? -1 : value); }
public Card(CardFace face, CardColor color) { Info.Face = face; Info.Color = color; }
/// <summary> /// Get the string for a card /// </summary> /// <param name="color"></param> /// <param name="face"></param> /// <returns></returns> public static string StringForCard(CardColor color, CardFace face) { return(CardColorToString(color) + CardFaceToString(face)); }
/// <summary> /// Determine's card's value in the context of forming a run. /// </summary> static int GetValue(CardFace face) { return((int)face.Value); }
void CreateEvalInfo(EvalFuncParamDatas paramDatas) { CardFace[] cardFaces = paramDatas.cardFaces; CardsTypeInfo? curtSlotCardTypeInfo = paramDatas.curtSlotCardTypeInfo; List <SlotCardsEvalInfo> slotCardsEvalGroup = paramDatas.slotCardsEvalGroup; List <CardFace>[] evalDatas = paramDatas.evalDatas; CardsTypeInfo?[] cardsTypeInfos = paramDatas.cardsTypeInfos; int slotDepth = paramDatas.slotDepth; CardFace[] refLaizi = paramDatas.refLaizi; if (curtSlotCardTypeInfo != null) { //根据赖子牌使用数量,移除当前槽相同数量的赖子牌 CardFace[] removeLaizi = new CardFace[5]; cardFaces = CardsTransform.Instance.RemoveLaiziByCount(cardFaces, refLaizi, curtSlotCardTypeInfo.Value.laiziCount, removeLaizi); //移除当前槽已使用的牌型牌 CardInfo[] cardInfos = CardsTransform.Instance.CreateRemoveFaceValues(cardFaces, curtSlotCardTypeInfo.Value.cardFaceValues); cardFaces = CardsTransform.Instance.CreateCardFaces(cardInfos); //添加数据 evalDatas[slotDepth].AddRange(curtSlotCardTypeInfo.Value.cardFaceValues); evalDatas[slotDepth].AddRange(removeLaizi); cardsTypeInfos[slotDepth] = curtSlotCardTypeInfo; } if (slotDepth == 2) { int mustSingleCardCount = 5 - evalDatas[0].Count + 5 - evalDatas[1].Count + 3 - evalDatas[2].Count; if (cardFaces.Length < mustSingleCardCount) { return; } int n = 0; int valueIdx = 0; int[] value = new int[5]; //尾槽 SlotCardsEvalInfo evalInfo = new SlotCardsEvalInfo(); evalInfo.slotCardFaceList[0].AddRange(evalDatas[0]); for (int i = 0; i < 5 - evalDatas[0].Count; i++) { value[valueIdx++] = CardsTransform.Instance.GetValue(cardFaces[n]); evalInfo.slotCardFaceList[0].Add(cardFaces[n++]); } evalInfo.slotEval[0] = CalCardsScore(cardsTypeInfos[0].Value, value); //中槽 valueIdx = 0; Array.Clear(value, 0, value.Length); evalInfo.slotCardFaceList[1].AddRange(evalDatas[1]); for (int i = 0; i < 5 - evalDatas[1].Count; i++) { value[valueIdx++] = CardsTransform.Instance.GetValue(cardFaces[n]); evalInfo.slotCardFaceList[1].Add(cardFaces[n++]); } evalInfo.slotEval[1] = CalCardsScore(cardsTypeInfos[1].Value, value); //头槽 valueIdx = 0; Array.Clear(value, 0, value.Length); evalInfo.slotCardFaceList[2].AddRange(evalDatas[2]); for (int i = 0; i < 3 - evalDatas[2].Count; i++) { value[valueIdx++] = CardsTransform.Instance.GetValue(cardFaces[n]); evalInfo.slotCardFaceList[2].Add(cardFaces[n++]); } evalInfo.slotEval[2] = CalCardsScore(cardsTypeInfos[2].Value, value); // evalInfo.totalEval = evalInfo.slotEval[0] + evalInfo.slotEval[1] + evalInfo.slotEval[2]; slotCardsEvalGroup.Add(evalInfo); return; } //为下一个槽准备数据 CardsTypeCreater nextSlotCreater = new CardsTypeCreater(); nextSlotCreater.CreateAllCardsTypeArray(cardFaces, refLaizi); CardsTypeInfo[] info; if (nextSlotCreater.IsExistNotSingleCardsType()) { info = nextSlotCreater.GetAllCardsTypeInfo(); } else { info = nextSlotCreater.GetAllCardsTypeInfo(false); } for (int i = 0; i < info.Length; i++) { EvalFuncParamDatas paramDatas2 = new EvalFuncParamDatas() { cardFaces = cardFaces, curtSlotCardTypeInfo = info[i], slotCardsEvalGroup = slotCardsEvalGroup, evalDatas = evalDatas, cardsTypeInfos = cardsTypeInfos, slotDepth = slotDepth + 1, refLaizi = refLaizi }; CreateEvalInfo(paramDatas2); evalDatas[slotDepth + 1].Clear(); cardsTypeInfos[slotDepth + 1] = null; } }
/// <summary> /// Get the string representing the card face /// </summary> /// <param name="cardFace"></param> /// <returns></returns> public static string CardFaceToString(CardFace cardFace) { string ret = ""; switch (cardFace) { case CardFace.Zero: case CardFace.One: case CardFace.Two: case CardFace.Three: case CardFace.Four: case CardFace.Five: case CardFace.Six: case CardFace.Seven: case CardFace.Eight: case CardFace.Nine: ret = CardFaceToInt(cardFace).ToString(); break; case CardFace.Draw2: ret = "d2"; break; case CardFace.Draw4: ret = "d4"; break; case CardFace.Reverse: ret = "r"; break; case CardFace.Skip: ret = "s"; break; } return ret; }
private static string CardFaceToString(CardFace cardFace) { string result; switch (cardFace) { case CardFace.Two: result = "2"; break; case CardFace.Three: result = "3"; break; case CardFace.Four: result = "4"; break; case CardFace.Five: result = "5"; break; case CardFace.Six: result = "6"; break; case CardFace.Seven: result = "7"; break; case CardFace.Eight: result = "8"; break; case CardFace.Nine: result = "9"; break; case CardFace.Ten: result = "10"; break; case CardFace.Jack: result = "J"; break; case CardFace.Queen: result = "Q"; break; case CardFace.King: result = "K"; break; case CardFace.Ace: result = "A"; break; default: throw new ArgumentException(string.Format("Invalid value for card face : '{0}'.", cardFace)); } return(result); }
/// <summary> /// Check if a color/face combination is a valid Uno card /// </summary> /// <param name="color"></param> /// <param name="face"></param> /// <returns></returns> public static bool IsValidCard(CardColor color, CardFace face) { // TODO: implement checking for valid card return true; }
public void DrawFront(Graphics g, Point point, CardSuit suit, CardFace face, bool inverted = false) { this.DrawFront(g, point.X, point.Y, suit, face, inverted); }
/// <summary> /// Card constructor. /// </summary> /// <param name="c">Color of the card.</param> /// <param name="f">Face of the card.</param> public Card(CardColor c, CardFace f) { Color = c; Face = f; }
public void DrawFront(Graphics g, Rectangle rectangle, CardSuit suit, CardFace face, bool inverted = false) { this.DrawFront(g, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, suit, face, inverted); }
/// <summary> /// Check if a color/face combination is a valid Uno card /// </summary> /// <param name="color"></param> /// <param name="face"></param> /// <returns></returns> public static bool IsValidCard(CardColor color, CardFace face) { // TODO: implement checking for valid card return(true); }
public Card(CardSuit _suit, CardFace _face) { suit = _suit; face = _face; }
private static int CountSameFacesOfCard(IHand hand, CardFace face) { int countEqualFaces = 0; foreach (var card in hand.Cards) { if (card.Face == face) { countEqualFaces++; } } return countEqualFaces; }
private void Awake() { spriteRenderer = GetComponent <SpriteRenderer>(); card = GetComponent <CardFace>(); }
/// <summary> /// Gets the card index for the card with the specified suit and face. /// </summary> /// <param name="suit">The suit of the card.</param> /// <param name="face">The face of the card.</param> public static int GetCardIndex(CardSuit suit, CardFace face) { return (int)suit + ((int)face * Enum.GetValues(typeof(CardSuit)).Length); }
public void Card_ToString_ShouldReturnFormattedString(CardFace face, CardSuit suit, string expected) { var actual = new Card(face, suit).ToString(); Assert.AreEqual(expected, actual); }
public void DrawFront(Graphics g, int x, int y, CardSuit suit, CardFace face, bool inverted = false) { this.DrawFront(g, x, y, this.Width, this.Height, suit, face, inverted); }
private int CompareTwoPairHands(IHand firstHand, IHand secondHand) { List <ICard> firstHandCards = this.GetSortedCards(firstHand); List <ICard> secondHandCards = this.GetSortedCards(secondHand); CardFace firstHandFirstPairCardFace = CardFace.Undefined; CardFace secondHandFirstPairCardFace = CardFace.Undefined; CardFace firstHandSecondPairCardFace = CardFace.Undefined; CardFace secondHandSecondPairCardFace = CardFace.Undefined; bool firstPairWasFound = false; CardFace previousCardFace = firstHandCards[0].Face; for (int i = 1; i < firstHandCards.Count; i++) { if (previousCardFace == firstHandCards[i].Face && !firstPairWasFound) { firstPairWasFound = true; firstHandFirstPairCardFace = previousCardFace; } if (previousCardFace == firstHandCards[i].Face && firstPairWasFound) { firstHandSecondPairCardFace = previousCardFace; } previousCardFace = firstHandCards[i].Face; } firstPairWasFound = false; previousCardFace = secondHandCards[0].Face; for (int i = 1; i < secondHandCards.Count; i++) { if (previousCardFace == secondHandCards[i].Face && !firstPairWasFound) { firstPairWasFound = true; secondHandFirstPairCardFace = previousCardFace; } if (previousCardFace == secondHandCards[i].Face && firstPairWasFound) { secondHandSecondPairCardFace = previousCardFace; } previousCardFace = firstHandCards[i].Face; } int firstTwoPairsFacesSum = (int)firstHandFirstPairCardFace + (int)firstHandSecondPairCardFace; int secondTwoPairsFacesSum = (int)secondHandFirstPairCardFace + (int)secondHandSecondPairCardFace; if (firstTwoPairsFacesSum > secondTwoPairsFacesSum) { return(1); } else if (firstTwoPairsFacesSum < secondTwoPairsFacesSum) { return(-1); } else { return(0); } }
public void DrawFront(Graphics g, int x, int y, int width, int height, CardSuit suit, CardFace face, bool inverted = false) { this.Draw(g, x, y, width, height, CardRenderer.GetCardIndex(suit, face), inverted ? CardType.InvertedFront : CardType.Front, Color.FromArgb(0)); }
private int CompareThreeOfAKindHands(IHand firstHand, IHand secondHand) { List <ICard> firstHandCards = this.GetSortedCards(firstHand); List <ICard> secondHandCards = this.GetSortedCards(secondHand); CardFace firstThreeOfAKindCardFace = CardFace.Undefined; CardFace secondThreeOfAKindCardFace = CardFace.Undefined; int firstCount = 1; int secondCount = 1; CardFace previousCardFace = firstHandCards[0].Face; for (int i = 1; i < firstHandCards.Count; i++) { if (previousCardFace == firstHandCards[i].Face) { firstCount++; } else { firstCount = 1; } if (firstCount == 3) { firstThreeOfAKindCardFace = previousCardFace; break; } previousCardFace = firstHandCards[i].Face; } previousCardFace = secondHandCards[0].Face; for (int i = 1; i < secondHandCards.Count; i++) { if (previousCardFace == secondHandCards[i].Face) { secondCount++; } else { secondCount = 1; } if (secondCount == 3) { secondThreeOfAKindCardFace = previousCardFace; break; } previousCardFace = secondHandCards[i].Face; } if (firstThreeOfAKindCardFace > secondThreeOfAKindCardFace) { return(1); } else if (firstThreeOfAKindCardFace < secondThreeOfAKindCardFace) { return(-1); } else { return(0); } }
public Bitmap FrontToBitmap(CardSuit suit, CardFace face, Color color) { return this.FrontToBitmap(this.Size, suit, face, color); }
public Card(CardFace face, CardSuit suit) { this.Face = face; this.Suit = suit; }
public Bitmap FrontToBitmap(int width, int height, CardSuit suit, CardFace face) { return this.ToBitmap(width, height, CardRenderer.GetCardIndex(suit, face), CardType.Front, Color.FromArgb(0)); }
public void ToString_ShouldReturnStringCorrectly_IfTheCardDoesNotContainUndefinedValues(CardFace cardFace, CardSuit cardSuit) { var card = new Card(cardFace, cardSuit); string expectedString = $"{cardFace} {cardSuit}"; string cardString = card.ToString(); Assert.AreEqual(expectedString, cardString); }
private NumberCard(CardColor cc, CardFace cf) : base(cc, cf) { }
public static string FaceToString(CardFace cardType) { string cardTypeAsString = null; switch (cardType) { case CardFace.Ace: cardTypeAsString = "A"; break; case CardFace.King: cardTypeAsString = "K"; break; case CardFace.Queen: cardTypeAsString = "Q"; break; case CardFace.Jack: cardTypeAsString = "J"; break; case CardFace.Ten: cardTypeAsString = "10"; break; case CardFace.Nine: cardTypeAsString = "9"; break; case CardFace.Eight: cardTypeAsString = "8"; break; case CardFace.Seven: cardTypeAsString = "7"; break; case CardFace.Six: cardTypeAsString = "6"; break; case CardFace.Five: cardTypeAsString = "5"; break; case CardFace.Four: cardTypeAsString = "4"; break; case CardFace.Three: cardTypeAsString = "3"; break; case CardFace.Two: cardTypeAsString = "2"; break; } return(cardTypeAsString); }
public PokerCard(CardSuit s, CardFace f) { suit = s; face = f; }
public void ToString_ShouldThrowArgumentException_IfAtLeastOneOfTheValuesIsUndefined(CardFace cardFace, CardSuit cardSuit) { var card = new Card(cardFace, cardSuit); Assert.Throws <ArgumentException>(() => card.ToString()); }
/// <summary> /// Do the given card faces correspond to a valid run? A valid run occurs when the difference in value between /// the two cards is equal to 1. Note that the Jack, Queen, King are valued 11, 12, 13 and the Ace can be either /// 1 or 14, so that it forms a run with both the 2 and the King. /// </summary> public static bool IsValidRun(CardFace cardA, CardFace cardB) { int absDifference = Mathf.Abs(GetValue(cardA) - GetValue(cardB)); return(1 == absDifference || 12 == absDifference); }
Card CreateCard(CardFace face, GameObject prefab, ICardFactory factory) { Card card = factory.CreateCard(face, prefab); return(card); }