Exemplo n.º 1
0
        public override void Initialize(GameInfo gameInfo, GameSetting gameSetting)
        {
            base.Initialize(gameInfo, gameSetting);

            comingoutDay = new Random().Next(3) + 1;
            isCameout = false;
        }
Exemplo n.º 2
0
 public virtual void Initialize(GameInfo gameInfo, GameSetting gameSetting)
 {
     GameInfoMap.Clear();
     GameSetting = gameSetting;
     Day = gameInfo.Day;
     GameInfoMap[Day] = gameInfo;
     MyRole = gameInfo.Role;
     Me = gameInfo.Agent;
     return;
 }
Exemplo n.º 3
0
        public override void Update(GameInfo gameInfo)
        {
            base.Update(gameInfo);

            List<Talk> talkList = gameInfo.TalkList;
            bool existInspectResult = false;

            // talkListからCO,占い結果の抽出
            for (int i = readTalkListNum; i < talkList.Count; i++)
            {
                Talk talk = talkList[i];
                Utterance utterance = new Utterance(talk.Content);
                switch (utterance.Topic)
                {
                    // カミングアウトの発話の場合
                    case Topic.COMINGOUT:
                        agi.ComingoutMap[talk.Agent] = utterance.Role;
                        break;
                    // 占い結果の発話の場合
                    case Topic.DIVINED:
                        // AGIのJudgeListに結果を加える
                        Agent seerAgent = talk.Agent;
                        Agent inspectedAgent = utterance.Target;
                        Species inspectResult = (Species)utterance.Result;
                        Judge judge = new Judge(Day, seerAgent, inspectedAgent, inspectResult);
                        agi.AddInspectJudgeList(judge);
                        existInspectResult = true;
                        break;
                }
            }
            readTalkListNum = talkList.Count;

            // 新しい占い結果があれば投票先を変える.(新たに黒判定が出た,または投票先のプレイヤーに白判定が出た場合)
            if (existInspectResult)
            {
                SetPlanningVoteAgent();
            }
        }
Exemplo n.º 4
0
        public object Recieve(Packet packet)
        {
            GameInfo gameInfo = lastGameInfo;
            GameSetting gameSetting = packet.GameSetting;

            if (packet.GameInfo != null)
            {
                gameInfo = packet.GameInfo.ToGameInfo();
                lastGameInfo = gameInfo;
            }

            if (packet.TalkHistory != null)
            {
                Talk lastTalk = null;
                if (gameInfo.TalkList != null && gameInfo.TalkList.Count != 0)
                {
                    lastTalk = gameInfo.TalkList[gameInfo.TalkList.Count - 1];
                }
                foreach (var talk in packet.TalkHistory)
                {
                    if (IsAfter(talk, lastTalk))
                    {
                        gameInfo.TalkList.Add(talk.ToTalk());
                    }
                }
            }

            if (packet.WhisperHistory != null)
            {
                Talk lastWhisper = null;
                if (gameInfo.WhisperList != null && gameInfo.WhisperList.Count != 0)
                {
                    lastWhisper = gameInfo.WhisperList[gameInfo.WhisperList.Count - 1];
                }
                foreach (var whisper in packet.WhisperHistory)
                {
                    if (IsAfter(whisper, lastWhisper))
                    {
                        gameInfo.WhisperList.Add(whisper.ToTalk());
                    }
                }
            }

            object returnObject = null;
            switch (packet.Request)
            {
                case Request.INITIALIZE:
                    Running = true;
                    player.Initialize(gameInfo, gameSetting);
                    break;
                case Request.DAILY_INITIALIZE:
                    player.Update(gameInfo);
                    player.DayStart();
                    break;
                case Request.DAILY_FINISH:
                    player.Update(gameInfo);
                    break;
                case Request.NAME:
                    if (PlayerName == null)
                    {
                        returnObject = player.Name;
                        if (returnObject == null)
                        {
                            returnObject = player.GetType().Name;
                        }
                    }
                    else
                    {
                        returnObject = PlayerName;
                    }
                    break;
                case Request.ROLE:
                    if (RequestRole != null)
                    {
                        returnObject = RequestRole.ToString();
                    }
                    else
                    {
                        returnObject = "none";
                    }
                    break;
                case Request.ATTACK:
                    player.Update(gameInfo);
                    returnObject = player.Attack();
                    break;
                case Request.TALK:
                    player.Update(gameInfo);
                    returnObject = player.Talk();
                    if (returnObject == null)
                    {
                        returnObject = Talk.SKIP;
                    }
                    break;
                case Request.WHISPER:
                    player.Update(gameInfo);
                    returnObject = player.Whisper();
                    if (returnObject == null)
                    {
                        returnObject = Talk.SKIP;
                    }
                    break;
                case Request.DIVINE:
                    player.Update(gameInfo);
                    returnObject = player.Divine();
                    break;
                case Request.GUARD:
                    player.Update(gameInfo);
                    returnObject = player.Guard();
                    break;
                case Request.VOTE:
                    player.Update(gameInfo);
                    returnObject = player.Vote();
                    break;
                case Request.FINISH:
                    player.Update(gameInfo);
                    Finish();
                    break;
                default:
                    break;
            }
            return returnObject;
        }
 public override sealed void Initialize(GameInfo gameInfo, GameSetting gameSetting)
 {
     Role? myRole = gameInfo.Role;
     switch (myRole)
     {
         case Role.VILLAGER:
             rolePlayer = VillagerPlayer;
             break;
         case Role.SEER:
             rolePlayer = SeerPlayer;
             break;
         case Role.MEDIUM:
             rolePlayer = MediumPlayer;
             break;
         case Role.BODYGUARD:
             rolePlayer = BodyguardPlayer;
             break;
         case Role.POSSESSED:
             rolePlayer = PossessedPlayer;
             break;
         case Role.WEREWOLF:
             rolePlayer = WerewolfPlayer;
             break;
         default:
             rolePlayer = VillagerPlayer;
             break;
     }
     rolePlayer.Initialize(gameInfo, gameSetting);
 }
 public override sealed void Update(GameInfo gameInfo)
 {
     rolePlayer.Update(gameInfo);
 }
