Skip to content

Commit

Permalink
Fix bug where required letter bonuses reject all tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
jcreedcmu committed Feb 22, 2024
1 parent bbf7642 commit a70b30c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/landing-result.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DEBUG } from "../util/debug";
import { Point } from "../util/types";
import { getOverlay } from "./layer";
import { AbstractLetter } from "./letters";
import { AbstractLetter, lettersMatch } from "./letters";
import { MobState, MobType, collidesWithMob, mobsMap } from "./mobs";
import { CoreState, MobileEntity, MoveMobile } from "./state";
import { CellContents, cellAtPointForMobiles, get_mobiles } from "./tile-helpers";
Expand Down Expand Up @@ -87,7 +87,7 @@ export function landMobileOnCell(m: MoveSource, c: CellContents): LandingResult
case 'empty': return { t: 'place' };
case 'tree': return { t: 'collision' };
case 'bomb': return { t: 'collision' };
case 'required': return (m.t == 'tile' && (m.letter == bonus.letter || DEBUG.allWords)) ? { t: 'place' } : { t: 'collision' };
case 'required': return (m.t == 'tile' && (lettersMatch(m.letter, bonus.letter) || DEBUG.allWords)) ? { t: 'place' } : { t: 'collision' };
case 'consonant': return { t: 'collision' };
case 'vowel': return { t: 'collision' };
case 'copy': return { t: 'collision' };
Expand Down
6 changes: 6 additions & 0 deletions src/core/letters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@ export function letterOfIndex(i: number): AbstractLetter {
}
throw new Error(`Unknown abstract letter index ${i}`);
}

export function lettersMatch(al1: AbstractLetter, al2: AbstractLetter): boolean {
switch (al1.t) {
case 'single': return al2.t == 'single' && al2.letter == al1.letter;
}
}

0 comments on commit a70b30c

Please sign in to comment.