示例#1
0
        private void DeApply(Minion m)
        {
            for (int i = 0; i < _effects.Length; i++)
            {
                _effects[i].RemoveAuraFrom(m);
            }

            if (EnchantmentCard != null && (_history || EnchantmentCard.Power.Trigger != null))
            {
                int cardId = EnchantmentCard.AssetId;
                List <Enchantment> enchantments = m.AppliedEnchantments;
                for (int i = enchantments.Count - 1; i >= 0; i--)
                {
                    if (enchantments[i].Creator == _owner && enchantments[i].Card.AssetId == cardId)
                    {
                        enchantments.RemoveAt(i);
                        break;
                    }
                }

                if (_history)
                {
                    for (int i = 0; i < _effects.Length; i++)
                    {
                        _owner.Game.PowerHistory.Add(
                            PowerHistoryBuilder.TagChange(_owner.Id, _effects[i].Tag, _owner[_effects[i].Tag]));
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Sets the native value without any trigger activated.
        /// </summary>
        /// <param name="tag"></param>
        /// <param name="value"></param>
        public void SetNativeGameTag(GameTag tag, int value)
        {
            _data[tag] = value;

            if (Game.History && (int)tag < 1000)
            {
                Game.PowerHistory.Add(PowerHistoryBuilder.TagChange(Id, tag, value));
            }
        }
示例#3
0
        private void Apply(Minion m)
        {
            for (int i = 0; i < _effects.Length; i++)
            {
                _effects[i].ApplyAuraTo(m);
            }

            if (EnchantmentCard != null && _history)
            {
                Enchantment.GetInstance(m.Controller, _owner, m, in EnchantmentCard);
                for (int i = 0; i < _effects.Length; i++)
                {
                    _owner.Game.PowerHistory.Add(
                        PowerHistoryBuilder.TagChange(_owner.Id, _effects[i].Tag, _owner[_effects[i].Tag]));
                }
            }
        }
        /// <summary>
        /// Apply this Enchant's <see cref="Effect"/>s to the given entity.
        /// </summary>
        /// <param name="entity">The target entity.</param>
        /// <param name="num1">Integer value for GameTag.TAG_SCRIPT_DATA_NUM_1.</param>
        /// <param name="num2">Integer value for GameTag.TAG_SCRIPT_DATA_NUM_2.</param>
        public virtual void ActivateTo(IEntity entity, int num1 = -1, int num2 = -1)
        {
            IEffect[] effects = Effects;
            if (!UseScriptTag)
            {
                for (int i = 0; i < effects.Length; i++)
                {
                    effects[i].ApplyTo(entity, IsOneTurnEffect);
                }
            }
            else
            {
                effects[0].ChangeValue(num1).ApplyTo(entity, IsOneTurnEffect);

                if (effects.Length >= 2)
                {
                    if (num2 >= 0)
                    {
                        effects[1].ChangeValue(num2).ApplyTo(entity, IsOneTurnEffect);
                    }
                    else
                    {
                        effects[1].ChangeValue(num1).ApplyTo(entity, IsOneTurnEffect);
                    }

                    for (int i = 2; i < effects.Length; i++)
                    {
                        effects[i].ApplyTo(entity, IsOneTurnEffect);
                    }
                }
            }

            if (entity.Game.History)
            {
                for (int i = 0; i < effects.Length; i++)
                {
                    entity.Game.PowerHistory.Add(
                        PowerHistoryBuilder.TagChange(entity.Id, effects[i].Tag, entity[effects[i].Tag]));
                }
            }
        }
示例#5
0
        public override int this[GameTag t]
        {
            get
            {
                _data.TryGetValue(t, out int value);
                return(value + ControllerAuraEffects[t]);
            }
            set
            {
                //20200405 Connor - Turning off the logging for now
                //if (_logging)
                //	Game.Log(LogLevel.DEBUG, BlockType.TRIGGER, "Entity", !Game.Logging ? "" : $"{this} set data {t} to {value}");
                if (_history && (int)t < 1000)
                {
                    if (value + ControllerAuraEffects[t] != this[t])
                    {
                        Game.PowerHistory.Add(PowerHistoryBuilder.TagChange(Id, t, value));
                    }
                }

                _data[t] = value;
            }
        }
示例#6
0
        public void Update()
        {
            if (_triggerType != TriggerType.NONE)
            {
                if (_initialisationFunction != null)
                {
                    _owner._costManager.UpdateAdaptiveEffect(_cachedValue);
                }
                else
                {
                    if (!_isTriggered)
                    {
                        return;
                    }

                    if (_isAppliedThisTurn)
                    {
                        return;
                    }

                    _owner._costManager.UpdateAdaptiveEffect(_value);

                    _isAppliedThisTurn = true;
                }
            }
            else
            {
                _owner._costManager.UpdateAdaptiveEffect();
            }

            if (_owner.Game.History)
            {
                _owner.Game.PowerHistory.Add(PowerHistoryBuilder
                                             .TagChange(_owner.Id, GameTag.COST, _owner.Cost));
            }
        }
示例#7
0
        /// <summary>Process the specified task.
        /// The game will execute the desired task and all effects coupled either
        /// directly or indirectly in synchronous manner.
        ///
        /// Call <see cref="Controller.Options(bool)"/> on the <see cref="CurrentPlayer"/>
        /// instance for tasks which are accepted as arguments.
        /// After this method returns, check <see cref="Controller.Options(bool)"/>
        /// again until only <see cref="EndTurnTask"/> remains, which will
        /// start the turn of <see cref="CurrentOpponent"/>.
        /// </summary>
        /// <param name="gameTask">The game task to execute.</param>
        public void Process(PlayerTask gameTask)
        {
            // start with no splits ...
            Splits = new List <Game>();

            Log(LogLevel.INFO, BlockType.PLAY, "Game", gameTask.FullPrint());

            // clear last power history
            PowerHistory.Last.Clear();

            // make sure that we only use task for this game ...
            gameTask.Game = this;
            gameTask.Process();

            // add enchantment and buff tag changes
            if (History)
            {
                Enchants.ForEach(p =>
                                 p.Effects.Keys.ToList().ForEach(t =>
                                                                 IdEntityDic.Values.ToList().ForEach(o =>
                                                                                                     PowerHistory.Add(PowerHistoryBuilder.TagChange(o.Id, t, o[t])))));

                foreach (var controller in _players)
                {
                    controller.Hero.Enchants.ForEach(p =>
                                                     p.Effects.Keys.ToList().ForEach(t =>
                                                                                     PowerHistory.Add(PowerHistoryBuilder.TagChange(Game.CurrentPlayer.Hero.Id, t, Game.CurrentPlayer.Hero[t]))));

                    //CurrentPlayer.Hero.Weapon?.Enchants.ForEach(p => p.IsEnabled());
                    //CurrentPlayer.Hero.Weapon?.Triggers.ForEach(p => p.IsEnabled());
                    //CurrentOpponent.Hero.Weapon?.Enchants.ForEach(p => p.IsEnabled());
                    //CurrentOpponent.Hero.Weapon?.Triggers.ForEach(p => p.IsEnabled());

                    controller.ControlledZones.Where(z => z != null).ToList().ForEach(z =>
                                                                                      z.Enchants.ForEach(p =>
                                                                                                         p.Effects.Keys.ToList().ForEach(t =>
                                                                                                                                         z.GetAll.ForEach(o =>
                                                                                                                                                          PowerHistory.Add(PowerHistoryBuilder.TagChange(o.Id, t, o[t]))))));
                }

                Characters.ForEach(c =>
                                   c.Enchants.ForEach(p =>
                                                      p.Effects.Keys.ToList().ForEach(t =>
                                                                                      PowerHistory.Add(PowerHistoryBuilder.TagChange(c.Id, t, c[t])))));
            }

            if (Splitting)
            {
                var finalSplits = SplitNode.GetSolutions(this, 10, 10000);
                Dump("Split", $"found {finalSplits.Count} final splits of {finalSplits.Sum(p => p.SameState + 1)}!");
                finalSplits.GroupBy(p => p.SameState)
                .Select(i => new { Word = i.Key, Count = i.Count() })
                .ToList().ForEach(p => Dump("Split", $" {p.Count},  with {p.Word} same states"));
                FinalSplits = finalSplits;
            }
        }
示例#8
0
        public override void Update()
        {
            var m = (Minion)Owner;

            // Remove this EnrageEffect from the target
            if (!On)
            {
                Game.Auras.Remove(this);

                if (!_enraged)
                {
                    return;
                }

                // Spiteful Smith
                if (Type == AuraType.WEAPON)
                {
                    Weapon weapon = m.Controller.Hero.Weapon;
                    if (weapon == null)
                    {
                        return;
                    }

                    if (_target != weapon)
                    {
                        return;
                    }
                }

                foreach (IEffect eff in EnchantmentCard.Power.Enchant.Effects)
                {
                    eff.RemoveFrom(_target);
                }
                if (_currentInstance != null)
                {
                    _currentInstance.Remove();
                    foreach (IEffect eff in EnchantmentCard.Power.Enchant.Effects)
                    {
                        Game.PowerHistory.Add(PowerHistoryBuilder.TagChange(
                                                  m.Id, eff.Tag, m[eff.Tag]));
                    }
                }
                //if (_target != null)
                //	for (int i = 0; i < Effects.Length; i++)
                //		Effects[i].RemoveFrom(_target.AuraEffects);
            }

            if (Type == AuraType.WEAPON)
            {
                Weapon weapon = m.Controller.Hero.Weapon;
                if (weapon == null)
                {
                    return;
                }

                if (_target != weapon)
                {
                    _currentInstance?.Remove();
                    _currentInstance = null;

                    _target = weapon;
                }
            }

            if (!_enraged)
            {
                if (m.Damage == 0)
                {
                    return;
                }
                //if (_target != null)
                //	for (int i = 0; i < Effects.Length; i++)
                //		Effects[i].ApplyTo(_target.AuraEffects);
                Generic.AddEnchantmentBlock(Game, EnchantmentCard, m, _target, 0, 0, 0);
                if (Game.History)
                {
                    _currentInstance = _target.AppliedEnchantments.Last();
                }
                _enraged = true;
            }
            else
            {
                if (m.Damage != 0)
                {
                    return;
                }

                for (int i = 0; i < EnchantmentCard.Power.Enchant.Effects.Length; i++)
                {
                    EnchantmentCard.Power.Enchant.Effects[i].RemoveFrom(m);
                }

                if (_currentInstance != null)
                {
                    _currentInstance.Remove();
                    foreach (IEffect eff in EnchantmentCard.Power.Enchant.Effects)
                    {
                        Game.PowerHistory.Add(PowerHistoryBuilder.TagChange(
                                                  _target.Id, eff.Tag, _target[eff.Tag]));
                    }
                }
                _enraged = false;
            }
        }