// Scoring code is bloated but is composed of resuable methods, // for example if you were to expand the game to work for more than two players. // Not a proper TDD approach to the kata. static void Main(string[] args) { Deck gameDeck = new Deck(); ScoringSession newSession = new ScoringSession(); List<Card> player1Hand = gameDeck.GetNewHand(); List<Card> player2Hand = gameDeck.GetNewHand(); newSession.ShowHands(player1Hand, player2Hand); }
// Constructors public Game(int n_players, Deck deck, int starting_funds = Money.DEFAULT_ORIGINAL_AMOUNT, int buy_in = Money.DEFAULT_BUY_IN, int max_size = Hand.DEFAULT_MAX_SIZE, int big_blind = Money.DEFAULT_BIG_BLIND, int small_blind = Money.DEFAULT_SMALL_BLIND, int ante = Money.DEFAULT_ANTE) { if (n_players < 4) { n_players = 4; } else if (n_players > 6) { n_players = 6; } Random rand = new Random(); this.deck = deck; this.deck.shuffle(); players = new Player[n_players]; player_queue = new Queue<Player>(n_players); string player_1_name = query_player_1_name(); bool is_male_player = query_player_1_gender(); // initialize the players // initialize the bank // empty out the queue // assign and shuffle the deck /* int starting_funds = Money.DEFAULT_ORIGINAL_AMOUNT; int buy_in = Money.DEFAULT_BUY_IN; int big_blind = Money.DEFAULT_BIG_BLIND; int small_blind = Money.DEFAULT_SMALL_BLIND; int ante = Money.DEFAULT_ANTE; int max_size = Hand.DEFAULT_MAX_SIZE; */ bool[] AI_genders; string[] AI_names = choose_AI_names(player_1_name, out AI_genders); players[0] = new Player(starting_funds, buy_in, big_blind, small_blind, ante, deck.draw(5), this.deck, max_size, player_1_name, is_male_player); player_queue.Enqueue(players[0]); for (int i = 1; i < n_players; i++) { Wealth_Types wealth_type = (Wealth_Types)rand.Next((int)Wealth_Types.END); Betting_Types betting_type = (Betting_Types)rand.Next((int)Betting_Types.END); Perception_Types perception_type = (Perception_Types)rand.Next((int)Perception_Types.END); Personality personality = new Personality(wealth_type, betting_type, perception_type); players[i] = new AIPlayer(personality, this.deck, AI_names[i - 1], AI_genders[i - 1]); player_queue.Enqueue(players[i]); } // assign the bank's variables bank = new Money(0, buy_in, big_blind, small_blind, ante); }
// Constructors public Player(int starting_funds, int buy_in, int big_blind, int small_blind, int ante, Card[] starting_hand, Deck deck, int max_size, string name, bool is_male) { money_p = new Money(starting_funds, buy_in, big_blind, small_blind, ante); hand_p = new Hand(starting_hand, deck, max_size); is_out_p = false; folded_p = false; all_in_p = false; refresh_bluff(); name_p = name; is_male_p = is_male; n_times_this_turn = 0; tell_type_p = (Tell_Types)rand.Next((int)Tell_Types.END); tell_p = decide_tell(); last_action_p = Actions.CALL; last_bet_p = 0; }
/* // Testing mainframe public static void Main(string[] args) { Personality personality = new Personality(Wealth_Types.RICH, Betting_Types.EXTREME, Perception_Types.AWARE); AIPlayer player = new AIPlayer(personality, new Deck()); player.AI_take_action(true, false, 20); Console.Read(); } */ // Constructor public AIPlayer(Personality personality, int starting_funds, int buy_in, int big_blind, int small_blind, int ante, Card[] starting_hand, Deck deck, int max_size, string name, bool is_male) : base(starting_funds, buy_in, big_blind, small_blind, ante, starting_hand, deck, max_size, name, is_male) { Wealth_Types actual_wealth_type = Wealth_Types.POOR; for (int i = (int)Wealth_Types.END - 1; i > 0; i--) { if (starting_funds > (int)(Wealth_Values)i) { actual_wealth_type = (Wealth_Types)i; break; } } AI_Ctor_Helper(personality); }
static void Main() { Hand[] hands = new Hand[10]; Deck d = new Deck(); d.Shuffle(); for (int i = 0; i < hands.Length; i++) { hands[i] = new Hand(); } for (int cardCount = 0; cardCount < 5; cardCount++) { foreach (Hand t in hands) { t.Add(d.Deal()); } } foreach (Hand hand in hands) { Console.WriteLine("{0} ({1})", hand.Rank, hand); } }
public Player(Deck deck) : this(Money.DEFAULT_ORIGINAL_AMOUNT, Money.DEFAULT_BUY_IN, Money.DEFAULT_BIG_BLIND, Money.DEFAULT_SMALL_BLIND, Money.DEFAULT_ANTE, deck.draw(5), deck, 5, "Player_1", true) { }
public Player(Deck deck, string name, bool is_male) : this(Money.DEFAULT_ORIGINAL_AMOUNT, Money.DEFAULT_BUY_IN, Money.DEFAULT_BIG_BLIND, Money.DEFAULT_SMALL_BLIND, Money.DEFAULT_ANTE, deck.draw(5), deck, 5, name, is_male) { }
public void Init() { testDeck = new Deck(); }
public AIPlayer(Personality personality, Deck deck) : this(personality, deck, pick_random_name(), true) { }
public Dealer(List<IPlayer> player_list) { myDeck = new Deck(); myDeck.shuffle(); GameOver=false; players = player_list; }
public void newHand(GameState state) { this.state = state; state.handStep = GameState.HandStep.PreFlop; Deck deck = new Deck(); state.deck = deck; state.players = state.players; this.buttonPos = state.buttonPos; if (state.players.Count > 2) { state.actionPos = (state.buttonPos + 3) % state.players.Count; // small blind state.players[(buttonPos + 1) % state.players.Count].commitChips(state.bb / 2); // big blind state.players[(buttonPos + 2) % state.players.Count].commitChips(state.bb); } else { state.actionPos = (state.buttonPos) % state.players.Count; // small blind state.players[(state.buttonPos) % state.players.Count].commitChips(state.bb / 2); // big blind state.players[(state.buttonPos + 1) % state.players.Count].commitChips(state.bb); } foreach (Player player in state.players) { player.inHand = true; player.addHoleCards(deck.giveCard(), deck.giveCard()); } state.updateMaxCommitted(); play(state); }
public Hand(Deck deck, int max_size) : this(new Card[5], deck, max_size) { }
public Hand(Card[] cards, Deck deck, int max_size) { cards_p = cards; max_size_p = max_size; n_held_p = 0; for (int i = 0; i < cards.Length; i++) { if (cards_p[i] == null) { break; } else { ++n_held_p; } } deck_p = deck; the_best_p = new Card[max_size_p]; the_rest_p = new Card[0]; best_hand_value_p = Hand_Values.END; organize(); }
// Constructors public Hand(Hand other) { this.cards_p = other.cards; this.max_size_p = other.max_size; this.n_held_p = other.n_held; this.deck_p = other.deck; this.the_best_p = other.the_best; this.the_rest_p = other.the_rest; this.best_hand_value_p = other.best_hand_value; }
public Dealer() { myDeck = new Deck(); myDeck.shuffle(); GameOver=false; }
public AIPlayer(Personality personality, Deck deck, string name, bool is_male) : this(personality, (int)(Personality.convert_wealth_type_to_value(personality.wealth_type)), Money.DEFAULT_BUY_IN, Money.DEFAULT_BIG_BLIND, Money.DEFAULT_SMALL_BLIND, Money.DEFAULT_ANTE, deck.draw(Hand.DEFAULT_MAX_SIZE), deck, Hand.DEFAULT_MAX_SIZE, name, is_male) { AI_Ctor_Helper(personality); }
public Croupier() { deck = new Deck(); }