public GameState ApplyTargettedSkill(TargettedSkill s, GameState state) { if (!s.Skill.Available) { throw new InvalidOperationException($"{s.TargetInfo.InvokerID} tried to use skill {s.Skill.ID} but it is not available for use."); } AssertContainSkill(s, state); if (s.Skill.Cooldown > 0) { state = ApplyCooldown(s, state); } state = ApplyCTCost(s, state); TargettedAction targetAction = s.CreateAction(); if (s.Skill.Delay > 0) { state = ApplyCasting(s, state); return(state.AddDelayedAction(DelayedAction.Create(targetAction, Time.ActionAmount - s.Skill.Delay, s))); } else { return(EffectEngine.Apply(targetAction, state)); } }
public DelayedAction(long id, TargettedAction targetAction, int ct = 0, TargettedSkill sourceSkill = null) { ID = id; TargetAction = targetAction; CT = ct; SourceSkill = sourceSkill; }
GameState ApplyCooldown(TargettedSkill s, GameState state) { TargettedAction cooldownAction = CreateCooldownAction(s); state = state.AddDelayedAction(DelayedAction.Create(cooldownAction, Time.ActionAmount - s.Skill.Cooldown)); Character character = state.AllCharacters.WithID(s.TargetInfo.InvokerID); return(state.UpdateCharacter(character.WithUpdatedSkill(s.Skill.WithAvailable(false)))); }
static GameState AddNewEffect(string effectName, int power, ItemResolver <Character> character, GameState state) { state = state.UpdateCharacter(character.Item.AddStatusEffect(new StatusEffect(effectName))); character.Update(state); Action removeAction = new Action(ActionType.RemoveEffect, 0, effectName); TargettedAction removeActionTargetted = new TargettedAction(removeAction, TargettingInfo.Self(character)); DelayedAction removeEffectAction = DelayedAction.Create(removeActionTargetted, Time.ActionAmount - power); return(state.AddDelayedAction(removeEffectAction)); }
public GameState Apply(TargettedAction targettedAction, GameState state) { TargettingInfo targettingInfo = targettedAction.TargetInfo; Character invoker = state.AllCharacters.WithIDOrNull(targettingInfo.InvokerID); if (invoker == null || !invoker.IsAlive) { return(state); } Action action = targettedAction.Action; ActionType type = action.Type; if (type.HasFlag(ActionType.Damage) || type.HasFlag(ActionType.Heal)) { Character target = state.AllCharacters.WithIDOrNull(targettingInfo.TargetID); if (target == null || !target.IsAlive) { return(state); } } if (type.HasFlag(ActionType.Damage)) { state = ApplyDamage(action.Power, CharacterResolver.Create(targettingInfo.TargetID, state), state); } if (type.HasFlag(ActionType.Heal)) { state = ApplyHeal(action.Power, CharacterResolver.Create(targettingInfo.TargetID, state), state); } if (type.HasFlag(ActionType.Cooldown)) { state = ApplyCooldown(targettingInfo, state); } if (type.HasFlag(ActionType.Effect)) { state = ApplyEffect(action.EffectName, action.Power, targettingInfo, state); } if (type.HasFlag(ActionType.RemoveEffect)) { state = RemoveEffect(action.EffectName, targettingInfo, state); } return(state); }
public DelayedAction WithTargetAction(TargettedAction targetAction) { return(new DelayedAction(ID, targetAction, CT, SourceSkill)); }
public static DelayedAction Create(TargettedAction action, int ct = 0, TargettedSkill sourceSkill = null) { return(new DelayedAction(IDs.Next(), action, ct, sourceSkill)); }