public override string GetInitMessage(GameCommand command) { var player = command.GetGameInfo <GameInfo>().GetPlayerByIdentity(IdentityType.Witcher).FirstOrDefault(); if (player == null) { return(null); } var witcher = player as Witcher; string content = ""; var killed = command.GetGameInfo <GameInfo>().WolferWillKilled; if (witcher != null) { if (killed != null) { content += "今天晚上被杀害的玩家是{0},".Format(killed.PlayerNickName); if (witcher.Antidote > 0) { content += "是否使用解药 (-save),"; } } if (witcher.Poison > 0) { var list = command.GetGameInfo <GameInfo>().BuildCanKillList(); content += "是否使用毒药 (-poison {序号})\n" + list.ToIndexMessage(); } } content += "\n 使用命令 (-empty) 表示空过不操作!"; return(content); }
/// <summary> /// 检测身份是否对上 /// </summary> /// <param name="command"></param> /// <returns></returns> public bool CheckIdentity(GameCommand command) { IPlayer player = command.GetGameInfo <GameInfo>().GetPlayerById(command.GameInput.Sender.Id); if (player == null) { return(false); } return(command.GetGameInfo <GameInfo>().GetPlayerByIdentity(IdentityType).Contains(player)); }
/// <summary> /// 是否需要空过 /// </summary> /// <param name="command"></param> /// <returns></returns> public override bool IsEmpty(GameCommand command) { var hunter = command.GetGameInfo <GameInfo>().GetPlayerByIdentity(IdentityType.Hunter).FirstOrDefault(); if (command.GetGameInfo <GameInfo>().PoisonKilled == hunter || command.GetGameInfo <GameInfo>().WolferWillKilled == hunter) { return(false); } else { return(true); } }
/// <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); } }
public override string GetInitMessage(GameCommand command) { var list = command.GetGameInfo <GameInfo>().BuildCanKillList(); string content = "请输入要查看的玩家的身份序号(-check {序号}) : \n" + list.ToIndexMessage(); return(content); }
/// <summary> /// 阶段初始化 /// </summary> /// <param name="command"></param> /// <returns></returns> public override async Task Init(GameCommand command) { var players = command.GetGameInfo <GameInfo>().GetPlayerByIdentity(IdentityType); await command.GameInput.ReplyGroup(StepMessage); //针对组 if (IsToGroup) { var msg = GetInitMessage(command); if (msg != null) { await command.GameInput.ReplyGroup(GetInitMessage(command)); } } else { //await command.GameInput.ReplyTemp(GetInitMessage()); string content = GetInitMessage(command); foreach (var item in players) { await command.GameInput.SendTemp(content, item.PlayerId); } } if ((IdentityType != IdentityType.None && players.Count() == 0) || IsEmpty(command)) { await command.Empty(NextState); } else { command.IsRunNextState = false; } }
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; } }
public override string GetInitMessage(GameCommand command) { if (!IsEmpty(command)) { return("您已经被杀害,是否使用技能。请选择目标(-gun {序号}) : \n" + command.GetGameInfo <GameInfo>().BuildCanKillList().ToIndexMessage()); } return("今晚和你没关系!"); }
public override string GetInitMessage(GameCommand command) { var players = ""; deaths.Clear(); deaths.AddRange(command.GetGameInfo <GameInfo>().GetAllKilledPlayer()); players = deaths.JoinToString(",", p => p.PlayerNickName); return("昨晚死亡的玩家有 : {0}\n".Format(players) + "开始尽情讨论, 输入(-next) 进入下一个阶段!\n"); }
public async override Task DoAction(GameCommand command) { var commandItem = command.Commands[0]; if (commandItem.Command.Equals("start")) { await command.GameInput.ReplyGroupImg(command.GetGameInfo <GameInfo>().GetImageStream()); Next(command); } }
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); } } }
/// <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); } }
public override async Task DoAction(GameCommand command) { var witcher = command.GetGameInfo <GameInfo>().GetPlayerByIdentity(IdentityType.Witcher).FirstOrDefault() as Witcher; if (!CheckIdentity(command)) { await command.GameInput.ReplyTemp("只有女巫才可以操作!"); return; } if (command.Commands.Where(p => p.Command.Equals("empty")).Count() > 0) { Next(command); return; } foreach (var item in command.Commands) { //救人命令 if (item.Command.Equals("save") && witcher.Antidote > 0) { witcher.Antidote--; command.GetGameInfo <GameInfo>().WolferWillKilled = null; await command.GameInput.ReplyTemp("成功救下!"); } else if (item.Command.Equals("poison") && witcher.Poison > 0) { int index = Convert.ToInt32(item.Contents.First()); //获取期望毒杀的目标 var player = command.GetGameInfo <GameInfo>().GetPlayer(index); if (player != null) { command.GetGameInfo <GameInfo>().PoisonKilled = player; witcher.Poison--; } } } Next(command); }
public override async Task DoAction(GameCommand command) { //第一天 if (command.GetGameInfo <GameInfo>().Date == 1) { command.GameState = GameState.SheriffSpeekStep; } else { command.GameState = GameState.TalkAboutStep; } command.IsRunNextState = true; }
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("命令错误!"); } }
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("命令错误!"); } }
public override string GetInitMessage(GameCommand command) { command.GetGameInfo <GameInfo>().ResetVoted(); return("开始进行投票 输入 (-next) 进入下一个阶段, (-vote {序号}) 进行投票.\n" + command.GetGameInfo <GameInfo>().CanKilledList.ToIndexMessage()); }
public override string GetInitMessage(GameCommand command) { var killlist = command.GetGameInfo <GameInfo>().BuildCanKillList(); return("进入狼人杀人阶段 输入(-next 进入下一个阶段), 狼人请把要杀害的玩家信息通过临时会话发送给我! (-kill {序号}) : \n请输入序号选择要杀害的玩家:\n" + killlist.ToIndexMessage()); }
public override string GetInitMessage(GameCommand command) { bool res = command.GetGameInfo <GameInfo>().IsGameOver().Value; return("游戏结束 狼人 : {0}, 神民 : {1}".Format(res ? "失败" : "胜利", res ? "胜利" : "失败")); }
public override string GetInitMessage(GameCommand command) { return("请选择警徽的移交对象! 输入 (-move {序号}) : \n " + command.GetGameInfo <GameInfo>().BuildCanKillList().ToIndexMessage()); }
public override bool IsEmpty(GameCommand command) { var player = command.GetGameInfo <GameInfo>().GetPlayerByIdentity(IdentityType.Witcher).FirstOrDefault() as Witcher; return(player == null || (player.Antidote == 0 && player.Poison == 0)); }
public override bool IsEmpty(GameCommand command) { var prophet = command.GetGameInfo <GameInfo>().GetPlayerByIdentity(IdentityType.Propheter).FirstOrDefault(); return(prophet == null); }
public override string GetInitMessage(GameCommand command) { command.GetGameInfo <GameInfo>().ResetVoted(); return("输入命令 (-next) 进入下一个阶段, 输入命令 (-vote {序号}) 进行投票 : \n" + command.GetGameInfo <GameInfo>().BuildCanKillList().ToIndexMessage()); }
public override string GetInitMessage(GameCommand command) { command.GameInfo.Init(command.GameInput); return("请输入 -p row col 来下子, -reset 来悔棋 -expend row col 扩充, 当前选手是 : {0}".Format(command.GetGameInfo <GameInfo>().DoPlayer.PlayerNickName)); }
public async override Task DoAction(GameCommand command) { if (!await CheckPlayer(command)) { return; } var gameInfo = command.GetGameInfo <GameInfo>(); var player = gameInfo.GetPlayerById(command.GameInput.Sender.Id); var commandItem = command.Commands[0]; //扩充棋盘 if (commandItem.Command.Equals("expend")) { var r = Convert.ToInt32(commandItem.Contents[0]); var c = Convert.ToInt32(commandItem.Contents[1]); await gameInfo.Expend(r, c); return; } if (player != gameInfo.DoPlayer) { if (commandItem.Command.Equals("reset")) { if (!CanReset) { await command.GameInput.ReplyGroup("不能连续悔棋!"); return; } await gameInfo.ResetLast(LastR, LastC); await command.GameInput.ReplyGroupImg(gameInfo.GetImageStream()); CanReset = false; return; } await command.GameInput.ReplyGroup("当前不是你的回合!"); return; } if (commandItem.Command.Equals("p")) { var r = Convert.ToInt32(commandItem.Contents[0]); var c = Convert.ToInt32(commandItem.Contents[1]); var res = await gameInfo.SetLayout(r, c); if (!res) { await command.GameInput.ReplyGroup("坐标错误!"); return; } LastR = r; LastC = c; CanReset = true; await command.GameInput.ReplyGroupImg(gameInfo.GetImageStream()); var vectorer = gameInfo.IsOver(); if (vectorer != null) { await command.GameInput.ReplyGroup("游戏结束 -> 胜利者 : {0}".Format(vectorer.PlayerNickName)); Next(command); } } }