GameState RemoveEffect(string effectName, TargettingInfo targettingInfo, GameState state) { Character c = state.AllCharacters.WithID(targettingInfo.TargetID); c = c.WithStatusEffects(c.StatusEffects.RemoveAll(x => x.Name == effectName)); return(state.UpdateCharacter(c)); }
GameState ApplyCooldown(TargettingInfo targettingInfo, GameState state) { Character c = state.AllCharacters.WithID(targettingInfo.InvokerID); c = c.WithUpdatedSkill(c.Skills.WithID(targettingInfo.TargetID).WithAvailable(true)); return(state.UpdateCharacter(c)); }
public void ProcessAction(int skillIndex, long targetID) { Skill s = Engine.CurrentState.ActiveCharacter.Skills[skillIndex]; TargettingInfo info = TargettingInfo.From(Engine.CurrentState.ActivePlayerID, targetID); Engine.ProcessActivePlayerAction(new TargettedSkill(s, info)); CheckForNewLevel(); }
GameState ApplyEffect(string effectName, int power, TargettingInfo targettingInfo, GameState state) { var character = CharacterResolver.Create(targettingInfo.TargetID, state); if (character.Item.HasEffect(effectName)) { return(ExtendEffect(effectName, power, character, state)); } else { return(AddNewEffect(effectName, power, character, state)); } }
TargettedSkill ConsiderSkill(string skillName, GameState state, ItemResolver <Character> c) { Skill skill = c.Item.SkillWithName(skillName); if (skill != null && skill.Available) { TargettingInfo targetting = SelectTarget(skill, state, c); if (targetting != TargettingInfo.Empty) { return(new TargettedSkill(skill, targetting)); } } return(null); }
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); }
TargettedAction CreateCooldownAction(TargettedSkill s) { TargettingInfo targettingInfo = new TargettingInfo(s.TargetInfo.InvokerID, s.Skill.ID); return(new TargettedAction(CooldownAction, targettingInfo)); }
public static TargettingInfo FindBestDamageTarget(GameState state, ItemResolver <Character> c) { Character lowestHealth = state.GetOpponents(c).OrderBy(x => x.Health.Current / (double)x.Health.Max).First(); return(TargettingInfo.From(c.Item.ID, lowestHealth.ID)); }
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 TargettedAction WithTargetInfo(TargettingInfo targetInfo) { return(new TargettedAction(Action, targetInfo)); }
public TargettedAction(Action action, TargettingInfo targetInfo) { Action = action; TargetInfo = targetInfo; }
public TargettedSkill(Skill skill, TargettingInfo targetInfo) { Skill = skill; TargetInfo = targetInfo; }