コード例 #1
0
ファイル: Game.cs プロジェクト: KunyiLiu/Mafia_on_Teams
        public void AssignVoteToPlayers(string voteId)
        {
            // If the vote is not within active players, assign null to the Vote property
            if (!ActivePlayers.Select(p => p.Id).Contains(voteId))
            {
                voteId = null;
            }

            foreach (Player player in ActivePlayers)
            {
                player.Vote = voteId;
            }
        }
コード例 #2
0
        public void StartRound()
        {
            if (GameState != RoboGameState.Ready)
            {
                return;
            }

            OnGameStateChange(EventArgs <RoboGameState> .create(RoboGameState.DrawingCards));

            foreach (RoboPlayerPlugin elem in ActivePlayers)
            {
                if (elem.Player.PlayerState != RoboPlayerState.Ready)
                {
                    continue;
                }

                if (!elem.Player.StartRound())
                {
                    elem.Player.PlayerState = RoboPlayerState.Dead;
                    continue;
                }

                (elem.PluginSettings as RoboPlayerPluginSettings).PlayerCollision = Interaction == RoboPlayerInteraction.Blocked;

                Action <RoboPosition, ICollection <RoboCard>, IEnumerable <RoboPosition> > pluginCaller = elem.StartRound;
                pluginCaller.BeginInvoke(
                    elem.Player.Position.Clone() as RoboPosition,
                    elem.Player.Cards,
                    ActivePlayers.Select(plugin => plugin.Player.Position.Clone() as RoboPosition),
                    null,
                    elem);

                elem.Player.PlayerState = RoboPlayerState.Thinking;
            }

            OnGameStateChange(EventArgs <RoboGameState> .create(RoboGameState.ChoosingCards));

            if (ActivePlayers.Count(elem => elem.Player.PlayerState == RoboPlayerState.Thinking) == 0)
            {
                OnGameStateChange(EventArgs <RoboGameState> .create(RoboGameState.Stopped));
            }
        }
コード例 #3
0
        private void DoPlayingCards()
        {
            if (GameState != RoboGameState.ChoosingCards || !IsChoosingCardsFinished)
            {
                return;
            }

            GameState = RoboGameState.PlayingCards;

            for (int i = 0; i < 5; i++)
            {
                foreach (RoboPlayerPlugin elem in ActivePlayers.OrderBy(elem => elem.Player.TimeEndRound.Ticks))
                {
                    if (elem.Player.PlayerState != RoboPlayerState.Decided)
                    {
                        continue;
                    }
                    RoboUtils.PlayCardCore(GetBoard(Board, elem.Player, ActivePlayers.Select(plugin => plugin.Player)), elem.Player.ChosenCards[i], elem.Player.Position);
                    elem.Player.TotalPlayedCards++;

                    if (Board.GetField(elem.Player.Position).IsDestination)
                    {
                        elem.Player.PlayerState = RoboPlayerState.Finished;
                    }
                    else if (elem.Player.Position.IsDead)
                    {
                        elem.Player.PlayerState = RoboPlayerState.Dead;
                    }
                    else if (i == 4)
                    {
                        elem.Player.PlayerState = RoboPlayerState.Ready;
                    }
                }
            }

            GameState = RoboGameState.Ready;

            Action starter = StartRound;

            starter.BeginInvoke(null, starter);
        }
コード例 #4
0
ファイル: Game.cs プロジェクト: KunyiLiu/Mafia_on_Teams
        public void AssignTargetToPlayers(string targetId, Role playerRole)
        {
            if (!ActivePlayers.Select(p => p.Id).Contains(targetId))
            {
                targetId = null;
            }

            if (playerRole == Role.Mafia)
            {
                foreach (Mafia mafia in Mafias)
                {
                    mafia.Target = targetId;
                }
            }
            else if (playerRole == Role.Doctor)
            {
                foreach (Doctor doctor in Doctors)
                {
                    doctor.Target = targetId;
                }
            }
        }