private void DiscardCardFromHand(Cards.Card p) { if (!humanDiscard && humanDraw) { HumanCards.Remove(p); Discards.Add(p); removePossibleCard(p); humanDiscard = true; startGame = true; playerTurn = false; } else { if (!startGame) { RaiseNotification("You must draw a card first", "Invalid Action"); } else { if (!playerTurn) { RaiseNotification("You already discard a card", "Invalid Action"); } else { RaiseNotification("You must draw a card first", "Invalid Action"); } } } }
private async void Deal() { var deck = Cards.Shuffle(Cards.FullDeck); foreach (var card in deck) { PossibleDeck.Add(card); // Possible list of card RemainingDeck.Add(card); await Task.Delay(1); } for (int i = 0; i < 10; i++) { Cards.Card computerCard = DrawTopCardFromDeck(); ComputerCards.Add(computerCard); // Remove the list of card on computer hand, as it is seen removePossibleCard(computerCard); await Task.Delay(30); HumanCards.Add(DrawTopCardFromDeck()); await Task.Delay(30); } Discards.Add(DrawTopCardFromDeck()); // Remove the discard from possible deck removePossibleCard(Discards[Discards.Count - 1]); ScoreToWin = "Score To Win : " + winingScore.ToString(); scoreLabel(firstWinnerScore, secondWinnerScore); }
private async void Deal() { ComputerThoughts = "You dare challenge I? I can calculate more moves in a second than you can possibly imagine!"; if (dealFinishied) { dealFinishied = false; var deck = Cards.Shuffle(Cards.FullDeck); foreach (var card in deck) { RemainingDeck.Add(card); await Task.Delay(1); } for (int i = 0; i < 10; i++) { ComputerCards.Add(DrawTopCardFromDeck()); await Task.Delay(30); HumanCards.Add(DrawTopCardFromDeck()); await Task.Delay(30); } Discards.Add(DrawTopCardFromDeck()); dealFinishied = true; } }
private void TakeCardFromDeck(Cards.Card card) { if (humanTurn) { RemainingDeck.Remove(card); HumanCards.Add(card); } }
private void TakeCardFromDiscardPile(Cards.Card p) { if (humanTurn) { Discards.Remove(p); HumanCards.Add(p); } }
private void CleanUpCards() { HumanCards.Clear(); ComputerCards.Clear(); RemainingDeck.Clear(); Discards.Clear(); Deal(); }
private void DiscardCardFromHand(Cards.Card p) { if (HumanCards.Count > 10 && humanTurn) { HumanCards.Remove(p); Discards.Add(p); humanTurn = false; } }
async private void HumanCards_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { HumanDeadwood = "Calculating ..."; // this might take a while, so let's do it in the background Deadwood = await Task.Run(() => GinRummy.Deadwood(HumanCards.ToArray())); //int deadwood = GinRummy.Deadwood(GinRummy.listOfSortedSuits(HumanCards).ToArray()); HumanDeadwood = "Deadwood: " + Deadwood; }
private void TakeCardFromDeck(Cards.Card card) { if (!takenFromDeckOrDiscardPile) // Human goes first { RemainingDeck.Remove(card); HumanCards.Add(card); takenFromDeckOrDiscardPile = true; canNowDiscard = true; } }
private void TakeCardFromDiscardPile(Cards.Card p) { if (!takenFromDeckOrDiscardPile) { Discards.Remove(p); HumanCards.Add(p); takenFromDeckOrDiscardPile = true; canNowDiscard = true; } }
private void nextRound() { CheckForEndGame(); takenFromDeckOrDiscardPile = false; canNowDiscard = false; HumanCards.Clear(); ComputerCards.Clear(); RemainingDeck.Clear(); Discards.Clear(); Deal(); }
private void DiscardCardFromHand(Cards.Card p) { if (canNowDiscard) { HumanCards.Remove(p); Discards.Add(p); canNowDiscard = false; computerSeen.Remove(p); ArtificialPlayer(); } }
private void TakeCardFromDeck(Cards.Card card) { if (!humanDraw) { RemainingDeck.Remove(card); HumanCards.Add(card); humanDraw = true; } else { RaiseNotification("You already take a card", "Invalid Action"); } }
private void TakeCardFromDiscardPile(Cards.Card p) { if (!humanDraw) { Discards.Remove(p); HumanCards.Add(p); humanDraw = true; } else { RaiseNotification("You already take a card", "Invalid Action"); } }
private void TakeCardFromDiscardPile(Cards.Card p) { if (pickUpStage) { Discards.Remove(p); HumanCards.Add(p); pickUpStage = false; discardStage = true; } else { RaiseNotification("Not in Pick-Up Stage", "Title"); } }
private void TakeCardFromDeck(Cards.Card card) { if (pickUpStage) { RemainingDeck.Remove(card); HumanCards.Add(card); pickUpStage = false; discardStage = true; } else { RaiseNotification("Not in Pick-Up Stage", "Title"); } }
private void DiscardCardFromHand(Cards.Card p) { if (discardStage) { HumanCards.Remove(p); Discards.Add(p); discardStage = false; computerStage = true; ComputerPlayerTurn(); } else { RaiseNotification("Not in Discard Stage", "Title"); } }
// Function to reset the game for next rounds // The game will continue if none of player has exceeded // maximum score to win private void resetGame() { Discards.Clear(); HumanCards.Clear(); ComputerCards.Clear(); RemainingDeck.Clear(); PossibleDeck.Clear(); startGame = false; playerTurn = true; humanDraw = false; humanDiscard = false; if (firstWinnerScore >= winingScore || secondWinnerScore >= winingScore) { scoreReset(); } Deal(); }
private async void Deal() { var deck = Cards.Shuffle(Cards.FullDeck); foreach (var card in deck) { RemainingDeck.Add(card); await Task.Delay(1); } for (int i = 0; i < 10; i++) { ComputerCards.Add(DrawTopCardFromDeck()); await Task.Delay(30); HumanCards.Add(DrawTopCardFromDeck()); await Task.Delay(30); } Discards.Add(DrawTopCardFromDeck()); }
private void DiscardCardFromHand(Cards.Card p) { HumanCards.Remove(p); Discards.Add(p); }