public void Cast(ISpellCast spell) { try { if (Check.IsCastableByWarrior(this, spell) == true) { base.Cast(spell); } else { throw new InvalidOperationException(); } } catch (InvalidOperationException) { } }
protected void Cast(ISpellCast spell) { try { if (Check.IsAlive(this) == true) { SpellLevelUp(spell, this.level); spell.Cast(this); } else { throw new InvalidOperationException(); } } catch (InvalidOperationException) { } }
private bool TryMatchSpell(string spellName, out ISpellCast spell) { if (_spellCache == null) { var spells = from c in _spells.Value let spellAttribute = c.GetType() .GetCustomAttributes(true) .OfType <SpellAttribute>() .FirstOrDefault() where spellAttribute != null select new { Name = spellAttribute.SpellName, Spell = c }; _spellCache = spells.ToDictionary(c => c.Name, c => c.Spell, StringComparer.OrdinalIgnoreCase); } return(_spellCache.TryGetValue(spellName, out spell)); }
private void ExecuteSpell() { Logger.Default.Log($"Vie du bot: {_account.Character.LifePercentage}"); if (_spells == null) { return; } var monster = _account.Character.Fight.NearestMonster(); //foreach (var spell in _spells) //{ var spell = _spells[0]; _currentSpell = spell; var fighter = (IFighter)monster; if (spell.Target == SpellTarget.Self) { fighter = _account.Character.Fight.Fighter; } var useSpell = _account.Character.Fight.CanUseSpell(spell.SpellId, fighter); var nameSpell = D2OParsing.GetSpellName(spell.SpellId); if (_totalSpellLauch <= spell.Relaunchs) { Logger.Default.Log($"Attaque {monster.Name}"); switch (useSpell) { case -1: _account.Character.Fight.EndTurn(); break; case 0: Logger.Default.Log($"Lancement de {nameSpell}"); _spellEvent = new SpellCast(_account, spell.SpellId, fighter.CellId); _spellEvent.SpellCasted += OnSpellCasted; _spellEvent.PerformCast(); break; default: Logger.Default.Log($"Déplacement en {useSpell}"); var movement = _account.Character.Fight.MoveToCell(useSpell); movement.MovementFinished += (sender, e) => { if (e.Sucess) { Logger.Default.Log($"Lancement de {nameSpell}"); _spellEvent = new SpellCast(_account, spell.SpellId, fighter.CellId); _spellEvent.SpellCasted += OnSpellCasted; _spellEvent.PerformCast(); } else { Logger.Default.Log( $"Erreur lors du lancement du spell {spell.SpellId} sur la cell {fighter.CellId}", LogMessageType.Public); } }; movement.PerformMovement(); break; } } else { _totalSpellLauch = 0; _account.Character.Fight.EndTurn(); } }
private bool TryMatchSpell(string spellName, out ISpellCast spell) { if (_spellCache == null) { var spells = from c in _spells.Value let spellAttribute = c.GetType() .GetCustomAttributes(true) .OfType<SpellAttribute>() .FirstOrDefault() where spellAttribute != null select new { Name = spellAttribute.SpellName, Spell = c }; _spellCache = spells.ToDictionary(c => c.Name, c => c.Spell, StringComparer.OrdinalIgnoreCase); } return _spellCache.TryGetValue(spellName, out spell); }