refactor(spells): TargetedSpell base owns target+range+LOS validation once #152
No reviewers
Labels
No labels
alpha:wave-0
alpha:wave-1
alpha:wave-2
alpha:wave-3
area:assets
area:combat
area:ecology
area:infra
area:render
area:scripting
area:ui
area:world
enhancement
epic
migration
post-alpha
roadmap
tech-debt
type:bug
type:chore
type:design
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
marco/IsoMmo!152
Loading…
Reference in a new issue
No description provided.
Delete branch "refactor/targeted-spell-base"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Every targeted spell had to re-implement the same preamble — target exists? alive? not the caster? in range? in line of sight? — before its effect. With more targeted spells coming, that's duplicated logic per spell (and the line-of-sight check, which is what makes arena cover real, would be copied N times).
TargetedSpellbase owns the validation once: target valid → in range → (by default) has line of sight, elseFizzledwith the rightSystemMessageId. Subclasses supply onlyRange(options)andApply(target, context)(the effect).BoltSpellnow derives from it — itsResolveshrank toRange => BoltRange+Apply= deal damage.FireBolt/WaterBoltunchanged.This is the server-enforced attack line-of-sight the PvP arena relies on: a blocking static (wall/pillar/tree) between caster and target fizzles the cast. (We deliberately did not hide out-of-LoS entities from the client — see the closed #150; cover is enforced on the attack, UO-style visibility is kept.)
How it was tested
IncantationTests.Bolt_TargetBehindBlockingStatic_FizzlesNoLineOfSight: caster and target 2 tiles apart (in range) with a blocking static between them → the bolt resolvesFizzled/NoLineOfSight. Locks the arena's essential cover behaviour through a concrete spell + the shared base.just lint(zero warnings) +just test(422 tests) green; whole solution builds.Checklist
just lintpasses (zero warnings)just testis green