Exemplo n.º 7
0
        public override void Update(GameInfo gameInfo)
        {
            base.Update(gameInfo);

            List<Talk> talkList = gameInfo.TalkList;

            // talkListからCO,占い結果の抽出
            for (int i = readTalkListNum; i < talkList.Count; i++)
            {
                Talk talk = talkList[i];
                Utterance utterance = new Utterance(talk.Content);
                switch (utterance.Topic)
                {
                    // カミングアウトの発話の場合
                    // 自分以外で占い師COするプレイヤーが出たら投票先を変える
                    case Topic.COMINGOUT:
                        agi.ComingoutMap[talk.Agent] = utterance.Role;
                        if (utterance.Role == fakeRole)
                        {
                            SetPlanningVoteAgent();
                        }
                        break;

                    // 占い結果の発話の場合
                    // 人狼以外の占い,霊能結果で嘘だった場合は狂人だと判断
                    case Topic.DIVINED:
                        // AGIのJudgeListに結果を加える
                        Agent seerAgent = talk.Agent;
                        Agent inspectedAgent = utterance.Target;
                        Species inspectResult = (Species)utterance.Result;
                        Judge judge = new Judge(Day, seerAgent, inspectedAgent, inspectResult);
                        agi.AddInspectJudgeList(judge);

                        // ジャッジしたのが人狼以外の場合
                        if (!WolfList.Contains(judge.Agent))
                        {
                            Species judgeSpecies = judge.Result;
                            Species realSpecies;
                            if (WolfList.Contains(judge.Target))
                            {
                                realSpecies = Species.WEREWOLF;
                            }
                            else
                            {
                                realSpecies = Species.HUMAN;
                            }
                            if (judgeSpecies != realSpecies)
                            {
                                maybePossesedAgent = judge.Agent;
                                SetPlanningVoteAgent();
                            }
                        }
                        break;
                }
            }
            readTalkListNum = talkList.Count;
        }
Exemplo n.º 8
0
        public override void Initialize(GameInfo gameInfo, GameSetting gameSetting)
        {
            base.Initialize(gameInfo, gameSetting);

            List<Role> fakeRoles = gameSetting.RoleNumMap.Keys.ToList();
            List<Role> nonFakeRoleList = new Role[] { Role.BODYGUARD, Role.FREEMASON, Role.POSSESSED, Role.WEREWOLF }.ToList();
            fakeRoles.RemoveAll(role => nonFakeRoleList.Contains(role));
            fakeRole = fakeRoles[new Random().Next(fakeRoles.Count)];

            // 占い師,or霊能者なら1~3日目からランダムに選択してCO.村人ならCOしない.
            comingoutDay = new Random().Next(3) + 1;
            if (fakeRole == Role.VILLAGER)
            {
                comingoutDay = 1000;
            }
            isCameout = false;
        }
Exemplo n.º 9
0
 /// <summary>
 /// Called when the game information updated.
 /// </summary>
 /// <param name="gameInfo"></param>
 public abstract void Update(GameInfo gameInfo);
Exemplo n.º 10
0
 /// <summary>
 /// Called when the game started.
 /// </summary>
 /// <param name="gameInfo">Information about current game status.</param>
 /// <param name="gameSetting">Game settings.</param>
 public abstract void Initialize(GameInfo gameInfo, GameSetting gameSetting);
Exemplo n.º 11
0
 public virtual void Update(GameInfo gameInfo)
 {
     Day = gameInfo.Day;
     GameInfoMap[Day] = gameInfo;
 }
Exemplo n.º 12
0
        public override void Update(GameInfo gameInfo)
        {
            base.Update(gameInfo);

            List<Talk> talkList = gameInfo.TalkList;
            // talkListからCO,占い結果の抽出
            for (int i = readTalkListNum; i < talkList.Count; i++)
            {
                Talk talk = talkList[i];
                Utterance utterance = new Utterance(talk.Content);
                switch (utterance.Topic)
                {
                    // カミングアウトの発話の場合
                    case Topic.COMINGOUT:
                        agi.ComingoutMap[talk.Agent] = (Role)utterance.Role;
                        if (utterance.Role == MyRole)
                        {
                            SetPlanningVoteAgent();
                        }
                        break;
                }
            }
            readTalkListNum = talkList.Count;
        }