Esempio n. 1
0
        public GameInfoToSend GetFinalGameInfoToSend(Agent agent)
        {
            GameInfoToSend gi = GetGameInfoToSend(agent);

            Dictionary <int, string> roleMap = new Dictionary <int, string>();

            foreach (Agent a in agentRoleMap.Keys)
            {
                roleMap[a.AgentIdx] = agentRoleMap[a].ToString();
            }
            gi.RoleMap = roleMap;

            return(gi);
        }
Esempio n. 2
0
        public GameInfoToSend GetGameInfoToSend(Agent agent)
        {
            GameData       today = this;
            GameInfoToSend gi    = new GameInfoToSend();

            int day = today.Day;

            if (agent != null)
            {
                gi.Agent = agent.AgentIdx;
            }

            GameData yesterday = today.DayBefore;

            if (yesterday != null)
            {
                Agent executed = yesterday.Executed;
                if (executed != null)
                {
                    gi.ExecutedAgent = executed.AgentIdx;
                }

                Agent attacked = yesterday.Attacked;
                if (attacked != null)
                {
                    gi.AttackedAgent = attacked.AgentIdx;
                }

                if (gameSetting.VoteVisible)
                {
                    List <VoteToSend> voteList = new List <VoteToSend>();
                    foreach (Vote vote in yesterday.VoteList)
                    {
                        voteList.Add(new VoteToSend(vote));
                    }
                    gi.VoteList = voteList;
                }

                if (agent != null && (today.GetRole(agent) == Role.MEDIUM && executed != null))
                {
                    Species result = ((Role)yesterday.GetRole(executed)).GetSpecies();
                    gi.MediumResult = new JudgeToSend(new Judge(day, agent, executed, result));
                }

                if (agent == null || today.GetRole(agent) == Role.SEER)
                {
                    Judge divine = yesterday.Divine;
                    if (divine != null && divine.Target != null)
                    {
                        Species result = ((Role)yesterday.GetRole(divine.Target)).GetSpecies();
                        gi.DivineResult = new JudgeToSend(new Judge(day, divine.Agent, divine.Target, result));
                    }
                }

                if (agent == null || today.GetRole(agent) == Role.WEREWOLF)
                {
                    List <VoteToSend> attackVoteList = new List <VoteToSend>();
                    foreach (Vote vote in yesterday.AttackVoteList)
                    {
                        attackVoteList.Add(new VoteToSend(vote));
                    }
                    gi.AttackVoteList = attackVoteList;
                }
                if (agent == null || today.GetRole(agent) == Role.BODYGUARD)
                {
                    Guard guard = yesterday.Guard;
                    if (guard != null)
                    {
                        gi.GuardedAgent = guard.Target.AgentIdx;
                    }
                }
            }
            List <TalkToSend> talkList = new List <TalkToSend>();

            foreach (Talk talk in today.TalkList)
            {
                talkList.Add(new TalkToSend(talk));
            }
            gi.TalkList = talkList;

            Dictionary <int, string> statusMap = new Dictionary <int, string>();

            foreach (Agent a in agentStatusMap.Keys)
            {
                statusMap[a.AgentIdx] = agentStatusMap[a].ToString();
            }
            gi.StatusMap = statusMap;

            Dictionary <int, string> roleMap = new Dictionary <int, string>();
            Role?role = (Role?)agentRoleMap[agent];

            if (Role.WEREWOLF == role || agent == null)
            {
                List <TalkToSend> whisperList = new List <TalkToSend>();
                foreach (Talk talk in today.WhisperList)
                {
                    whisperList.Add(new TalkToSend(talk));
                }
                gi.WhisperList = whisperList;
            }

            if (role != null)
            {
                roleMap[agent.AgentIdx] = role.ToString();
                if (today.GetRole(agent) == Role.WEREWOLF)
                {
                    foreach (Agent target in today.AgentList)
                    {
                        if (today.GetRole(target) == Role.WEREWOLF)
                        {
                            roleMap[target.AgentIdx] = Role.WEREWOLF.ToString();
                        }
                    }
                }
                if (today.GetRole(agent) == Role.FREEMASON)
                {
                    foreach (Agent target in today.AgentList)
                    {
                        if (today.GetRole(target) == Role.FREEMASON)
                        {
                            roleMap[target.AgentIdx] = Role.FREEMASON.ToString();
                        }
                    }
                }
            }
            gi.RoleMap = roleMap;
            gi.Day     = day;

            return(gi);
        }
