Esempio n. 1
0
        public static int GetEffectiveness(Character attacker, Character target, BattleData action, int element)
        {
            int effectiveness = 0;

            EventEnqueueFunction <ElementEffectEvent> function = (StablePriorityQueue <GameEventPriority, Tuple <GameEventOwner, Character, ElementEffectEvent> > queue, Priority maxPriority, ref Priority nextPriority) =>
            {
                //start with universal
                DataManager.Instance.UniversalEvent.AddEventsToQueue(queue, maxPriority, ref nextPriority, DataManager.Instance.UniversalEvent.ElementEffects);

                //go through all statuses' element matchup methods
                if (attacker != null)
                {
                    foreach (PassiveContext effectContext in attacker.IteratePassives(GameEventPriority.USER_PORT_PRIORITY))
                    {
                        effectContext.AddEventsToQueue <ElementEffectEvent>(queue, maxPriority, ref nextPriority, effectContext.EventData.UserElementEffects);
                    }
                }
                if (target != null)
                {
                    foreach (PassiveContext effectContext in target.IteratePassives(GameEventPriority.TARGET_PORT_PRIORITY))
                    {
                        effectContext.AddEventsToQueue <ElementEffectEvent>(queue, maxPriority, ref nextPriority, effectContext.EventData.TargetElementEffects);
                    }
                }

                action.AddEventsToQueue <ElementEffectEvent>(queue, maxPriority, ref nextPriority, action.ElementEffects);
            };

            foreach (Tuple <GameEventOwner, Character, ElementEffectEvent> effect in IterateEvents <ElementEffectEvent>(function))
            {
                effect.Item3.Apply(effect.Item1, effect.Item2, action.Element, element, ref effectiveness);
            }

            return(effectiveness);
        }