private AdaptiveCostEffect(AdaptiveCostEffect prototype, IPlayable owner) { if (!(owner is Playable p)) { throw new Exception($"Can't activate {this} to non-playable {owner}"); } _owner = p; if (prototype._triggerType != TriggerType.NONE) { _value = prototype._value; _triggerType = prototype._triggerType; _triggerSource = prototype._triggerSource; _condition = prototype._condition; _updateHandler = Trigger; _removedHandler = RemoveAtEnd; _isTriggered = prototype._isTriggered; _isAppliedThisTurn = prototype._isAppliedThisTurn; } else { _costFunction = prototype._costFunction; } }
public void Activate(Playable owner, bool cloning = false) { if (!cloning && !(owner.Zone is HandZone)) { return; } var instance = new AdaptiveCostEffect(this, owner); if (owner._costManager == null) { owner._costManager = new Playable.CostManager(); } owner._costManager.ActivateAdaptiveEffect(instance); owner.OngoingEffect = instance; switch (_triggerType) { case TriggerType.NONE: break; case TriggerType.HEAL: owner.Game.TriggerManager.HealTrigger += instance._updateHandler; break; case TriggerType.DEATH: owner.Game.TriggerManager.DeathTrigger += instance._updateHandler; break; case TriggerType.CAST_SPELL: owner.Game.TriggerManager.CastSpellTrigger += instance._updateHandler; break; case TriggerType.AFTER_CAST: owner.Game.TriggerManager.AfterCastTrigger += instance._updateHandler; break; case TriggerType.TURN_START: owner.Game.TriggerManager.TurnStartTrigger += instance._updateHandler; break; case TriggerType.ZONE: owner.Game.TriggerManager.ZoneTrigger += instance._updateHandler; break; case TriggerType.OVERLOAD: owner.Game.TriggerManager.OverloadTrigger += instance._updateHandler; break; default: throw new NotImplementedException(); } owner.Game.Auras.Add(instance); }
private AdaptiveCostEffect(AdaptiveCostEffect prototype, IPlayable owner) { if (!(owner is Playable p)) { throw new Exception($"Can't activate {this} to non-playable {owner}"); } _owner = p; _condition = prototype._condition; _costFunction = prototype._costFunction; _operator = prototype._operator; }
public void Activate(Playable owner, bool cloning = false) { if (!cloning && !(owner.Zone is HandZone)) { return; } var instance = new AdaptiveCostEffect(this, owner); if (owner._costManager == null) { owner._costManager = new Playable.CostManager(); } owner._costManager.ActivateAdaptiveEffect(instance); owner.OngoingEffect = instance; owner.Game.Auras.Add(instance); }
private AdaptiveCostEffect(AdaptiveCostEffect prototype, IPlayable owner) { if (!(owner is Playable p)) { throw new Exception($"Can't activate {this} to non-playable {owner}"); } _owner = p; _type = prototype._type; switch (_type) { case Type.Variable: _costFunction = prototype._costFunction; _operator = prototype._operator; _condition = prototype._condition; return; case Type.Triggered: _value = prototype._value; _triggerType = prototype._triggerType; _triggerSource = prototype._triggerSource; _condition = prototype._condition; break; case Type.TriggeredWithInitialisation: _initialisationFunction = prototype._initialisationFunction; _cachedValue = _initialisationFunction(p); _costFunction = prototype._costFunction; _triggerType = prototype._triggerType; _triggerSource = prototype._triggerSource; _condition = prototype._condition; break; default: throw new ArgumentOutOfRangeException(); } _updateHandler = Trigger; _removedHandler = RemoveAtEnd; _isTriggered = prototype._isTriggered; _isAppliedThisTurn = prototype._isAppliedThisTurn; }
public void Activate(Playable owner, bool cloning = false) { if (!cloning && !(owner.Zone is HandZone)) { return; } var instance = new AdaptiveCostEffect(this, owner); if (owner._costManager == null) { owner._costManager = new Playable.CostManager(); } owner._costManager.ActivateAdaptiveEffect(instance); owner.OngoingEffect = instance; switch (_triggerType) { case TriggerType.NONE: break; case TriggerType.HEAL: owner.Game.TriggerManager.HealTrigger += instance._updateHandler; break; case TriggerType.DEATH: owner.Game.TriggerManager.DeathTrigger += instance._updateHandler; break; case TriggerType.CAST_SPELL: owner.Game.TriggerManager.CastSpellTrigger += instance._updateHandler; break; } owner.Game.Auras.Add(instance); }