public Player CopyPlayer(Player player) { var newPlayer = new Player(player.Name, player.Stack, player.IsHero, player.numeric, player.reserved); newPlayer.InGame = player.InGame; for (int i = 0; i < player.cards.Length; i++) { newPlayer.cards[i] = player.cards[i]; } newPlayer.reservedMoney = player.reservedMoney; return newPlayer; }
public Game(Player[] players, Deck deck, int[] blinds,Label PotLabel) { this.players = players; this.deck = deck; this.BigBlind = blinds[1]; this.SmallBlind = blinds[0]; this.PotLabel = PotLabel; CurrentStake = BigBlind; reRaiseValue = 2 * BigBlind; this.PlayersInGame = players.Length; this.tableCards = new Card[5]; }
public void CreateGame() { int num = (int)NumOfPlayers.Value; players = new Player[num]; int dealer = IsDealerOrHeroInPlayers(DealerLabel, num); bool isDealer = false; if (dealer >= 0) { isDealer = true; } int hero = IsDealerOrHeroInPlayers(HeroLabel, num); bool isHero = false; if (hero >= 0) { isHero = true; } bool allCardSelected = AllCardsSelected(cards); int[] blinds = new int[] { (int)SmallBlind.Value, (int)BigBlind.Value }; if (isDealer && isHero && allCardSelected && blinds[0] < blinds[1]) { for (int i = 0; i < num; i++) { Player player = new Player(labels[i].Text, (int)nums[i].Value, hero == i, nums[i], Betlabels[i]); if (hero == i) { player.cards = cards; } players[(i + num - dealer) % num] = player; } game = new Game(players, deck, blinds, Pot); Console.WriteLine(" Udało się " + players[0].Name); for (int i = 0; i < game.players.Length; i++) { string str = game.players[i].Name + " " + game.players[i].Stack; if (game.players[i].IsHero) { str += " Hero"; } } HideShowPlayerUI(); game.PostBlind(); button1.Visible = false; NumOfPlayers.Enabled = false; SmallBlind.Enabled = false; BigBlind.Enabled = false; foreach (var item in game.players) { item.numeric.Enabled = false; } HeroLabel.Enabled = false; DealerLabel.Enabled = false; } else { MessageBox.Show("You done something wrong"); } }
public Game CopyGame(Game game) { var newPlayers = new Player[game.players.Length]; for (int i = 0; i < game.players.Length; i++) { newPlayers[i] = game.players[i].CopyPlayer(game.players[i]); } var newDeck = game.deck.CopyDeck(game.deck); var newGame = new Game(newPlayers, newDeck, new int[] { game.SmallBlind, game.BigBlind }, game.PotLabel); newGame.state = game.state; newGame.CallCount = game.CallCount; newGame.CurrentStake = game.CurrentStake; newGame.ReRaiseValue= game.ReRaiseValue; newGame.Position = game.Position; newGame.PlayersInGame = game.PlayersInGame; newGame.Pot = game.Pot; return newGame; }
public Player NextPlayerToPlay() { var NotFound = true; Player player = new Player(); while (NotFound) { if (players[Position % players.Length].InGame) { player = players[Position % players.Length]; NotFound = false; } else { Position++; } } return player; }
public void MakeRaise(Player player, int RaiseValue) { reRaiseValue = 2 * RaiseValue - CurrentStake; CurrentStake = RaiseValue; pot += CurrentStake - player.ReservedMoney; PotLabel.Text = pot.ToString(); player.Stack -= CurrentStake - player.ReservedMoney; player.numeric.Value = player.Stack; player.ReservedMoney = CurrentStake; player.reserved.Text = player.ReservedMoney.ToString(); CallCount = 1; Position++; }
public void MakeFold(Player player) { player.InGame = false; Position++; PlayersInGame--; }
public void MakeCall(Player player) { pot += CurrentStake - player.ReservedMoney; PotLabel.Text = pot.ToString(); player.Stack -= CurrentStake - player.ReservedMoney; player.numeric.Value = player.Stack; player.ReservedMoney = CurrentStake; player.reserved.Text = player.ReservedMoney.ToString(); CallCount++; Position++; }