Compare commits

...

2 Commits

Author SHA1 Message Date
ee4dbc0428
[processor] init 2024-03-05 23:18:46 +08:00
7af8e1b935
[server] fix spelling 2024-03-05 23:18:37 +08:00
12 changed files with 148 additions and 1 deletions

0
processor/index.mjs Normal file
View File

10
processor/package.json Normal file
View 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"
}
}

View 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
};

View File

View 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 */ ];

View 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
}
};

View 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;

View File

@ -0,0 +1,5 @@
import { BASIC_TYPES } from '@og/binary-struct';
/** @typedef {number} PosT */
export const TYPEDEF_PosT = BASIC_TYPES.u8;

View 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;

View 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 },
];
};

View File

@ -0,0 +1,5 @@
import { BASIC_TYPES } from '@og/binary-struct';
/** @typedef {number} Unit */
export const TYPEDEF_Unit = BASIC_TYPES.i32;

View File

@ -23,7 +23,7 @@ function calcAccountUUID(handle) {
} }
/** /**
* A Model repersenting an user account. * A Model representing an user account.
* @class * @class
* @extends {BaseModel} * @extends {BaseModel}
*/ */