gungi.js 1.0.20 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,148 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.remove_stockpile = exports.remove = exports.get_top = exports.get = exports.put = exports.init_stockpile = void 0;
4
- const constants_1 = require("./constants");
5
- const init_stockpile = (color) => {
6
- return new Array({
7
- piece: {
8
- type: constants_1.MARSHAL,
9
- color,
10
- },
11
- amount: 1,
12
- }, {
13
- piece: {
14
- type: constants_1.PAWN,
15
- color,
16
- },
17
- amount: 9,
18
- }, {
19
- piece: {
20
- type: constants_1.SPY,
21
- color,
22
- },
23
- amount: 2,
24
- }, {
25
- piece: {
26
- type: constants_1.CANNON,
27
- color,
28
- },
29
- amount: 2,
30
- }, {
31
- piece: {
32
- type: constants_1.FORTRESS,
33
- color,
34
- },
35
- amount: 2,
36
- }, {
37
- piece: {
38
- type: constants_1.SAMURAI,
39
- color,
40
- },
41
- amount: 2,
42
- }, {
43
- piece: {
44
- type: constants_1.CAPTAIN,
45
- color,
46
- },
47
- amount: 1,
48
- }, {
49
- piece: {
50
- type: constants_1.MUSKETEER,
51
- color,
52
- },
53
- amount: 1,
54
- }, {
55
- piece: {
56
- type: constants_1.KNIGHT,
57
- color,
58
- },
59
- amount: 2,
60
- }, {
61
- piece: {
62
- type: constants_1.ARCHER,
63
- color,
64
- },
65
- amount: 2,
66
- }, {
67
- piece: {
68
- type: constants_1.GENERAL,
69
- color,
70
- },
71
- amount: 6,
72
- }, {
73
- piece: {
74
- type: constants_1.LIEUTENANT_GENERAL,
75
- color,
76
- },
77
- amount: 4,
78
- }, {
79
- piece: {
80
- type: constants_1.MAJOR_GENERAL,
81
- color,
82
- },
83
- amount: 4,
84
- });
85
- };
86
- exports.init_stockpile = init_stockpile;
87
- const put = (board, piece, square) => {
88
- let rank = parseInt(square.split('-')[0]);
89
- let file = parseInt(square.split('-')[1]);
90
- let top = exports.get_top(board, square);
91
- let tier = top == null ? 1 : top.tier + 1;
92
- if (tier > 3 || !piece) {
93
- return null;
94
- }
95
- board[9 - rank][file - 1][tier - 1] = {
96
- type: piece.type,
97
- color: piece.color,
98
- };
99
- return {
100
- piece,
101
- tier,
102
- };
103
- };
104
- exports.put = put;
105
- const get = (board, square) => {
106
- let rank = parseInt(square.split('-')[0]);
107
- let file = parseInt(square.split('-')[1]);
108
- return board[9 - rank][file - 1];
109
- };
110
- exports.get = get;
111
- const get_top = (board, square) => {
112
- let tower = exports.get(board, square);
113
- for (let i = 2; i >= 0; i--) {
114
- if (tower[i] !== null) {
115
- return {
116
- piece: tower[i],
117
- tier: i + 1,
118
- };
119
- }
120
- }
121
- return null;
122
- };
123
- exports.get_top = get_top;
124
- const remove = (board, square) => {
125
- let tower = exports.get(board, square);
126
- for (let i = 2; i >= 0; i--) {
127
- if (tower[i] !== null) {
128
- let temp = tower[i];
129
- tower[i] = null;
130
- return temp;
131
- }
132
- }
133
- return null;
134
- };
135
- exports.remove = remove;
136
- const remove_stockpile = (stockpile, piece) => {
137
- var stockPiece = stockpile.find((x) => x.piece.type === piece.type && x.piece.color === piece.color);
138
- if (!stockPiece) {
139
- return null;
140
- }
141
- if (stockPiece.amount === 0) {
142
- return null;
143
- }
144
- stockPiece.amount--;
145
- return stockPiece;
146
- };
147
- exports.remove_stockpile = remove_stockpile;
148
- //# sourceMappingURL=helper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helper.js","sourceRoot":"","sources":["../../src/utils/helper.ts"],"names":[],"mappings":";;;AAEA,2CAcqB;AAEd,MAAM,cAAc,GAAG,CAAC,KAAgB,EAAgB,EAAE;IAChE,OAAO,IAAI,KAAK,CACf;QACC,KAAK,EAAE;YACN,IAAI,EAAE,mBAAO;YACb,KAAK;SACL;QACD,MAAM,EAAE,CAAC;KACT,EACD;QACC,KAAK,EAAE;YACN,IAAI,EAAE,gBAAI;YACV,KAAK;SACL;QACD,MAA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,gBAAgB,oBAc3B"}
@@ -1,25 +0,0 @@
1
- import { Piece, RelaxMove } from '../interfaces/igungi';
2
- export declare const get_squares_around: (square: string, ignore_list: {
3
- rank_offset: number;
4
- file_offset: number;
5
- }[]) => {
6
- rank: number;
7
- file: number;
8
- }[];
9
- export declare const isSquareOutOfBounds: (rank: number, file: number) => boolean;
10
- export declare const probe_directions: (board: Array<Array<Array<Piece | null>>>, square: string, depth: number, directions: boolean[]) => any[];
11
- export declare const generate_moves_from_probes: (board: Array<Array<Array<Piece | null>>>, probes: {
12
- rank: number;
13
- file: number;
14
- }[], src: {
15
- piece: Piece | null;
16
- tier: number;
17
- }, square: string, turn: 'w' | 'b') => RelaxMove[];
18
- export declare const single_sqaure_move_gen: (board: Array<Array<Array<Piece | null>>>, src: {
19
- piece: Piece | null;
20
- tier: number;
21
- }, square: string) => {
22
- rank: number;
23
- file: number;
24
- }[];
25
- //# sourceMappingURL=move_gen.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"move_gen.d.ts","sourceRoot":"","sources":["../../src/utils/move_gen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AA0BxD,eAAO,MAAM,kBAAkB,WACtB,MAAM,eACD;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,EAAE;;;GAyB3D,CAAC;AAEF,eAAO,MAAM,mBAAmB,SAAU,MAAM,QAAQ,MAAM,YAS7D,CAAC;AAgBF,eAAO,MAAM,gBAAgB,UACrB,MAAM,MAAM,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,UAChC,MAAM,SACP,MAAM,cACD,OAAO,EAAE,UAyDrB,CAAC;AAEF,eAAO,MAAM,0BAA0B,UAC/B,MAAM,MAAM,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,UAChC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,OACnC;IAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,UAClC,MAAM,QACR,GAAG,GAAG,GAAG,gBAsCf,CAAC;AAEF,eAAO,MAAM,sBAAsB,UAC3B,MAAM,MAAM,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,OACnC;IAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,UAClC,MAAM;UAEK,MAAM;UAAQ,MAAM;GAwiCvC,CAAC"}