/// <summary> /// Setups the buff caster from save. /// </summary> /// <param name="bs">The bs.</param> /// <param name="partyMembers">The party members.</param> /// <returns></returns> public static Buff SetupBuffCasterFromSave(BuffSave bs, List<Character> partyMembers) { Buff b = bs.CreateObjectFromID(); b.InitFromSaveObject(bs); Characters.Stats caster = null; int id = 0; switch (bs.Type) { case BuffSave.SaveType.CASTER_IN_PARTY: Util.Assert(bs.PartyIndex >= 0, "Party index is negative."); Character character = partyMembers[bs.PartyIndex]; caster = character.Stats; id = character.Id; break; // Spoof their stats, and equipment too! case BuffSave.SaveType.CASTER_NOT_IN_PARTY: Util.Assert(bs.StatCopy != null, "Statcopy is null."); caster = new Characters.Stats(); caster.SetupTemporarySaveFields(true); caster.InitFromSaveObject(bs.StatCopy); id = Character.UNKNOWN_ID; break; default: Util.Assert(false, "Unknown SaveType"); break; } b.Caster = new BuffParams(caster, id); return b; }
/// <summary> /// Effects that occur at the end of a turn. /// </summary> /// <param name="owner"></param> public void OnEndOfTurn(Characters.Stats owner) { PerformSpellEffects(OnEndOfTurnHelper(owner)); if (isDefinite) { turnsRemaining--; } }
private static bool LearnerHasResourcesNeededToCastSpell(Characters.Stats learner, SpellBook book) { foreach (StatType type in book.Costs.Keys) { if (!learner.HasStat(type)) { return(false); } } return(true); }
/// <summary> /// Casters the has resources. /// </summary> /// <param name="caster">The caster.</param> /// <returns></returns> public bool CasterHasResources(Characters.Stats caster) { foreach (KeyValuePair <StatType, int> stat in Costs) { if (caster.GetStatCount(Characters.Stats.Get.MOD, stat.Key) < stat.Value) { return(false); } } return(true); }
/// <summary> /// Effects that occur at the end of a turn. /// </summary> /// <param name="owner"></param> public void OnEndOfTurn(Characters.Stats owner) { // TODO use an overridable condition instead if (owner.State == Characters.State.ALIVE) { PerformSpellEffects(OnEndOfTurnHelper(owner)); } if (isDefinite) { turnsRemaining--; } }
/// <summary> /// Gets the comma separated costs. /// </summary> /// <param name="caster">The caster.</param> /// <returns></returns> private string GetCommaSeparatedCosts(Characters.Stats caster = null) { string[] arr = new string[Costs.Count]; int index = 0; foreach (KeyValuePair <StatType, int> pair in Costs) { arr[index++] = string.Format("{0} {1}", Util.ColorString(pair.Value.ToString(), caster != null && CasterHasResource(pair.Key, caster)), Util.ColorString(pair.Key.Name, pair.Key.Color)); } return(string.Join(", ", arr)); }
/// <see cref="OnDispell(Characters.Stats)"/> protected virtual IList <SpellEffect> OnDispellHelper(Characters.Stats owner) { return(OnTimeOutHelper(owner)); }
/// <summary> /// Cast when the buff expires. /// </summary> /// <param name="ownerOfThisBuff">Stats of the character who is the target of the spell</param> public void OnTimeOut(Characters.Stats ownerOfThisBuff) { PerformSpellEffects(OnTimeOutHelper(ownerOfThisBuff)); }
/// <see cref="React(Spell, Characters.Stats)"/> protected virtual void ReactHelper(Spell s, Characters.Stats owner) { }
/// <see cref="OnTimeOut(Characters.Stats)"/> protected virtual IList <SpellEffect> OnTimeOutHelper(Characters.Stats owner) { return(new SpellEffect[0]); }
/// <see cref="React(Spell, Characters.Stats)"/> protected virtual void ReactHelper(SingleSpell spellCast, Characters.Stats ownerOfThisBuff) { }
/// <summary> /// Cast when the buff is dispelled. /// </summary> /// <param name="statsOfTheCharacterTheBuffIsOn">Stats of the character who is the target of the spell</param> public void OnDispell(Characters.Stats statsOfTheCharacterTheBuffIsOn) { PerformSpellEffects(OnDispellHelper(statsOfTheCharacterTheBuffIsOn)); }
/// <summary> /// Respond to a spell cast in battle. /// </summary> /// <param name="incomingSpell">Spell cast on character</param> /// <param name="statsOfTheCharacterTheBuffIsOn">Stats of the character who is the target of the spell</param> public void React(Spell incomingSpell, Characters.Stats statsOfTheCharacterTheBuffIsOn) { ReactHelper(incomingSpell, statsOfTheCharacterTheBuffIsOn); }
/// <summary> /// Cast when the buff is dispelled. /// </summary> /// <param name="ownerOfThisBuff">Stats of the character who is the target of the spell</param> public void OnDispell(Characters.Stats ownerOfThisBuff) { PerformSpellEffects(OnDispellHelper(ownerOfThisBuff)); }
/// <summary> /// Respond to a spell cast in battle. /// </summary> /// <param name="incomingSpell">Spell cast on character</param> /// <param name="ownerOfThisBuff">Stats of the character who is the target of the spell</param> private void React(SingleSpell incomingSpell, Characters.Stats ownerOfThisBuff) { ReactHelper(incomingSpell, ownerOfThisBuff); }
/// <summary> /// If true, buff will react to the spells being cast in battle. This can be any spell. /// The one who has the buff doesn't have to be targeted. /// </summary> /// <param name="incomingSpell">Spell cast on character</param> /// <param name="ownerOfThisBuff">Stats of the character who is the target of the spell</param> /// <returns>True if the buff will react.</returns> public virtual bool IsReact(SingleSpell incomingSpell, Characters.Stats ownerOfThisBuff) { return(false); }
/// <summary> /// Effects that occur when the buff is added to a character. /// </summary> /// <param name="owner"></param> public void OnApply(Characters.Stats owner) { PerformSpellEffects(OnApplyHelper(owner)); }
/// <summary> /// Exp earned = Defeated.Level - Earner.Level /// </summary> /// <param name="earner">Whoever is earning the experience</param> /// <param name="defeated">Defeated character to do calculation for</param> /// <returns>Calculated experience earner should recieve</returns> private int CalculateExperience(Characters.Stats earner, Characters.Stats defeated) { return(Mathf.Max(0, defeated.Level - earner.Level)); }
public static int GetDifference(StatType type, Characters.Stats a, Characters.Stats b) { return(a.GetStatCount(Characters.Stats.Get.TOTAL, type) - b.GetStatCount(Characters.Stats.Get.TOTAL, type)); }
/// <summary> /// Determines whether [is meet pre target requirements] [the specified caster]. /// </summary> /// <param name="caster">The caster.</param> /// <returns> /// <c>true</c> if [is meet pre target requirements] [the specified caster]; otherwise, <c>false</c>. /// </returns> public bool IsMeetPreTargetRequirements(Characters.Stats caster) { return(CasterHasResources(caster) && IsMeetOtherPreTargetRequirements()); }
/// <summary> /// Initializes a new instance of the <see cref="BuffParams"/> struct. /// </summary> /// <param name="caster">The caster's stats.</param> /// <param name="casterId">A unique id number associated with a character.</param> public BuffParams(Characters.Stats caster, int casterId) { this.Caster = caster; this.CasterId = casterId; }
/// <summary> /// Casters the has resource. /// </summary> /// <param name="stat">The stat.</param> /// <param name="caster">The caster.</param> /// <returns></returns> public bool CasterHasResource(StatType stat, Characters.Stats caster) { return(caster.GetStatCount(Characters.Stats.Get.MOD, stat) >= Costs[stat]); }
/// <summary> /// Cast when the buff expires. /// </summary> /// <param name="statsOfTheCharacterTheBuffIsOn">Stats of the character who is the target of the spell</param> public void OnTimeOut(Characters.Stats statsOfTheCharacterTheBuffIsOn) { PerformSpellEffects(OnTimeOutHelper(statsOfTheCharacterTheBuffIsOn)); }
/// <summary> /// If true, buff will react to the spells being cast in battle. This can be any spell. /// The one who has the buff doesn't have to be targeted. /// </summary> /// <param name="incomingSpell">Spell cast on character</param> /// <param name="statsOfTheCharacterTheBuffIsOn">Stats of the character who is the target of the spell</param> /// <returns></returns> public virtual bool IsReact(Spell incomingSpell, Characters.Stats statsOfTheCharacterTheBuffIsOn) { return(false); }
/// <see cref="OnEndOfTurn(Characters.Stats)"/> protected virtual IList <SpellEffect> OnEndOfTurnHelper(Characters.Stats ownerOfThisBuff) { return(new SpellEffect[0]); }