public bool CanUseWeapon(Cell cell, WeaponTemplate weapon) { if (!IsFighterTurn()) { return(false); } if (HasState((int)SpellStatesEnum.AFFAIBLI_42)) { return(false); } var point = new MapPoint(cell); if ((weapon.CastInDiagonal && (point.EuclideanDistanceTo(Position.Point) > weapon.WeaponRange || point.EuclideanDistanceTo(Position.Point) < weapon.MinRange)) || (!weapon.CastInDiagonal && point.ManhattanDistanceTo(Position.Point) > weapon.WeaponRange || point.ManhattanDistanceTo(Position.Point) < weapon.MinRange)) { return(false); } if (m_weaponUses >= weapon.MaxCastPerTurn) { return(false); } return(AP >= weapon.ApCost && Fight.CanBeSeen(cell, Position.Cell)); }
/// <summary> /// Check if the player can cast a spell to the targeted cell /// </summary> /// <param name="spell">Casted spell</param> /// <param name="cell">Targeted cell</param> /// <param name="NoRangeCheck">if true, then skip all checking related with caster position, /// (preparatory stuff, before fight)</param> /// <returns>False if cannot cast the spell</returns> public bool CanCastSpell(Spells.Spell spell, Cell cell, bool NoRangeCheck = false) { // todo spells modifications // todo states if (cell == null) { NoRangeCheck = true; } if (!NoRangeCheck && !IsPlaying()) { return(false); } if (spell.LevelTemplate.apCost > Stats.CurrentAP) { return(false); } if (!NoRangeCheck && !IsInSpellRange(cell, spell.LevelTemplate)) { return(false); } // test the LoS if (!NoRangeCheck && spell.LevelTemplate.castTestLos && !Fight.CanBeSeen(Cell, cell, false)) { return(false); } return(true); }