import { Orientation } from '../../../primitives.js';
import DirectionLinkerBTModule from './directionLinker.js';
export default class LotusBTModule extends DirectionLinkerBTModule {
    constructor(instr) {
        super(instr);
        Object.defineProperty(this, "instr", {
            enumerable: true,
            configurable: true,
            writable: true,
            value: void 0
        });
        this.instr = instr;
    }
    // Translate a position in relative to a lotus symbol
    movePos(grid, x, y) {
        const symbol = this.instr;
        let pos;
        if (symbol.orientation === Orientation.Up ||
            symbol.orientation === Orientation.Down) {
            pos = { x: 2 * symbol.x - x, y };
        }
        else if (symbol.orientation === Orientation.UpRight ||
            symbol.orientation === Orientation.DownLeft) {
            pos = { x: symbol.y + symbol.x - y, y: symbol.y + symbol.x - x };
        }
        else if (symbol.orientation === Orientation.Right ||
            symbol.orientation === Orientation.Left) {
            pos = { x, y: 2 * symbol.y - y };
        }
        else if (symbol.orientation === Orientation.DownRight ||
            symbol.orientation === Orientation.UpLeft) {
            pos = { x: symbol.x - symbol.y + y, y: symbol.y - symbol.x + x };
        }
        return grid.isInBound(pos.x, pos.y) ? pos : null;
    }
}
