public void SetInfo(Player thePlayer, Game theGame) { game = theGame; player = thePlayer; gamePlayer = game.PlayersCards[player] as Game.GamePlayer; // Don't show the score label if basic scoring is used if (game.Options.ScoringSystem == GameOptions.ScoringSystems.Basic) { scoreLabel.Visible = false; } nameLabel.Text = player.Name; scoreLabel.Text = "Score: " + player.Score; //typeLabel.Text = Player.PlayerTypeToString(player.Type); typeBadge.Image = Player.PlayerTypeBadge(player.Type); turnsLabel.Text = gamePlayer.NumberOfTurns.ToString(); cardsPickedUpLabel.Text = gamePlayer.NumberOfCardsPickedUp.ToString(); cardsPlayedLabel.Text = gamePlayer.NumberOfCardsPlayed.ToString(); ordinalLabel.Text = GetOrdinalStringForInt(player.Rank + 1); if (thePlayer.Team != 0) { TeamIndex.Text += " " + thePlayer.Team; } }
/// <summary> /// End the game, and perform necessary clean up /// </summary> public void EndGame() { // Calculate scores for (int i = 0; i < game.NumberOfPlayers; i++) { Game.GamePlayer gamePlayer = (game.PlayersCards[game.Players[i]] as Game.GamePlayer); // Score the players according to the basic system // TODO: implement hybrid scoring somehow if (game.Options.ScoringSystem == GameOptions.ScoringSystems.Basic) { gamePlayer.Score = gamePlayer.FinishRank < 0 ? game.NumberOfPlayers : gamePlayer.FinishRank; } // Use official Uno scoring else { gamePlayer.Score = CalculateUnoScoreForHand(gamePlayer.Cards); } // Add the GamePlayer's score to the Player's total // (For playing multiple games, not currently implemented) game.Players[i].Score += gamePlayer.Score; } // Show the final results Program.NewSortedPlayersView(game); // (this will sort the players) // Close the game view gameView.Close(); }
public static void SetOtherCardsToBack(Hashtable playerCards, Game.GamePlayer currentPlayer, GameView gameview, bool isTeams) { gameview.ReDraw(); gameview.Refresh(); foreach (DictionaryEntry player in playerCards) { if (player.Value == currentPlayer) { foreach (Card card in currentPlayer.Cards) { card.Image = ImageForCard(card.Color, card.Face); //gameview.cardsViews[card] = gameview.createPictureBoxForCard(card); foreach (DictionaryEntry cardView in gameview.cardsViews) { if (cardView.Key == card) { ((PictureBox)cardView.Value).Image = ImageForCard(card.Color, card.Face); } } } } else if (isTeams && ((Game.GamePlayer)player.Value).TeamMate == currentPlayer) { foreach (Card card in ((Game.GamePlayer)player.Value).Cards) { card.Image = ImageForCard(card.Color, card.Face); //gameview.cardsViews[card] = gameview.createPictureBoxForCard(card); foreach (DictionaryEntry cardView in gameview.cardsViews) { if (cardView.Key == card) { ((PictureBox)cardView.Value).Image = ImageForCard(card.Color, card.Face); } } } } else { foreach (Card card in ((Game.GamePlayer)player.Value).Cards) { card.Image = Properties.Resources.back; //gameview.cardsViews[card] = gameview.createPictureBoxForCard(card); foreach (DictionaryEntry cardView in gameview.cardsViews) { if (cardView.Key == card) { ((PictureBox)cardView.Value).Image = Properties.Resources.back; } } } } } gameview.ReDraw(); gameview.Refresh(); }
private void PlayerSwapHands(int?PlayerIndex) { int Player = PlayerIndex ?? default; Game.GamePlayer TargetPlayer = game.PlayersCards[game.Players[Player]] as Game.GamePlayer; Game.GamePlayer CurrentPlayer = game.PlayersCards[game.Players[game.CurrentPlayerIndex]] as Game.GamePlayer; List <Card> targetPlayerCards = TargetPlayer.Cards; List <Card> currentPlayerCards = CurrentPlayer.Cards; TargetPlayer.Cards = currentPlayerCards; CurrentPlayer.Cards = targetPlayerCards; nextPlayer(); gameView.ReDraw(); }
public void SwapHandsOnSeven() { if (game.CurrentPlayer.Type != Player.PlayerType.Human) { int smallestHand = int.MaxValue; int handOwner = -1; for (int i = 0; i < game.PlayersCards.Count; i++) { Game.GamePlayer currentPlayerCheck = (Game.GamePlayer)game.PlayersCards[game.Players[i]]; if (currentPlayerCheck.Player.Name == game.CurrentPlayer.Name) { continue; } else { if (smallestHand > currentPlayerCheck.Cards.Count) { handOwner = i; smallestHand = currentPlayerCheck.Cards.Count; } } } if (handOwner != -1) { PlayerSwapHands(handOwner); } } else { HandSwapSelect handSwapSelect = new HandSwapSelect(game.NumberOfPlayers, game.CurrentPlayerIndex); DialogResult result = handSwapSelect.ShowDialog(); if (result == DialogResult.OK) { PlayerSwapHands(handSwapSelect.ClickResult); } } }
private void flipOtherCards(Hashtable playerCards, Game.GamePlayer currentPlayer, GameView gameview) { Card.SetOtherCardsToBack(playerCards, currentPlayer, gameview, game.Options.EnableTeams); }
public void SetInfo(Player thePlayer, Game theGame) { game = theGame; player = thePlayer; gamePlayer = game.PlayersCards[player] as Game.GamePlayer; // Don't show the score label if basic scoring is used if (game.Options.ScoringSystem == GameOptions.ScoringSystems.Basic) scoreLabel.Visible = false; nameLabel.Text = player.Name; scoreLabel.Text = "Score: " + player.Score; //typeLabel.Text = Player.PlayerTypeToString(player.Type); typeBadge.Image = Player.PlayerTypeBadge(player.Type); turnsLabel.Text = gamePlayer.NumberOfTurns.ToString(); cardsPickedUpLabel.Text = gamePlayer.NumberOfCardsPickedUp.ToString(); cardsPlayedLabel.Text = gamePlayer.NumberOfCardsPlayed.ToString(); ordinalLabel.Text = GetOrdinalStringForInt(player.Rank + 1); }
/// <summary> /// Updates the game view form to present the current state of the game /// </summary> public void ReDraw() { // Remove cards that are just in the deck, but set to appropriate positions foreach (Card c in game.Deck) { this.Controls.Remove(cardsViews[c] as PictureBox); (cardsViews[c] as PictureBox).Location = new Point(75, 182); } // Layout the cards for each player for (int i = 0; i < game.Players.Count; i++) { // Get the GamePlayer Game.GamePlayer p = (Game.GamePlayer)game.PlayersCards[game.Players[i]]; for (int k = 0; k < p.Cards.Count; k++) { // Get the card Card c = p.Cards[k]; // Get the picture box and make sure it's shown on the form PictureBox pictureBox = cardsViews[c] as PictureBox; this.Controls.Add(pictureBox); pictureBox.BringToFront(); // Highlight playable cards if (game.Options.HighlightPlayableCards) { pictureBox.BorderStyle = controller.CanPlayCard(c) ? BorderStyle.FixedSingle : BorderStyle.None; } // Extra things to try while in Debug mode (incomplete features) #if DEBUG // Set the tooltip to the status of the card toolTip.SetToolTip(pictureBox, controller.CanPlayCardStatus(c).ToString()); if (p.Cards.Count > 10) { //System.Diagnostics.Debugger.Break(); } #endif // Set the position of the card on the screen, putting them closer together when there's more than 10 cards int left = p.Cards.Count <= 10 ? k * 60 + 260 : k * (650 / p.Cards.Count) + 260; // Animate moving the position of the card moveControlTo(pictureBox, left, i * 137 + 80, Tweener.easeOutCubic, !(first && tooManyCards)); } } // Remove all cards in the discard pile from the form except some of the top cards for (int c = 0; c < game.DiscardPile.Count - 15; c++) { Controls.Remove(cardsViews[game.DiscardPile[c]] as PictureBox); (cardsViews[game.DiscardPile[c]] as PictureBox).Location = new Point(75, 182); } // Display the discard pile if (game.DiscardPile.Count > 0) { PictureBox lastCard = cardsViews[game.DiscardPile.Last()] as PictureBox; Controls.Add(lastCard); lastCard.BringToFront(); moveControlTo(lastCard, 75, 65); // Remove tooltip toolTip.SetToolTip(lastCard, ""); // Remove the highlighted border if (game.Options.HighlightPlayableCards) { lastCard.BorderStyle = BorderStyle.None; } } // Show the pickup pile as empty when it's empty if (game.Deck.Count == 0) { pickupPileImage.Image = null; pickupPileImage.BackColor = Color.White; } else if (pickupPileImage.Image == null) { pickupPileImage.Image = Properties.Resources.back; pickupPileImage.BackColor = Color.Transparent; } // Set player status // Don't animate when computers are playing each other really quickly moveControlTo(playerStatus, 213, game.CurrentPlayerIndex * 137 + 43, Tweener.easeOutCubic, game.Options.ComputerPlayerDelay > 600, 50); playerStatus.Image = (Image)Properties.Resources.ResourceManager.GetObject(Card.CardColorToString(game.CurrentColor) + (game.Reverse ? "_ccw" : "_cw")); if (game.CurrentColor == Card.CardColor.Wild) { playerStatus.BackColor = Color.Black; } else { playerStatus.BackColor = Color.Transparent; } // Show the end game highlight if (game.Finished) { endGameHighlightTimer.Start(); endGameButton.Focus(); } // Set the first flag, to enable animation again first = false; }