Exemplo n.º 1
0
        private void GetStatistics()
        {
            gameStats.InitializeStatistics();

            lblAttacksWonDisplay.Text       = gameStats.attacksWon.ToString();
            lblCardsDrawnDisplay.Text       = gameStats.cardsDrawn.ToString();
            lblDefensesRepelledDisplay.Text = gameStats.defensesRepelled.ToString();
            lblGamesWonDisplay.Text         = gameStats.gamesWon.ToString();
            lblGamesLostDisplay.Text        = gameStats.gamesLost.ToString();
        }
Exemplo n.º 2
0
        // frmGameGUI
        public frmGameGUI(frmMainMenu mainMenu)
        {
            menuForm = mainMenu;
            InitializeComponent();
            this.Show();

            // Read config file
            if (!File.Exists("./DurakConfiguration"))
            {
                File.Create("./DurakConfiguration").Dispose();
            }
            TextReader tr = new StreamReader("./DurakConfiguration");

            HumanName = tr.ReadLine();
            AiName    = tr.ReadLine();
            String isCardVisible = tr.ReadLine();

            if (!String.IsNullOrEmpty(isCardVisible))
            {
                aiCardsVisible = bool.Parse(isCardVisible);
            }

            tr.Close();

            // The DurakGame constructor creates a game instance
            // with one human and one AI player, and deals hands out to
            // both of them.
            // By passing this form as a parameter, it can receive data from
            // the game and have GUI events triggered by it
            durakGame = new DurakGame(this);
            // Capture players from DurakGame
            HumanPlayer = durakGame.Players[0];
            AiPlayer    = durakGame.Players[1];
            // Set Names
            if (!String.IsNullOrEmpty(HumanName))
            {
                HumanPlayer.Name = HumanName;
            }
            if (!String.IsNullOrEmpty(AiName))
            {
                AiPlayer.Name = AiName;
            }
            lblPlayerName.Text = HumanPlayer.Name;
            lblAIName.Text     = AiPlayer.Name;
            //Throw In events
            durakGame.OnPuttingDown       += PuttingDown;
            durakGame.PuttingDownComplete += PuttingDownComplete;

            gameStats.InitializeStatistics();

            this.InitiateGame();
        }