Ejemplo n.º 1
0
        //obtains the premade game object, begin the game
        public frmGameWindow(Player[] players, int deckSize)
        {
            InitializeComponent();
            //create the deck
            game = new Durak(deckSize);
            //shuffling the deck, setting the players and AIs

            Players.InitializeGame(players, true);
            game.SetPlayers(players);

            //  Get reference to the game table (Card container)

            game.Table.InPlay.CardsChanged += hand_CardChanged;
            //lblTrump.Text = game.TrumpSuit();
            cbTrump.Card = game.TrumpCard;

            player = Players.GetHumanPlayer();
            player.PlayHand.CardsChanged += hand_CardChanged;
            //Dealing the hands
            game.DealHands();
            attacker = Players.GetCurrentPlayer();   //  Determine attacker
            defender = Players.PeakNextPlayer();     //  Determine defender

            lblDeckSize.Text = game.GetCardsRemaining().ToString();
        }
Ejemplo n.º 2
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            int    deckSize    = 0;
            int    playerCount = 0;
            String playerName  = "";

            if (cbxPlayers.SelectedIndex != -1)
            {
                if (rbtn20.Checked)
                {
                    deckSize = 20;
                }
                else if (rbtn36.Checked)
                {
                    deckSize = 36;
                }
                else if (rbtn52.Checked)
                {
                    deckSize = 52;
                }

                Int32.TryParse(cbxPlayers.SelectedItem.ToString(), out playerCount);

                if (txtName.Text.Length > 0)
                {
                    Durak newGame = new Durak(deckSize);

                    //Creates an array of players. Can be between 2 and 7
                    Player[] players;

                    List <Player> playerList = new List <Player>();
                    playerName = txtName.Text;
                    playerList.Add(new Player(playerName));
                    for (int i = 0; i < playerCount - 1; i++)
                    {
                        playerList.Add(new Player("AI " + i));
                    }
                    //Sets each player in the arary.
                    players = playerList.ToArray();

                    //Setting the players. Must be done before starting the game.
                    newGame.SetPlayers(players);
                    //Close the main menu, and open the game window
                    this.Hide();
                    var gameWindow = new frmGameWindow();
                    gameWindow.Closed += (s, args) => this.Close();
                    gameWindow.Show();
                }
            }
        }