/* * 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 }); } }
/* 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 player_OnCardPlayed(object sender, CardEventArgs e) { var nextIndex = CurrentPlayer.Index + 1 >= 3 ? 0 : CurrentPlayer.Index + 1; CurrentAvailableCard = new Cards(); var cardsInPlay = new List<Card>(); for (int i = 0; i < e.Cards.Count; i++) CurrentAvailableCard.Add(e.Cards[i]); if (e.Cards.Count > 0) { CurrentAvailableCardPlayer = e.index; Combination = e.CurrentCombination; } AssignCurrentPlayer(nextIndex); }
void player_OnCardDiscarded(object sender, CardEventArgs e) { CurrentAvailableCard = e.Card; var nextIndex = CurrentPlayer.Index + 1 >= _gameOptions.NumberOfPlayers ? 0 : CurrentPlayer.Index + 1; if (GameDeck.CardsInDeck == 0) { var cardsInPlay = new List<Card>(); foreach (var player in Players) cardsInPlay.AddRange(player.GetCards()); cardsInPlay.Add(CurrentAvailableCard); GameDeck.ReshuffleDiscarded(cardsInPlay); } AssignCurrentPlayer(nextIndex); }
private void CurrentPlayer_OnCardDiscarded(object sender, CardEventArgs e) { AvailableCard = e.Card; DrawDecks(); }