예제 #1
0
 public override async Task DoAction(GameCommand command)
 {
     if (command.GetCommandIndex(0).Command.Equals("start"))
     {
         Next(command);
     }
 }
예제 #2
0
        public override async Task DoAction(GameCommand command)
        {
            var commandItem = command.GetCommandIndex(0);

            if (commandItem.Command.Equals("next"))
            {
                Next(command);
            }
        }
예제 #3
0
        /// <summary>
        /// 夜晚阶段执行
        /// </summary>
        /// <param name="command"></param>
        public override async Task DoAction(GameCommand command)
        {
            var commandItem = command.GetCommandIndex(0);

            if (commandItem.Command.Equals("next"))
            {
                command.GetGameInfo <GameInfo>().GetAllKilledPlayer().ForEach(p => p.IsAlive = false);
                command.GetGameInfo <GameInfo>().InitKilleds();
                command.GetGameInfo <GameInfo>().Date++;

                Next(command);
            }
        }
예제 #4
0
        public override async Task DoAction(GameCommand command)
        {
            var commandItem = command.GetCommandIndex(0);

            if (commandItem.Command.Equals("next"))
            {
                //获取投票结果
                var target = command.GetGameInfo <GameInfo>().GetMaxVotedPlayer();
                if (target.Key != null)
                {
                    await command.GameInput.ReplyGroup("玩家{0}被白嫖死了!".Format(target.Key.PlayerNickName));

                    target.Key.IsAlive = false;
                }

                bool?isOver = !command.GetGameInfo <GameInfo>().IsGameOver();
                if (isOver != null)
                {
                    command.GameState      = GameState.Over;
                    command.IsRunNextState = true;
                    return;
                }

                if (command.GetGameInfo <GameInfo>().GetAllKilledPlayer().Where(p => p.IsSheriff).Count() > 0)
                {
                    command.GameState      = GameState.SheriffMoveStep;
                    command.IsRunNextState = true;
                }
                else
                {
                    Next(command);
                }
            }
            else if (commandItem.Command.Equals("vote"))
            {
                var     index  = Convert.ToInt32(commandItem.Contents.First());
                IPlayer player = command.GetGameInfo <GameInfo>().GetPlayer(index);
                IPlayer self   = command.GetGameInfo <GameInfo>().GetPlayerById(command.GameInput.Sender.Id);
                if (self == null)
                {
                    await command.GameInput.ReplyTemp("您没有参与游戏,或则您已经出局!");

                    return;
                }
                self.VotedPlayer = player;
            }
        }
예제 #5
0
        public override async Task DoAction(GameCommand command)
        {
            var commandItem = command.GetCommandIndex(0);

            if (commandItem.Command.Equals("next"))
            {
                var list = new List <IPlayer>();
                command.GetGameInfo <GameInfo>().CanKilledList.ForEach(p => {
                    if (p.VotedPlayer != null)
                    {
                        list.Add(p.VotedPlayer);
                    }
                });
                //获取票数最多的
                var target = (from item in list group item by item into gro orderby gro.Count() descending select new { Player = gro.Key, Count = gro.Count() }).FirstOrDefault();
                if (target == null)
                {
                    await command.GameInput.ReplyGroup("竞选失败请认真投票!");

                    return;
                }
                target.Player.IsSheriff = true;
                await command.GameInput.ReplyGroup("恭喜玩家 {0}, 被选为警长, 荣获票数 : {1} ".Format(target.Player.PlayerNickName, target.Count));

                Next(command);
            }
            else if (commandItem.Command.Equals("vote"))
            {
                var     index  = Convert.ToInt32(commandItem.Contents.First());
                IPlayer player = command.GetGameInfo <GameInfo>().GetPlayer(index);
                IPlayer self   = command.GetGameInfo <GameInfo>().GetPlayerById(command.GameInput.Sender.Id);
                if (self == null)
                {
                    await command.GameInput.ReplyTemp("您没有参与游戏,或则您已经出局!");

                    return;
                }
                self.VotedPlayer = player;
                await command.GameInput.ReplyGroup("玩家 : {0} -> {1}".Format(self.PlayerNickName, player == null ? "" : player.PlayerNickName));
            }
        }
        public override async Task DoAction(GameCommand command)
        {
            var commandItem = command.GetCommandIndex(0);

            if (commandItem.Command.Equals("move"))
            {
                var     index  = Convert.ToInt32(commandItem.Contents.First());
                IPlayer target = command.GetGameInfo <GameInfo>().GetPlayer(index);
                if (target == null && command.GetGameInfo <GameInfo>().GetAllKilledPlayer().Contains(target))
                {
                    await command.GameInput.ReplyGroup("请输入正确的移交对象!");

                    return;
                }
                else
                {
                    target.IsSheriff = true;
                    Next(command);
                }
            }
        }
