示例#1
0
        private void UpdatePlayerEvents(Game newState)
        {
            var match = incineRegex.Match(newState.lastUpdate);

            if (match.Success)
            {
                PlayerEvent newEvent = new PlayerEvent();
                newEvent.eventType = PlayerEventType.INCINERATION;
                TryPopulatePlayerId(newEvent, match.Groups[1].Value);
                m_currEvent.playerEvents.Add(newEvent);
            }

            match = peanutRegex.Match(newState.lastUpdate);
            if (match.Success)
            {
                string playerName = match.Groups[1].Value;

                if (match.Groups[2].Value == "yummy")
                {
                    PlayerEvent newEvent = new PlayerEvent();
                    newEvent.eventType = PlayerEventType.PEANUT_GOOD;
                    TryPopulatePlayerId(newEvent, playerName);
                    m_currEvent.playerEvents.Add(newEvent);
                }
                else if (match.Groups[2].Value == "allergic")
                {
                    PlayerEvent newEvent = new PlayerEvent();
                    newEvent.eventType = PlayerEventType.PEANUT_BAD;
                    TryPopulatePlayerId(newEvent, playerName);
                    m_currEvent.playerEvents.Add(newEvent);
                }
            }
        }
示例#2
0
        private void TryPopulatePlayerId(PlayerEvent p, string name)
        {
            string id;

            if (m_playerNameToId.TryGetValue(name, out id))
            {
                p.playerId = id;
            }
        }