public ItemPurchaseInformation(Event itemEvent, GameState gameState)
        {
            ItemId = itemEvent.ItemId;
            ItemBefore = itemEvent.ItemBefore;
            ItemAfter = itemEvent.ItemAfter;

            if (!itemEvent.EventType.HasValue)
            {
                throw new ArgumentException("Event type must not be null.", "itemEvent");
            }

            EventType = itemEvent.EventType.Value;

            GameState = gameState.Clone();
        }
Exemple #2
0
 private void HandleItemUndo(Frame frame, Event e)
 {
     GetChampionByParticipant(e.ParticipantId).ItemUndo(e.ItemBefore, e.ItemAfter);
 }
Exemple #3
0
 private void HandleItemSold(Frame frame, Event e)
 {
     GetChampionByParticipant(e.ParticipantId).ItemSold(e.ItemId);
 }
Exemple #4
0
        private void HandleItemDestroyed(Frame frame, Event e)
        {
            // Handle a bug where we get an ItemDestroyed with no participant
            if (e.ParticipantId == 0)
                return;

            GetChampionByParticipant(e.ParticipantId).ItemDestroyed(e.ItemId);
        }
Exemple #5
0
        private void HandleEliteMonsterKill(Frame frame, Event e)
        {
            if (!e.MonsterType.HasValue)
                return;

            var team = (e.KillerId != 0) ? GetTeamByParticipant(e.KillerId) : (e.TeamId != 0) ? Teams[e.TeamId] : null;

            // This happens sometimes - not sure why
            if (team == null)
                return;

            switch (e.MonsterType.Value)
            {
                case MonsterType.BaronNashor:
                    ++team.BaronKills;
                    break;
                case MonsterType.Dragon:
                    ++team.DragonKills;
                    break;
            }
        }
Exemple #6
0
        private void HandleChampionKill(Frame frame, Event e)
        {
            int killerId = e.KillerId;
            int victimId = e.VictimId;
            List<int> assistIds = e.AssistingParticipantIds;

            if (killerId != 0) // 0 = minion
            {
                ++GetChampionByParticipant(killerId).Kills;
            }

            ++GetChampionByParticipant(victimId).Deaths;

            if (assistIds != null)
            {
                assistIds.ForEach(assistId => ++GetChampionByParticipant(assistId).Assists);
            }
        }
Exemple #7
0
        private void HandleBuildingKill(Frame frame, Event e)
        {
            if (!e.BuildingType.HasValue)
                return;

            // Team that destroyed a tower
            int teamId = e.TeamId;

            switch (e.BuildingType.Value)
            {
                case BuildingType.InhibitorBuilding:
                    ++Teams[teamId].InhibitorsDestroyed;
                    break;
                case BuildingType.TowerBuilding:
                    {
                        ++Teams[teamId].TowersDestroyed;

                        if (!e.TowerType.HasValue)
                            return;

                        if (Teams[teamId].TowerTypesDestroyed.ContainsKey(e.TowerType.Value))
                        {
                            ++Teams[teamId].TowerTypesDestroyed[e.TowerType.Value];
                        }
                        else
                        {
                            Teams[teamId].TowerTypesDestroyed.Add(e.TowerType.Value, 1);
                        }
                    }
                    break;
            }
        }
Exemple #8
0
        /// <summary>
        /// Updates the game state with a timeline event.
        /// </summary>
        /// <remarks>Events are expected to happen in the order this is called.</remarks>
        public void Update(Frame frame, Event e)
        {
            if (!e.EventType.HasValue)
                return;

            // Call event handlers.
            // NOTE: We only handle events that could be used to make a decision about item purchases.
            switch (e.EventType.Value)
            {
                case EventType.BuildingKill:
                    HandleBuildingKill(frame, e);
                    break;
                case EventType.ChampionKill:
                    HandleChampionKill(frame, e);
                    break;
                case EventType.EliteMonsterKill:
                    HandleEliteMonsterKill(frame, e);
                    break;
                case EventType.ItemDestroyed:
                    HandleItemDestroyed(frame, e);
                    break;
                case EventType.ItemPurchased:
                    HandleItemPurchased(frame, e);
                    break;
                case EventType.ItemSold:
                    HandleItemSold(frame, e);
                    break;
                case EventType.ItemUndo:
                    HandleItemUndo(frame, e);
                    break;
                default:
                    return;
            }

            // If the event was handled, update the timestamp
            Timestamp = e.Timestamp;
        }