예제 #7
0
        /// <summary>
        /// 狼人杀人阶段
        /// </summary>
        /// <param name="command"></param>
        public override async Task DoAction(GameCommand command)
        {
            var wolfers = command.GetGameInfo <GameInfo>().GetWolfers(true);

            var commandItem = command.GetCommandIndex(0);

            IPlayer self = command.GetGameInfo <GameInfo>().GetPlayerById(command.GameInput.Sender.Id);

            if (!CheckIdentity(command))
            {
                await command.GameInput.ReplyTemp("只有狼人才能操作!");

                return;
            }
            if (commandItem.Command.Equals("kill"))
            {
                int     index  = Convert.ToInt32(commandItem.Contents.FirstOrDefault());
                IPlayer player = command.GetGameInfo <GameInfo>().GetPlayer(index);
                (self as Wolfer).SetTarget(player);
                if (player != null)
                {
                    await command.GameInput.ReplyTemp("您投票 -> {0} 玩家成功!".Format(player.PlayerNickName));
                }
            }
            if (commandItem.Command.Equals("next") || wolfers.Where(p => (p as Wolfer).IsOptioned == false).Count() == 0)
            {
                var list = new List <IPlayer>();
                wolfers.ForEach(p =>
                {
                    if ((p as Wolfer).KillTargetPlayer != null)
                    {
                        list.Add((p as Wolfer).KillTargetPlayer);
                    }
                });
                ///如果狼人操作完成
                command.GetGameInfo <GameInfo>().WolferWillKilled = (from item in list group item by item into gro orderby gro.Count() descending select gro.Key).FirstOrDefault();
                wolfers.ForEach(p => (p as Wolfer).Reset());
                Next(command);
            }
        }
예제 #8
0
        public override async Task DoAction(GameCommand command)
        {
            if (!CheckIdentity(command))
            {
                await command.GameInput.ReplyTemp("只有预言家才可以操作!");

                return;
            }
            var commandItem = command.GetCommandIndex(0);

            if (commandItem.Command.Equals("check"))
            {
                int     index  = Convert.ToInt32(commandItem.Contents.First());
                IPlayer player = command.GetGameInfo <GameInfo>().GetPlayer(index);
                await command.GameInput.ReplyTemp("这个人的身份是 : {0}".Format(player.Identity == IdentityType.Wolfer ? "狼" : "好"));

                Next(command);
            }
            else
            {
                await command.GameInput.ReplyTemp("命令错误!");
            }
        }
예제 #9
0
        public override async Task DoAction(GameCommand command)
        {
            if (!CheckIdentity(command))
            {
                await command.GameInput.ReplyTemp("只有猎人才可以操作!");

                return;
            }

            var commandItem = command.GetCommandIndex(0);

            if (commandItem.Command.Equals("gun"))
            {
                int index  = Convert.ToInt32(commandItem.Contents.FirstOrDefault());
                var player = command.GetGameInfo <GameInfo>().CanKilledList[index];
                command.GetGameInfo <GameInfo>().GunKilled = player;
                command.IsRunNextState = true;
                command.GameState      = NextState;
            }
            else
            {
                await command.GameInput.ReplyTemp("命令错误!");
            }
        }