| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- class move_direction {
- static get add() {
- return 1;
- }
- static get stop() {
- return 0;
- }
- static get sub() {
- return -1;
- }
- static contains(target) {
- if (target === move_direction.add) return true;
- if (target === move_direction.stop) return true;
- if (target === move_direction.sub) return true;
-
- return false;
- }
- }
- class moving {
- #x;
- #y;
- #z;
- constructor() {
- this.#x = 0;
- this.#y = 0;
- this.#z = 0;
- }
- get x() {
- return this.#x;
- }
- get y() {
- return this.#y;
- }
- get z() {
- return this.#z;
- }
- set x(target) {
- if (!move_direction.contains(target)) {
- throw new TypeError("New direction must be from move direction.");
- }
- this.#x = target;
- }
- set y(target) {
- if (!move_direction.contains(target)) {
- throw new TypeError("New direction must be from move direction.");
- }
- this.#y = target;
- }
- set z(target) {
- if (!move_direction.contains(target)) {
- throw new TypeError("New direction must be from move direction.");
- }
- this.#z = target;
- }
- stop() {
- this.x = move_direction.stop;
- this.y = move_direction.stop;
- this.z = move_direction.stop;
- }
- }
- export { moving, move_direction }
|