Exemplo n.º 1
0
        //the all important constructors
        public FormPoker()
        {
            InitializeComponent();
            this.Icon = new Icon("Poker.ico");
            timerCount = 0;
            screenWidth = Screen.PrimaryScreen.Bounds.Width;
            screenHeight = Screen.PrimaryScreen.Bounds.Height;
            width_ratio = (screenWidth / this.Width);
            height_ratio = (screenHeight / this.Height);

            SizeF scale = new SizeF(width_ratio, height_ratio);
            pbMain.Scale(scale);
            this.Size = pbMain.Size;
            foreach (Control control in this.Controls)
            {
                control.Font = new Font(control.Font.Name, control.Font.SizeInPoints * height_ratio * width_ratio, control.Font.Style);
            }
            cardWidth = Convert.ToInt32(71f * width_ratio);
            cardHeight = Convert.ToInt32(96f * height_ratio);
            user = new UserAccount();
            Random rand = new Random();
            Player me = new Player(playerName, BuyInAmount);
            playerList = new PlayerList();
            playerList.Add(me);
            lblName.Text = me.Name;
            List<int> AI = new List<int>(playerAmount);
            for (int i = 0; i < 3; i++)
            {
                AI.Add(i);
            }
            for (int i = 0; i < 4 - playerAmount; i++)
            {
                AI.Remove(rand.Next(AI.Count));
            }
            AI = shuffle(AI);
            for (int i = 1; i < playerAmount; i++)
            {
                playerList.Add(new AIPlayer(BuyInAmount, difficulty, AI[i - 1]));
                //labelListName[i].Text = playerList[i].Name;
            }
            FormInformation Information = new FormInformation(playerList);
            Information.StartPosition = FormStartPosition.CenterScreen;
            Information.ShowDialog();
            Information.Dispose();
            pokerTable = new Table(playerList);
            SoundPlayer sound = new SoundPlayer();
        }
Exemplo n.º 2
0
        public FormPoker(string playerName, int BuyInAmount, int playerAmount, int difficulty, UserAccount user)
        {
            InitializeComponent();
            this.Icon = new Icon("Poker.ico");
            this.playerName = playerName;
            if (playerName == null)
                throw new ArgumentOutOfRangeException();
            if (playerAmount < 2)
                throw new ArgumentOutOfRangeException();
            this.difficulty = difficulty;
            if (difficulty > 2)
                throw new ArgumentOutOfRangeException();
            this.BuyInAmount = BuyInAmount;
            this.playerAmount = playerAmount;
            timerCount = 0;
            //code to resize screen
            screenWidth = Screen.PrimaryScreen.Bounds.Width;
            screenHeight = Screen.PrimaryScreen.Bounds.Height;
            width_ratio = (screenWidth / 1366f);
            height_ratio = (screenHeight / 768f);
            SizeF scale = new SizeF(width_ratio, height_ratio);
            this.Scale(scale);
            foreach (Control control in this.Controls)
            {
                control.Font = new Font(control.Font.Name, control.Font.SizeInPoints * height_ratio * width_ratio, control.Font.Style);
            }

            cardWidth = Convert.ToInt32(71f * width_ratio);
            cardHeight = Convert.ToInt32(96f * height_ratio);
            this.user = new UserAccount(user);
            //add 3 archetytes randomly to list
            Random rand = new Random();
            Player me = new Player(playerName, BuyInAmount);
            playerList = new PlayerList();
            playerList.Add(me);
            lblName.Text = me.Name;
            List<int> AI = new List<int>(playerAmount);
            for (int i = 0; i < 3; i++)
            {
                AI.Add(i);
            }
            for (int i = 0; i < 4 - playerAmount; i++)
            {
                AI.Remove(rand.Next(AI.Count));
            }
            AI = shuffle(AI);
            for (int i = 1; i < playerAmount; i++)
            {
                playerList.Add(new AIPlayer(BuyInAmount, difficulty, AI[i - 1]));
                //labelListName[i].Text = playerList[i].Name;
            }
            FormInformation Information = new FormInformation(playerList);
            Information.StartPosition = FormStartPosition.CenterScreen;
            Information.ShowDialog();
            Information.Dispose();
            pokerTable = new Table(playerList);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Remove a player when the player busts out.
 /// </summary>
 /// <param name="player"></param>
 public void RemovePlayer(Player player)
 {
     if (player.ChipStack != 0)
         throw new InvalidOperationException();
     players.Remove(player);
 }
Exemplo n.º 4
0
 //add player to pot
 public void AddPlayer(Player player)
 {
     if(!playersInPot.Contains(player))
         playersInPot.Add(player);
 }
Exemplo n.º 5
0
 private void btnPlayers_Click(object sender, EventArgs e)
 {
     playerList.Clear();
     lbMain.Items.Clear();
     playerAmount = Convert.ToInt32(nudPlayers.Value);
     Player user = new Player("Player", 50000);
     playerList.Add(user);
     List<int> AI = new List<int>(playerAmount);
     for (int i = 0; i < 3; i++)
     {
         AI.Add(i);
     }
     for (int i = 0; i < 4 - playerAmount; i++)
     {
         AI.Remove(rand.Next(AI.Count));
     }
     AI = shuffle(AI);
     for (int i = 1; i < playerAmount; i++)
     {
         playerList.Add(new AIPlayer(50000, 1, AI[i - 1]));
     }
     pokerTable = new Table(playerList);
     foreach (Player player in pokerTable)
     {
         lbMain.Items.Add(player.Name);
     }
     lbMain.SelectedIndex = rand.Next(lbMain.Items.Count - 1) + 1;
 }