UNPKG

@real_one_chess_king/game-logic

Version:
20 lines 860 B
import { buildMoveAffect, markAsUserSelected } from "../../affect/affect.utils"; import { Direction } from "./movement-rule"; import { directionToVector, StraightMovementRule, } from "./straight-movement.rule"; export class DiagonalMovementRule extends StraightMovementRule { constructor({ id, name, moveToEmpty, moveToKill, collision, distance, directions, speed = 1, }) { super(id, name, moveToEmpty, moveToKill, collision, distance, directions, speed); } possibleDirrections = [ Direction.UpLeft, Direction.UpRight, Direction.DownLeft, Direction.DownRight, ]; calculateNewCoord = (x, y, diff, dirrection) => { return [ markAsUserSelected(buildMoveAffect([x, y], directionToVector(dirrection, x, y, diff))), ]; }; } //# sourceMappingURL=diagonal-movement.rule.js.map