@real_one_chess_king/game-logic
Version:
R.O.C.K. chess game logic
49 lines (48 loc) • 1.59 kB
TypeScript
import { Turn } from "../../turn";
import { GetPiece } from "../../get-piece";
import { Action } from "../../affect/affect.types";
import { MovementRules } from "./movement-rules.const";
import { UUID } from "crypto";
export declare enum Direction {
Up = "Up",
UpLeft = "UpLeft",
UpRight = "UpRight",
Down = "Down",
DownLeft = "DownLeft",
DownRight = "DownRight",
Left = "Left",
Right = "Right"
}
export type MovementRuleMeta = {
id: UUID;
name: MovementRules;
moveToEmpty: boolean;
moveToKill: boolean;
collision: boolean;
distance: number;
directions: Direction[];
speed: number;
};
export declare abstract class MovementRule {
id: UUID;
name: MovementRules;
protected moveToEmpty: boolean;
protected moveToKill: boolean;
protected collision: boolean;
protected distance: number;
protected directions: Set<Direction>;
protected speed: number;
constructor(id: UUID, name: MovementRules, moveToEmpty: boolean, moveToKill: boolean, collision: boolean, // true - will move until first enemy, false - will jump like horse
distance: number, directions: Set<Direction>, speed: number);
getMeta(): {
id: `${string}-${string}-${string}-${string}-${string}`;
name: MovementRules;
moveToEmpty: boolean;
moveToKill: boolean;
collision: boolean;
distance: number;
directions: Direction[];
speed: number;
};
abstract availableMoves(fromX: number, fromY: number, getPiece: GetPiece, turns: Turn[], size: number): Action[];
}