Esempio n. 1
0
        public int this[GameTag t]
        {
            get
            {
                //if (Card.Name.Equals("Angry Chicken"))
                //Game?.Log(LogLevel.DEBUG, BlockType.TRIGGER, "Entity", $"{this} get org. data {t} = {_data[t]}");

                var value = _data[t];

                // cumulative enchanment calculation ... priorizing game, zone, entity
                Game?.Enchants.ForEach(p => value = p.Apply(this, t, value));
                Zone?.Enchants.ForEach(p => value = p.Apply(this, t, value));
                Enchants.ForEach(p => value       = p.Apply(this, t, value));

                return(value);
            }
            set
            {
                var oldValue = _data[t];
                Game.Log(LogLevel.DEBUG, BlockType.TRIGGER, "Entity", $"{this} set data {t} to {value} oldvalue {oldValue}");
                //if (oldValue == value && t != GameTag.ZONE_POSITION)
                //{
                //    Game.Log(LogLevel.DEBUG, BlockType.TRIGGER, "Entity", $"{this} set data {t} to {value} obsolet as value is already that value.");
                //    return;
                //}

                SetNativeGameTag(t, value);

                Game.OnEntityChanged(this, t, oldValue, value);


                // don't trigger on explicit turned off heals or predamage changes ....
                if ((t == GameTag.DAMAGE || t == GameTag.PREDAMAGE) && IsIgnoreDamage)
                {
                    return;
                }

                // trigger here
                Game?.Triggers.ForEach(p => p.Change(this, t, oldValue, value));
                Zone?.Triggers.ForEach(p => p.Change(this, t, oldValue, value));
                Triggers.ForEach(p => p.Change(this, t, oldValue, value));
            }
        }