This repository has been archived by the owner on Apr 9, 2023. It is now read-only.
/
Formats.ts
85 lines (78 loc) · 1.44 KB
/
Formats.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/** @license
* JSON Kifu Format
* Copyright (c) 2014 na2hiro (https://github.com/na2hiro)
* This software is released under the MIT License.
* http://opensource.org/licenses/mit-license.php
*/
import {Color} from "shogi.js";
import {Kind} from "shogi.js/dist/src/Kind";
/**
* Kifu format
*/
export interface IJSONKifuFormat {
header: {[index: string]: string};
initial?: {
preset: string;
data?: IStateFormat;
};
moves: IMoveFormat[];
}
/**
* Game state
*/
export interface IStateFormat {
color: Color;
board: IPiece[][];
hands: Array<{
[index in Extract<Kind, "FU" | "KY" | "KE" | "GI" | "KI" | "KA" | "HI">]: number;
}>;
}
/**
* Piece
* TODO: Make color and kind nonnull
*/
export interface IPiece {
color?: Color;
kind?: Kind;
}
/**
* Abstract Move
*/
export interface IMoveMoveFormat {
color: Color;
from?: IPlaceFormat;
to?: IPlaceFormat;
piece: Kind;
same?: boolean;
promote?: boolean;
capture?: Kind;
relative?: string;
}
/**
* Move
*/
export interface IMoveFormat {
comments?: string[];
move?: IMoveMoveFormat;
time?: {
now: ITimeFormat;
total: ITimeFormat;
};
special?: string;
forks?: IMoveFormat[][];
}
/**
* Elapsed Time
*/
export interface ITimeFormat {
h?: number;
m: number;
s: number;
}
/**
* Position on boards
*/
export interface IPlaceFormat {
x: number;
y: number;
}