/* * public void DiscardCard(Card card) * { * Hand.Remove(card); * if (HasWon && OnPlayerHasWon != null) * OnPlayerHasWon(this, new PlayerEventArgs { Player = this, State = PlayerState.Winner }); * if (OnCardDiscarded != null) * OnCardDiscarded(this, new CardEventArgs { Card = card }); * } */ public void play(kindsOfCombination k) { kindsOfCombination result = validCards(); if (result == null) { return; } if (!result.biggerThan(k)) { return; } for (int i = 0; i < Chosen.Count; i++) { Hand.Remove(Chosen[i]); } CardEventArgs args = new CardEventArgs(); args.Card = new Card((Suit)1, (Rank)3); args.Cards = (Cards)Chosen.Clone(); args.index = Index; args.CurrentCombination = result; OnCardPlayed(this, args); Chosen.Clear(); if (HasWon && OnPlayerHasWon != null) { OnPlayerHasWon(this, new PlayerEventArgs { Player = this, State = PlayerState.Winner }); } }
private void DealwithStraight(kindsOfCombination combination, int CardPlayer) { for (int i = 0; i < Hand.Count; i++) { if (Chosen.Count == 0) { if (Hand[i].rank > (Rank)combination.index) { Chosen.Add(Hand[i]); } } else if (Hand[i].rank == Chosen.Last().rank + 1 && Hand[i].rank < (Rank)15) { Chosen.Add(Hand[i]); } else if (Hand[i].rank > Chosen.Last().rank + 1) { Chosen.Clear(); } if (Chosen.Count == combination.assist) { break; } } if (Chosen.Count != combination.assist) { Chosen.Clear(); } if (Chosen.Count == 0 && combination.assist >= 7) //use bomb { DealwithBomb(combination, CardPlayer); } }
public void pass(int CardsPlayer) { if (Index == CardsPlayer) { return; } Chosen.Clear(); this._state = PlayerState.Pass; OnCardPlayed(this, new CardEventArgs { Cards = new Cards() }); }
private void DealwithThree(kindsOfCombination combination, int CardPlayer) { for (int i = 0; i < Hand.Count - 2; i++) { if (Hand[i].rank == Hand[i + 1].rank && Hand[i].rank == Hand[i + 2].rank && Hand[i].rank > (Rank)combination.index) { Chosen.Add(Hand[i]); Chosen.Add(Hand[i + 1]); Chosen.Add(Hand[i + 2]); break; } } if (combination.assist == 1) { for (int i = 0; i < Hand.Count; i++) { if (!Chosen.Contains(Hand[i])) { Chosen.Add(Hand[i]); break; } } if (Chosen.Count != 4) { Chosen.Clear(); } } else if (combination.assist == 2) { for (int i = 0; i < Hand.Count - 1; i++) { if (!Chosen.Contains(Hand[i]) && !Chosen.Contains(Hand[i + 1])) { Chosen.Add(Hand[i]); Chosen.Add(Hand[i + 1]); break; } } if (Chosen.Count != 5) { Chosen.Clear(); } } if (Chosen.Count == 0 && combination.index >= 10) //use bomb { DealwithBomb(combination, CardPlayer); } }
private void DealwithStraightPair(kindsOfCombination combination, int CardPlayer) { bool chooseFirst = true; for (int i = 0; i < Hand.Count - 3; i++) { if (Chosen.Count == 0) { if (Hand[i].rank > (Rank)combination.index) { Chosen.Add(Hand[i]); } } else if (chooseFirst && Hand[i].rank == Chosen.Last().rank&& Hand[i].rank < (Rank)15) { chooseFirst = false; Chosen.Add(Hand[i]); } else if (chooseFirst && Hand[i].rank > Chosen.Last().rank&& Hand[i].rank < (Rank)15) { Chosen.Clear(); } else if (!chooseFirst && Hand[i].rank == Chosen.Last().rank + 1 && Hand[i].rank < (Rank)15) { chooseFirst = true; Chosen.Add(Hand[i]); } else if (!chooseFirst && Hand[i].rank > Chosen.Last().rank + 1) { Chosen.Clear(); } if (Chosen.Count == combination.assist) { break; } } if (Chosen.Count != combination.assist * 2) { Chosen.Clear(); } if (Chosen.Count == 0 && combination.assist >= 4) //use bomb { DealwithBomb(combination, CardPlayer); } }