コード例 #1
0
        public static void newGame(int nbrPlayers, String name)
        {
            Properties.Settings.Default.nbrPlayers = nbrPlayers;

            Game.Instance.addPlayer(name, true, 0);

            for (int i = 1; i < nbrPlayers; i++)
            {
                Game.Instance.addPlayer(Properties._string.Player + i, false, i); //Test
            }
            game_window gw = new game_window();

            gameView        = gw;
            gameView.Shown += new EventHandler(gameViewLoaded);
            gameView.ShowDialog();
        }
コード例 #2
0
        //play a turn for AI , if it's human it will does nothing, the human has to trigger play card effect
        private static void PlayTurn()
        {
            //if the current player is protected at the beggining of the turn , we have to remove his immunity (because it only last one turn)
            if (currentPlayer.HMProtected)
            {
                currentPlayer.HMProtected = false;
            }

            //check if the round is over
            if (Game.Instance.play_Deck.Count == 0 || Game.Instance.playersInCurrentRound.Count == 1)
            {
                Player winner = getWinnerOfRound();
                winner.nbMarker           += 1;
                Game.Instance.roundNumber += 1;
                checkWinner(); // is the game over ?

                //check if the game is finished
                if (!Game.Instance.isFinished)
                {
                    Boolean mutedTemp  = GameController.gameView.muted;
                    double  mainTemp   = GameController.gameView.mainVolume;
                    double  musicTemp  = GameController.gameView.musicVolume;
                    double  effectTemp = GameController.gameView.effectVolume;

                    game_window newGameView = new game_window(mutedTemp, mainTemp, musicTemp, effectTemp);
                    newGameView.Shown += new EventHandler(gameViewLoaded);

                    GameController.gameView.ambianceSound.Stop();
                    GameController.gameView.ambianceSound.Close();
                    GameController.gameView.Close();
                    GameController.gameView.Dispose();
                    GameController.gameView = newGameView;

                    newGameView.ShowDialog();
                }
                else
                {
                    GameController.gameView.backToMenu();
                }
            }
            else
            {
                if (currentPlayer.isHuman)
                {
                    GameController.gameView.showIndications(Properties._string.Take1CardFromTheDeck, "deck");
                }
                else
                {
                    Thread.Sleep(900);
                    Player player = Game.Instance.playersInCurrentRound.Find(x => x.indexPlayer == currentPlayer.indexPlayer);
                    GameController.PickCard(player);
                    Thread.Sleep(900);

                    if (CardEffect.MustPlayCountess(player)) //must play the countess
                    {
                        //tell all AIs what has been played
                        for (int p = 0; p < Game.Instance.players.Count; p++)
                        {
                            Player otherPlayer = Game.Instance.players[p];
                            if (!otherPlayer.isHuman)
                            {
                                otherPlayer.ai.CardPlayed(player.indexPlayer, 7);
                            }
                        }
                    }
                    else //normal turn
                    {
                        AI.Decision decision = player.ai.Decide();
                        Card        card     = player.player_Deck[decision.chosenCard];
                        GameController.gameView.PlayCard(card, player);
                        player.playCard(card);
                        //tell all AIs what has been played
                        for (int p = 0; p < Game.Instance.players.Count; p++)
                        {
                            Player otherPlayer = Game.Instance.players[p];
                            if (!otherPlayer.isHuman)
                            {
                                otherPlayer.ai.CardPlayed(player.indexPlayer, card.value);
                            }
                        }
                        card.Effect(player, Game.Instance.players[decision.guessPlayer], decision.guessCard);
                    }
                    NextCurrentPlayer();
                    PlayTurn();
                }
            }
        }