Esempio n. 3
0
 /// <summary>
 /// Create packet with game information.
 /// </summary>
 /// <param name="request"></param>
 /// <param name="gameInfoToSend"></param>
 public Packet(Request request, GameInfoToSend gameInfoToSend)
 {
     Request = request;
     GameInfo = gameInfoToSend;
 }
Esempio n. 4
0
 /// <summary>
 /// Create packet with game inforamtion and game setting.
 /// </summary>
 /// <param name="request"></param>
 /// <param name="gameInfoToSend"></param>
 /// <param name="gameSetting"></param>
 public Packet(Request request, GameInfoToSend gameInfoToSend, GameSetting gameSetting)
 {
     Request = request;
     GameInfo = gameInfoToSend;
     GameSetting = gameSetting;
 }
Esempio n. 5
0
        public GameInfoToSend GetGameInfoToSend(Agent agent)
        {
            GameData today = this;
            GameInfoToSend gi = new GameInfoToSend();

            int day = today.Day;
            if (agent != null)
            {
                gi.Agent = agent.AgentIdx;
            }

            GameData yesterday = today.DayBefore;

            if (yesterday != null)
            {
                Agent executed = yesterday.Executed;
                if (executed != null)
                {
                    gi.ExecutedAgent = executed.AgentIdx;
                }

                Agent attacked = yesterday.Attacked;
                if (attacked != null)
                {
                    gi.AttackedAgent = attacked.AgentIdx;
                }

                if (gameSetting.VoteVisible)
                {
                    List<VoteToSend> voteList = new List<VoteToSend>();
                    foreach (Vote vote in yesterday.VoteList)
                    {
                        voteList.Add(new VoteToSend(vote));
                    }
                    gi.VoteList = voteList;
                }

                if (agent != null && (today.GetRole(agent) == Role.MEDIUM && executed != null))
                {
                    Species result = ((Role)yesterday.GetRole(executed)).GetSpecies();
                    gi.MediumResult = new JudgeToSend(new Judge(day, agent, executed, result));
                }

                if (agent == null || today.GetRole(agent) == Role.SEER)
                {
                    Judge divine = yesterday.Divine;
                    if (divine != null && divine.Target != null)
                    {
                        Species result = ((Role)yesterday.GetRole(divine.Target)).GetSpecies();
                        gi.DivineResult = new JudgeToSend(new Judge(day, divine.Agent, divine.Target, result));
                    }
                }

                if (agent == null || today.GetRole(agent) == Role.WEREWOLF)
                {
                    List<VoteToSend> attackVoteList = new List<VoteToSend>();
                    foreach (Vote vote in yesterday.AttackVoteList)
                    {
                        attackVoteList.Add(new VoteToSend(vote));
                    }
                    gi.AttackVoteList = attackVoteList;
                }
                if (agent == null || today.GetRole(agent) == Role.BODYGUARD)
                {
                    Guard guard = yesterday.Guard;
                    if (guard != null)
                    {
                        gi.GuardedAgent = guard.Target.AgentIdx;
                    }
                }
            }
            List<TalkToSend> talkList = new List<TalkToSend>();
            foreach (Talk talk in today.TalkList)
            {
                talkList.Add(new TalkToSend(talk));
            }
            gi.TalkList = talkList;

            Dictionary<int, string> statusMap = new Dictionary<int, string>();
            foreach (Agent a in agentStatusMap.Keys)
            {
                statusMap[a.AgentIdx] = agentStatusMap[a].ToString();
            }
            gi.StatusMap = statusMap;

            Dictionary<int, string> roleMap = new Dictionary<int, string>();
            Role? role = (Role?)agentRoleMap[agent];

            if (Role.WEREWOLF == role || agent == null)
            {
                List<TalkToSend> whisperList = new List<TalkToSend>();
                foreach (Talk talk in today.WhisperList)
                {
                    whisperList.Add(new TalkToSend(talk));
                }
                gi.WhisperList = whisperList;
            }

            if (role != null)
            {
                roleMap[agent.AgentIdx] = role.ToString();
                if (today.GetRole(agent) == Role.WEREWOLF)
                {
                    foreach (Agent target in today.AgentList)
                    {
                        if (today.GetRole(target) == Role.WEREWOLF)
                        {
                            roleMap[target.AgentIdx] = Role.WEREWOLF.ToString();
                        }
                    }
                }
                if (today.GetRole(agent) == Role.FREEMASON)
                {
                    foreach (Agent target in today.AgentList)
                    {
                        if (today.GetRole(target) == Role.FREEMASON)
                        {
                            roleMap[target.AgentIdx] = Role.FREEMASON.ToString();
                        }
                    }
                }
            }
            gi.RoleMap = roleMap;
            gi.Day = day;

            return gi;
        }