[processor] init
This commit is contained in:
parent
7af8e1b935
commit
ee4dbc0428
0
processor/index.mjs
Normal file
0
processor/index.mjs
Normal file
10
processor/package.json
Normal file
10
processor/package.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"name": "@og/processor",
|
||||||
|
"type": "module",
|
||||||
|
"main": "index.mjs",
|
||||||
|
"dependencies": {
|
||||||
|
"@og/binary-struct": "file:../shared/bstruct",
|
||||||
|
"@og/utility": "file:../shared/utility",
|
||||||
|
"@og/error-utils": "file:../shared/error-utils"
|
||||||
|
}
|
||||||
|
}
|
27
processor/src/logic/board.mjs
Normal file
27
processor/src/logic/board.mjs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { Queue } from '@og/utility';
|
||||||
|
|
||||||
|
/** @typedef {import('../shared/player.mjs').Player} Player */
|
||||||
|
/** @typedef {import('../shared/team.mjs').Team} Team */
|
||||||
|
|
||||||
|
export class PlayerState {
|
||||||
|
/** @type {Player} */
|
||||||
|
id;
|
||||||
|
|
||||||
|
/** @type {Team} */
|
||||||
|
team;
|
||||||
|
|
||||||
|
/** @type {boolean} */
|
||||||
|
is_defeated = false;
|
||||||
|
|
||||||
|
/** @type {Queue} */
|
||||||
|
orders = new Queue();
|
||||||
|
|
||||||
|
constructor(id, team) {
|
||||||
|
this.id = id;
|
||||||
|
this.team = team;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export class GameBoard {
|
||||||
|
// TODO
|
||||||
|
};
|
0
processor/src/logic/team.mjs
Normal file
0
processor/src/logic/team.mjs
Normal file
15
processor/src/shared/direction.mjs
Normal file
15
processor/src/shared/direction.mjs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { BASIC_TYPES } from '@og/binary-struct';
|
||||||
|
|
||||||
|
/** @typedef {number} Direction */
|
||||||
|
|
||||||
|
export const DIRECTION = {
|
||||||
|
N: 0x00,
|
||||||
|
S: 0x01,
|
||||||
|
W: 0x02,
|
||||||
|
E: 0x03,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const TYPEDEF_Direction = BASIC_TYPES.u8;
|
||||||
|
|
||||||
|
export const DIRECTION_DELTA_X = [ /* TODO */ ];
|
||||||
|
export const DIRECTION_DELTA_Y = [ /* TODO */ ];
|
32
processor/src/shared/move.mjs
Normal file
32
processor/src/shared/move.mjs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/** @typedef {import('./player.mjs').Player} Player */
|
||||||
|
/** @typedef {import('./direction.mjs').Direction} Direction */
|
||||||
|
/** @typedef {import('./pos.mjs').PosT} PosT */
|
||||||
|
|
||||||
|
export class PlayerMove {
|
||||||
|
/** @type {Player} */
|
||||||
|
player;
|
||||||
|
|
||||||
|
/** @type {PosT} */
|
||||||
|
x;
|
||||||
|
|
||||||
|
/** @type {PosT} */
|
||||||
|
y;
|
||||||
|
|
||||||
|
/** @type {Direction} */
|
||||||
|
dir;
|
||||||
|
|
||||||
|
/** @type {boolean} */
|
||||||
|
is_half = false;
|
||||||
|
|
||||||
|
isValid() {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
get tx() {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
get ty() {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
};
|
8
processor/src/shared/player.mjs
Normal file
8
processor/src/shared/player.mjs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { BASIC_TYPES } from '@og/binary-struct';
|
||||||
|
|
||||||
|
/** @typedef {number} Player */
|
||||||
|
|
||||||
|
/** @type {Player} */
|
||||||
|
export const NEUTRAL_PLAYER = 0;
|
||||||
|
|
||||||
|
export const TYPEDEF_Player = BASIC_TYPES.u8;
|
5
processor/src/shared/pos.mjs
Normal file
5
processor/src/shared/pos.mjs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { BASIC_TYPES } from '@og/binary-struct';
|
||||||
|
|
||||||
|
/** @typedef {number} PosT */
|
||||||
|
|
||||||
|
export const TYPEDEF_PosT = BASIC_TYPES.u8;
|
8
processor/src/shared/team.mjs
Normal file
8
processor/src/shared/team.mjs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { BASIC_TYPES } from '@og/binary-struct';
|
||||||
|
|
||||||
|
/** @typedef {number} Team */
|
||||||
|
|
||||||
|
/** @type {Team} */
|
||||||
|
export const NEUTRAL_TEAM = 0;
|
||||||
|
|
||||||
|
export const TYPEDEF_Team = BASIC_TYPES.u8;
|
37
processor/src/shared/tile.mjs
Normal file
37
processor/src/shared/tile.mjs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import { NEUTRAL_PLAYER, TYPEDEF_Player } from './player.mjs';
|
||||||
|
import { TYPEDEF_Unit } from './unit.mjs';
|
||||||
|
import { BASIC_TYPES } from '@og/binary-struct';
|
||||||
|
|
||||||
|
/** @typedef {import('./player.mjs').Player} Player */
|
||||||
|
/** @typedef {import('./unit.mjs').Unit} Unit */
|
||||||
|
|
||||||
|
/** @typedef {number} TileType */
|
||||||
|
|
||||||
|
export const TILE_TYPE = {
|
||||||
|
misty: 0x00,
|
||||||
|
mountain: 0x01,
|
||||||
|
stronghold: 0x02,
|
||||||
|
blank: 0x03,
|
||||||
|
capital: 0x04,
|
||||||
|
swamp: 0x05,
|
||||||
|
isValid: (type) => (0 <= type && type <= 5),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const TYPEDEF_TileType = BASIC_TYPES.u8;
|
||||||
|
|
||||||
|
export class Tile {
|
||||||
|
/** @type {Player} */
|
||||||
|
owner = NEUTRAL_PLAYER;
|
||||||
|
|
||||||
|
/** @type {TileType} */
|
||||||
|
type = TILE_TYPE.misty;
|
||||||
|
|
||||||
|
/** @type {Unit} */
|
||||||
|
unit = 0;
|
||||||
|
|
||||||
|
static typedef = [
|
||||||
|
{ field: 'owner', type: TYPEDEF_Player },
|
||||||
|
{ field: 'type', type: TYPEDEF_TileType },
|
||||||
|
{ field: 'unit', type: TYPEDEF_Unit },
|
||||||
|
];
|
||||||
|
};
|
5
processor/src/shared/unit.mjs
Normal file
5
processor/src/shared/unit.mjs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { BASIC_TYPES } from '@og/binary-struct';
|
||||||
|
|
||||||
|
/** @typedef {number} Unit */
|
||||||
|
|
||||||
|
export const TYPEDEF_Unit = BASIC_TYPES.i32;
|
Loading…
x
Reference in New Issue
Block a user