Ejemplo n.º 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;
            }
        }
Ejemplo n.º 2
0
 private void btnPlaySavedGame_Click(object sender, RoutedEventArgs e)
 {
     if (BoardDb.CheckIfBoardDbContainsPlayerId(Services.Player.PlayerId))
     {
         Services.NoveltyOfGame = NoveltyOfGame.OLD;
         Services.Player.GetSavedGameFromDb();
         PlayGame game = new PlayGame();
         game.ShowDialog();
     }
     else
     {
         MessageBox.Show("Vous n'avez pas encore de partie sauvegardée");
     }
 }
Ejemplo n.º 3
0
        private void ButtonOK_Click(object sender, RoutedEventArgs e)
        {
            if (txbPseudo.Text.Trim( ) == "")
            {
                MessageBox.Show("Le pseudo ne doit pas être vide");
            }
            Services.PseudoPlayer2 = txbPseudo.Text;

            this.Hide();
            Services.NoveltyOfGame = NoveltyOfGame.NEW;
            PlayGame game = new PlayGame();

            game.ShowDialog();
        }
Ejemplo n.º 4
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;
            }
        }