Пример #1
0
        public void EndGame()
        {
            List <Token> tokensBackToPlayer1 = new List <Token>();
            List <Token> tokensBackToPlayer2 = new List <Token>();

            for (int i = 1; i < 6; i++)
            {
                tokensBackToPlayer1 = board.PlayersList[0].EatTokensInSquare(board.SquaresList[i]);
                tokensBackToPlayer2 = board.PlayersList[1].EatTokensInSquare(board.SquaresList[i + 6]);
            }
            UpdateEllipsesInBoard();//to remove ellipses in row
            AddEllipsesInPool(1, tokensBackToPlayer1);
            AddEllipsesInPool(2, tokensBackToPlayer2);
            Services.Player.UpdateResult(board);
            PlayerDb.UpdatePlayerDb(Services.Player);

            var declarationGameResult = "";

            switch (board.GetResult())
            {
            case Result.WIN:
                declarationGameResult = Services.Player.Pseudo + " a gagné";
                break;

            case Result.LOSE:
                declarationGameResult = board.PlayersList[1].Pseudo + " a gagné";
                break;

            case Result.DRAW:
                declarationGameResult = "Partie nulle";
                break;
            }

            MessageBoxResult result = MessageBox.Show(board.PlayersList[0].Pseudo + " a " + board.PlayersList[0].Score + " points\n"
                                                      + board.PlayersList[1].Pseudo + " a " + board.PlayersList[1].Score + " points\n"
                                                      + "\n" + declarationGameResult.ToUpper()
                                                      + "\nVous voulez rejouer ?",
                                                      "Résultat",
                                                      MessageBoxButton.YesNo,
                                                      MessageBoxImage.Question,
                                                      MessageBoxResult.No);

            switch (result)
            {
            case MessageBoxResult.Yes:
                this.Close();
                Services.NoveltyOfGame = NoveltyOfGame.NEW;
                PlayGame game = new PlayGame();
                game.ShowDialog();
                break;

            case MessageBoxResult.No:
                this.Close();
                break;
            }
        }
Пример #2
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            //save the enter info into the properties of object ThisPlayer
            ThisPlayer.FullName  = txbFullName.Text;
            ThisPlayer.IsEnabled = (cobEnabled.Text == "Oui") ? 1 : 0;
            ThisPlayer.IsAdmin   = (cobAdmin.Text == "Oui") ? 1 : 0;

            PlayerDb.UpdatePlayerDb(ThisPlayer);                              //to save player with new info in database
            PlayerInfo.dataGrid.ItemsSource = Services.PlayerListWithRanking; //reload the playerlist from database
            MessageBox.Show("Enregistré !");
        }
Пример #3
0
        public void EndGame()
        {
            List <Token> tokensBackToPlayer1 = new List <Token>();
            List <Token> tokensBackToPlayer2 = new List <Token>();

            for (int i = 1; i < 6; i++)
            {
                tokensBackToPlayer1 = board.PlayersList[0].EatTokensInSquare(board.SquaresList[i]);
                tokensBackToPlayer2 = board.PlayersList[1].EatTokensInSquare(board.SquaresList[i + 6]);
            }
            UpdateEllipsesInBoard();//to remove ellipses in row
            AddEllipsesInPool(1, tokensBackToPlayer1);
            AddEllipsesInPool(2, tokensBackToPlayer2);
            Services.Player.UpdateResult(board);
            PlayerDb.UpdatePlayerDb(Services.Player);

            MessageBoxResult result = MessageBox.Show(board.PlayersList[0].Pseudo + " a " + board.PlayersList[0].Score + " points\n"
                                                      + board.PlayersList[1].Pseudo + " a " + board.PlayersList[1].Score + " points\n"
                                                      + Services.Player.Pseudo + " " + board.GetResult().ToString()
                                                      + "\nVous voulez rejouer ?",
                                                      "Résultat",
                                                      MessageBoxButton.YesNo,
                                                      MessageBoxImage.Question,
                                                      MessageBoxResult.No);

            switch (result)
            {
            case MessageBoxResult.Yes:
                this.Close();
                PlayGame game = new PlayGame();
                game.ShowDialog();
                break;

            case MessageBoxResult.No:
                this.Close();
                break;
            }
        }