refactor(02-03): extract hero pass predicate

- Move passability and hit checks behind IPassPredicate
- Keep hero mover event dispatch and move codes unchanged
This commit is contained in:
AncTe committed 2026-09-09 21:06:07 +08:00
1 parent 3770e56c4d
commit 68a150882c
2 files changed
+80 -52

No files matched your search

+9 -2
View File
@@ -180,9 +180,16 @@ export class HeroMover<T extends IHeroLocation>
if (this.ignoreTerrain) {
return HeroMoveCode.Step;
} else {
const canPass = this.topImpl.canPass(handler);
const passHandler = {
currLoc: handler.currLoc,
nextLoc: handler.nextLoc,
direction: handler.direction,
floorId: handler.floorId
};
const predicate = this.topImpl.predicate();
const canPass = predicate.canPass(passHandler);
if (canPass) {
const hit = this.topImpl.shouldHit(handler);
const hit = predicate.shouldHit(passHandler);
if (hit) return HeroMoveCode.Hit;
else return HeroMoveCode.Step;
} else {