Exemplo n.º 1
0
        /// <summary>
        /// Activates a spell.
        /// </summary>
        /// <param name="type">Active spell type</param>
        /// <param name="duration">Duration in 5 minute chunks (e.g. 120 for 10 ingame hours).</param>
        /// <param name="level">Level of the spell or 0 if not used.</param>
        public void ActivateSpell(ActiveSpellType type, uint duration, uint level)
        {
            if (ActiveSpells[(int)type] == null)
            {
                ActiveSpells[(int)type] = new ActiveSpell
                {
                    Type     = type,
                    Duration = duration,
                    Level    = level
                };
            }
            else
            {
                var activeSpell = ActiveSpells[(int)type];

                if (activeSpell.Level < level)
                {
                    activeSpell.Level = level;
                }
                activeSpell.Duration = Util.Limit(activeSpell.Duration, duration, 200u);
            }
        }
Exemplo n.º 2
0
 public uint GetActiveSpellLevel(ActiveSpellType activeSpellType)
 {
     return(ActiveSpells.Where(s => s?.Type == activeSpellType && s?.Duration > 0).Select(s => s.Level).DefaultIfEmpty(0u).Max());
 }
Exemplo n.º 3
0
 public bool IsSpellActive(ActiveSpellType activeSpellType)
 {
     return(ActiveSpells.Any(s => s?.Type == activeSpellType && s?.Duration > 0));
 }
Exemplo n.º 4
0
 public static bool AvailableInBattle(this ActiveSpellType activeSpellType) => activeSpellType switch
 {