@logic-pad/core
Version:
62 lines (61 loc) • 1.8 kB
JavaScript
import { ConfigType } from '../config.js';
import GridData from '../grid.js';
import { Direction } from '../primitives.js';
import DirectionLinkerSymbol from './directionLinkerSymbol.js';
export default class GalaxySymbol extends DirectionLinkerSymbol {
x;
y;
title = 'Galaxy';
static linkedDirections = {
[Direction.Left]: Direction.Right,
[Direction.Up]: Direction.Down,
[Direction.Right]: Direction.Left,
[Direction.Down]: Direction.Up,
};
/**
* **Galaxies are centers of rotational symmetry**
*
* @param x - The x-coordinate of the symbol.
* @param y - The y-coordinate of the symbol.
*/
constructor(x, y) {
super(x, y);
this.x = x;
this.y = y;
super.changeDirections(GalaxySymbol.linkedDirections);
}
get id() {
return `galaxy`;
}
get explanation() {
return `*Galaxies* are centers of rotational symmetry`;
}
get configs() {
return Object.freeze([
{
type: ConfigType.Number,
default: 0,
field: 'x',
description: 'X',
configurable: false,
},
{
type: ConfigType.Number,
default: 0,
field: 'y',
description: 'Y',
configurable: false,
},
]);
}
createExampleGrid() {
return Object.freeze(GridData.create(['wbbbb', 'wbwww', 'bbwbb', 'wwwbb']).addSymbol(new GalaxySymbol(2, 2)));
}
validateSymbol(grid) {
return super.validateSymbol(grid);
}
copyWith({ x, y }) {
return new GalaxySymbol(x ?? this.x, y ?? this.y);
}
}
export const instance = new GalaxySymbol(0, 0);