jp.ms.common.engine 1.0.3 → 1.0.4

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.
Files changed (218) hide show
  1. package/dist/base/game-control-player-turn.d.ts +4 -4
  2. package/dist/base/game-control-player-turn.d.ts.map +1 -1
  3. package/dist/base/game-control-player-turn.js.map +1 -1
  4. package/dist/base/game-master.d.ts +24 -21
  5. package/dist/base/game-master.d.ts.map +1 -1
  6. package/dist/base/game-master.js +6 -2
  7. package/dist/base/game-master.js.map +1 -1
  8. package/dist/base/game-player-connections-helper.d.ts +15 -0
  9. package/dist/base/game-player-connections-helper.d.ts.map +1 -0
  10. package/dist/base/game-player-connections-helper.js +33 -0
  11. package/dist/base/game-player-connections-helper.js.map +1 -0
  12. package/dist/base/game-player.d.ts +3 -1
  13. package/dist/base/game-player.d.ts.map +1 -1
  14. package/dist/base/game-player.js +3 -1
  15. package/dist/base/game-player.js.map +1 -1
  16. package/dist/base/game-room.d.ts +15 -17
  17. package/dist/base/game-room.d.ts.map +1 -1
  18. package/dist/base/game-room.js +16 -17
  19. package/dist/base/game-room.js.map +1 -1
  20. package/dist/base/game-round.d.ts +7 -10
  21. package/dist/base/game-round.d.ts.map +1 -1
  22. package/dist/base/game-round.js +2 -4
  23. package/dist/base/game-round.js.map +1 -1
  24. package/dist/base/game-state-machine.d.ts +4 -4
  25. package/dist/base/game-state-machine.d.ts.map +1 -1
  26. package/dist/base/game-state-machine.js.map +1 -1
  27. package/dist/base/game-summary-result.d.ts +3 -0
  28. package/dist/base/game-summary-result.d.ts.map +1 -0
  29. package/dist/base/game-summary-result.js +7 -0
  30. package/dist/base/game-summary-result.js.map +1 -0
  31. package/dist/base/game-table-seat.d.ts +3 -3
  32. package/dist/base/game-table-seat.d.ts.map +1 -1
  33. package/dist/base/game-table-seat.js.map +1 -1
  34. package/dist/base/game-table-seats.d.ts +12 -12
  35. package/dist/base/game-table-seats.d.ts.map +1 -1
  36. package/dist/base/game-table-seats.js.map +1 -1
  37. package/dist/base/game-table.d.ts +25 -51
  38. package/dist/base/game-table.d.ts.map +1 -1
  39. package/dist/base/game-table.js.map +1 -1
  40. package/dist/base/index.d.ts +2 -1
  41. package/dist/base/index.d.ts.map +1 -1
  42. package/dist/base/index.js +3 -1
  43. package/dist/base/index.js.map +1 -1
  44. package/dist/base/standard-game-state.d.ts +2 -2
  45. package/dist/base/standard-game-state.d.ts.map +1 -1
  46. package/dist/base/standard-game-state.js +1 -1
  47. package/dist/base/standard-game-state.js.map +1 -1
  48. package/dist/base-rooms/fast-tournament-room.d.ts +0 -13
  49. package/dist/base-rooms/fast-tournament-room.d.ts.map +1 -1
  50. package/dist/base-rooms/fast-tournament-room.js +59 -51
  51. package/dist/base-rooms/fast-tournament-room.js.map +1 -1
  52. package/dist/base-rooms/index.d.ts +1 -5
  53. package/dist/base-rooms/index.d.ts.map +1 -1
  54. package/dist/base-rooms/index.js +3 -9
  55. package/dist/base-rooms/index.js.map +1 -1
  56. package/dist/base-rooms/scheduled-tournament-room.d.ts +0 -27
  57. package/dist/base-rooms/scheduled-tournament-room.d.ts.map +1 -1
  58. package/dist/base-rooms/scheduled-tournament-room.js +181 -164
  59. package/dist/base-rooms/scheduled-tournament-room.js.map +1 -1
  60. package/dist/base-rooms/simple-room.d.ts +5 -4
  61. package/dist/base-rooms/simple-room.d.ts.map +1 -1
  62. package/dist/base-rooms/simple-room.js +16 -0
  63. package/dist/base-rooms/simple-room.js.map +1 -1
  64. package/dist/base-rooms/tournament-room.d.ts +0 -46
  65. package/dist/base-rooms/tournament-room.d.ts.map +1 -1
  66. package/dist/base-rooms/tournament-room.js +169 -109
  67. package/dist/base-rooms/tournament-room.js.map +1 -1
  68. package/dist/base-rooms/tournament-state.d.ts +2 -2
  69. package/dist/base-rooms/tournament-state.d.ts.map +1 -1
  70. package/dist/base-rooms/tournament-state.js +2 -2
  71. package/dist/base-rooms/tournament-state.js.map +1 -1
  72. package/dist/board-game/base/board-cell.d.ts +0 -15
  73. package/dist/board-game/base/board-cell.d.ts.map +1 -1
  74. package/dist/board-game/base/board-cell.js +50 -40
  75. package/dist/board-game/base/board-cell.js.map +1 -1
  76. package/dist/board-game/base/board-figure.d.ts +0 -15
  77. package/dist/board-game/base/board-figure.d.ts.map +1 -1
  78. package/dist/board-game/base/board-figure.js +49 -36
  79. package/dist/board-game/base/board-figure.js.map +1 -1
  80. package/dist/board-game/base/board-game-master.d.ts +0 -18
  81. package/dist/board-game/base/board-game-master.d.ts.map +1 -1
  82. package/dist/board-game/base/board-game-master.js +56 -34
  83. package/dist/board-game/base/board-game-master.js.map +1 -1
  84. package/dist/board-game/base/board-player-move.d.ts +0 -10
  85. package/dist/board-game/base/board-player-move.d.ts.map +1 -1
  86. package/dist/board-game/base/board-player-move.js +29 -28
  87. package/dist/board-game/base/board-player-move.js.map +1 -1
  88. package/dist/board-game/base/board-player.d.ts +0 -12
  89. package/dist/board-game/base/board-player.d.ts.map +1 -1
  90. package/dist/board-game/base/board-player.js +43 -29
  91. package/dist/board-game/base/board-player.js.map +1 -1
  92. package/dist/board-game/base/board-table.d.ts +0 -16
  93. package/dist/board-game/base/board-table.d.ts.map +1 -1
  94. package/dist/board-game/base/board-table.js +52 -33
  95. package/dist/board-game/base/board-table.js.map +1 -1
  96. package/dist/board-game/d1-board-game/d1-board-table.d.ts +0 -18
  97. package/dist/board-game/d1-board-game/d1-board-table.d.ts.map +1 -1
  98. package/dist/board-game/d1-board-game/d1-board-table.js +56 -39
  99. package/dist/board-game/d1-board-game/d1-board-table.js.map +1 -1
  100. package/dist/board-game/d2-board-game/d2-board-cell.d.ts +0 -11
  101. package/dist/board-game/d2-board-game/d2-board-cell.d.ts.map +1 -1
  102. package/dist/board-game/d2-board-game/d2-board-cell.js +30 -24
  103. package/dist/board-game/d2-board-game/d2-board-cell.js.map +1 -1
  104. package/dist/board-game/d2-board-game/d2-board-pattern-move-figure.d.ts +0 -28
  105. package/dist/board-game/d2-board-game/d2-board-pattern-move-figure.d.ts.map +1 -1
  106. package/dist/board-game/d2-board-game/d2-board-pattern-move-figure.js +79 -49
  107. package/dist/board-game/d2-board-game/d2-board-pattern-move-figure.js.map +1 -1
  108. package/dist/board-game/d2-board-game/d2-board-table.d.ts +0 -48
  109. package/dist/board-game/d2-board-game/d2-board-table.d.ts.map +1 -1
  110. package/dist/board-game/d2-board-game/d2-board-table.js +262 -182
  111. package/dist/board-game/d2-board-game/d2-board-table.js.map +1 -1
  112. package/dist/board-game/d2-board-game/types.d.ts +0 -4
  113. package/dist/board-game/d2-board-game/types.d.ts.map +1 -1
  114. package/dist/board-game/d2-board-game/types.js +4 -1
  115. package/dist/board-game/d2-board-game/types.js.map +1 -1
  116. package/dist/board-game/dice.js +2 -2
  117. package/dist/board-game/dice.js.map +1 -1
  118. package/dist/board-game/index.d.ts +0 -12
  119. package/dist/board-game/index.d.ts.map +1 -1
  120. package/dist/board-game/index.js +28 -24
  121. package/dist/board-game/index.js.map +1 -1
  122. package/dist/cards-game/cards-game-master.d.ts +7 -8
  123. package/dist/cards-game/cards-game-master.d.ts.map +1 -1
  124. package/dist/cards-game/cards-game-master.js +13 -10
  125. package/dist/cards-game/cards-game-master.js.map +1 -1
  126. package/dist/cards-game/cards-player.d.ts.map +1 -1
  127. package/dist/cards-game/cards-player.js +1 -1
  128. package/dist/cards-game/cards-player.js.map +1 -1
  129. package/dist/cards-game/index.d.ts +1 -2
  130. package/dist/cards-game/index.d.ts.map +1 -1
  131. package/dist/cards-game/index.js +1 -3
  132. package/dist/cards-game/index.js.map +1 -1
  133. package/dist/index.d.ts +0 -1
  134. package/dist/index.d.ts.map +1 -1
  135. package/dist/index.js +1 -1
  136. package/dist/index.js.map +1 -1
  137. package/dist/tests/just-black-jack/domain/black-jack-dealer.d.ts +6 -0
  138. package/dist/tests/just-black-jack/domain/black-jack-dealer.d.ts.map +1 -0
  139. package/dist/tests/just-black-jack/domain/black-jack-dealer.js +14 -0
  140. package/dist/tests/just-black-jack/domain/black-jack-dealer.js.map +1 -0
  141. package/dist/tests/just-black-jack/domain/black-jack-game-master.d.ts +28 -0
  142. package/dist/tests/just-black-jack/domain/black-jack-game-master.d.ts.map +1 -0
  143. package/dist/tests/just-black-jack/domain/black-jack-game-master.js +90 -0
  144. package/dist/tests/just-black-jack/domain/black-jack-game-master.js.map +1 -0
  145. package/dist/tests/just-black-jack/domain/black-jack-player.d.ts +9 -0
  146. package/dist/tests/just-black-jack/domain/black-jack-player.d.ts.map +1 -0
  147. package/dist/tests/just-black-jack/domain/black-jack-player.js +21 -0
  148. package/dist/tests/just-black-jack/domain/black-jack-player.js.map +1 -0
  149. package/dist/tests/just-black-jack/helpers/calculate-result.d.ts +3 -0
  150. package/dist/tests/just-black-jack/helpers/calculate-result.d.ts.map +1 -0
  151. package/dist/tests/just-black-jack/helpers/calculate-result.js +30 -0
  152. package/dist/tests/just-black-jack/helpers/calculate-result.js.map +1 -0
  153. package/dist/tests/just-black-jack/helpers/calculate-result.test.d.ts +2 -0
  154. package/dist/tests/just-black-jack/helpers/calculate-result.test.d.ts.map +1 -0
  155. package/dist/tests/just-black-jack/helpers/calculate-result.test.js +34 -0
  156. package/dist/tests/just-black-jack/helpers/calculate-result.test.js.map +1 -0
  157. package/dist/tests/just-black-jack/rooms/black-jack-simple-room.d.ts +6 -0
  158. package/dist/tests/just-black-jack/rooms/black-jack-simple-room.d.ts.map +1 -0
  159. package/dist/tests/just-black-jack/rooms/black-jack-simple-room.js +13 -0
  160. package/dist/tests/just-black-jack/rooms/black-jack-simple-room.js.map +1 -0
  161. package/dist/tests/just-black-jack/tests/black-jack-simple-room.test.d.ts +2 -0
  162. package/dist/tests/just-black-jack/tests/black-jack-simple-room.test.d.ts.map +1 -0
  163. package/dist/tests/just-black-jack/tests/black-jack-simple-room.test.js +58 -0
  164. package/dist/tests/just-black-jack/tests/black-jack-simple-room.test.js.map +1 -0
  165. package/dist/tests/just-black-jack/tests/common.d.ts +11 -0
  166. package/dist/tests/just-black-jack/tests/common.d.ts.map +1 -0
  167. package/dist/tests/just-black-jack/tests/common.js +51 -0
  168. package/dist/tests/just-black-jack/tests/common.js.map +1 -0
  169. package/package.json +2 -1
  170. package/src/base/game-control-player-turn.ts +5 -5
  171. package/src/base/game-master.ts +25 -19
  172. package/src/base/game-player-connections-helper.ts +40 -0
  173. package/src/base/game-player.ts +5 -2
  174. package/src/base/game-room.ts +26 -30
  175. package/src/base/game-round.ts +10 -16
  176. package/src/base/game-state-machine.ts +7 -7
  177. package/src/base/game-summary-result.ts +3 -0
  178. package/src/base/game-table-seat.ts +3 -3
  179. package/src/base/game-table-seats.ts +13 -13
  180. package/src/base/game-table.ts +28 -79
  181. package/src/base/index.ts +2 -0
  182. package/src/base/standard-game-state.ts +2 -2
  183. package/src/base-rooms/fast-tournament-room.ts +59 -59
  184. package/src/base-rooms/index.ts +9 -9
  185. package/src/base-rooms/scheduled-tournament-room.ts +181 -181
  186. package/src/base-rooms/simple-room.ts +15 -4
  187. package/src/base-rooms/tournament-room.ts +169 -169
  188. package/src/base-rooms/tournament-state.ts +2 -2
  189. package/src/board-game/base/board-cell.ts +50 -50
  190. package/src/board-game/base/board-figure.ts +49 -49
  191. package/src/board-game/base/board-game-master.ts +56 -56
  192. package/src/board-game/base/board-player-move.ts +29 -29
  193. package/src/board-game/base/board-player.ts +43 -43
  194. package/src/board-game/base/board-table.ts +52 -52
  195. package/src/board-game/d1-board-game/d1-board-table.ts +56 -56
  196. package/src/board-game/d2-board-game/d2-board-cell.ts +30 -30
  197. package/src/board-game/d2-board-game/d2-board-pattern-move-figure.ts +79 -79
  198. package/src/board-game/d2-board-game/d2-board-table.ts +262 -262
  199. package/src/board-game/d2-board-game/types.ts +4 -4
  200. package/src/board-game/dice.ts +1 -1
  201. package/src/board-game/index.ts +28 -28
  202. package/src/cards-game/cards-game-master.ts +19 -16
  203. package/src/cards-game/cards-player.ts +2 -1
  204. package/src/cards-game/index.ts +0 -2
  205. package/src/index.ts +1 -1
  206. package/src/tests/just-black-jack/domain/black-jack-dealer.ts +15 -0
  207. package/src/tests/just-black-jack/domain/black-jack-game-master.ts +103 -0
  208. package/src/tests/just-black-jack/domain/black-jack-player.ts +27 -0
  209. package/src/tests/just-black-jack/helpers/calculate-result.test.ts +49 -0
  210. package/src/tests/just-black-jack/helpers/calculate-result.ts +34 -0
  211. package/src/tests/just-black-jack/rooms/black-jack-simple-room.ts +10 -0
  212. package/src/tests/just-black-jack/tests/black-jack-simple-room.test.ts +75 -0
  213. package/src/tests/just-black-jack/tests/common.ts +63 -0
  214. package/dist/cards-game/cards-table.d.ts +0 -11
  215. package/dist/cards-game/cards-table.d.ts.map +0 -1
  216. package/dist/cards-game/cards-table.js +0 -20
  217. package/dist/cards-game/cards-table.js.map +0 -1
  218. package/src/cards-game/cards-table.ts +0 -28
@@ -1,262 +1,262 @@
1
- import { flatten, last, take, uniqBy } from 'lodash';
2
-
3
- import { GamePlayer } from '../../base';
4
- import { GameTableConfig } from '../../base/game-table';
5
- import { BoardFigure } from '../base/board-figure';
6
- import { BoardTable } from '../base/board-table';
7
-
8
- import { D2BoardCell } from './d2-board-cell';
9
- import { Coordinate } from './types';
10
-
11
- export interface ID2BoardTable<BF extends BoardFigure> {
12
- getUpLeftDiagonal (center: Coordinate): Array<D2BoardCell<BF>>;
13
-
14
- getUpRightDiagonal (center: Coordinate): Array<D2BoardCell<BF>>;
15
-
16
- getDownLeftDiagonal (center: Coordinate): Array<D2BoardCell<BF>>;
17
-
18
- getDownRightDiagonal (center: Coordinate): Array<D2BoardCell<BF>>;
19
-
20
- getUpVertical (center: Coordinate): Array<D2BoardCell<BF>>;
21
-
22
- getDownVertical (center: Coordinate): Array<D2BoardCell<BF>>;
23
-
24
- getLeftHorizontal (center: Coordinate): Array<D2BoardCell<BF>>;
25
-
26
- getRightHorizontal (center: Coordinate): Array<D2BoardCell<BF>>;
27
- }
28
-
29
- export abstract class D2BoardTable<
30
- GP extends GamePlayer,
31
- GM,
32
- GSR,
33
- BF extends BoardFigure,
34
- > extends BoardTable<GP, GM, GSR, BF, D2BoardCell<BF>> implements ID2BoardTable<BF> {
35
- cells: Array<Array<D2BoardCell<BF>>>;
36
- readonly height: number;
37
- readonly width: number;
38
-
39
- protected constructor (config: GameTableConfig<GP>, height: number, width: number) {
40
- super(config);
41
- this.height = height;
42
- this.width = width;
43
- this.initCells();
44
- }
45
-
46
- initCells () {
47
- const cells: Array<Array<D2BoardCell<BF>>> = [];
48
- let id = 0;
49
- for (let i = 0; i < this.getHeight(); i += 1) {
50
- cells.push([]);
51
- for (let j = 0; j < this.getWidth(); j += 1) {
52
- cells[i].push(new D2BoardCell(id, j, i));
53
- id += 1;
54
- }
55
- }
56
-
57
- this.cells = cells;
58
- }
59
-
60
- getHeight () {
61
- return this.height;
62
- }
63
-
64
- getWidth () {
65
- return this.width;
66
- }
67
-
68
- getCell (id: number): D2BoardCell<BF> | null {
69
- return this.getCellsArray().find((item) => item.getId() === id) ?? null;
70
- }
71
-
72
- getCellByCoordinate (y: number, x: number): D2BoardCell<BF> | null {
73
- return this.cells[y]?.[x] ?? null;
74
- }
75
-
76
- getCells (): Array<Array<D2BoardCell<BF>>> {
77
- return this.cells;
78
- }
79
-
80
- getCellsArray (): Array<D2BoardCell<BF>> {
81
- return flatten(this.cells);
82
- }
83
-
84
- getUpLeftDiagonal (center: Coordinate): Array<D2BoardCell<BF>> {
85
- const cells: Array<D2BoardCell<BF>> = [];
86
-
87
- for (let row = center.y, col = center.x; row >= 0 && col >= 0; row -= 1, col -= 1) {
88
- const foundCell = this.getCellByCoordinate(row, col);
89
- if (foundCell) {
90
- cells.push(foundCell);
91
- }
92
- }
93
-
94
- return cells;
95
- }
96
-
97
- getUpRightDiagonal (center: Coordinate): Array<D2BoardCell<BF>> {
98
- const cells: Array<D2BoardCell<BF>> = [];
99
-
100
- for (let row = center.y, col = center.x; row >= 0 && col < this.cells.length; row -= 1, col += 1) {
101
- const foundCell = this.getCellByCoordinate(row, col);
102
- if (foundCell) {
103
- cells.push(foundCell);
104
- }
105
- }
106
-
107
- return cells;
108
- }
109
-
110
- getDownLeftDiagonal (center: Coordinate) {
111
- const cells: Array<D2BoardCell<BF>> = [];
112
-
113
- for (let row = center.y, col = center.x; row < 8 && col >= 0; row += 1, col -= 1) {
114
- const foundCell = this.getCellByCoordinate(row, col);
115
- if (foundCell) {
116
- cells.push(foundCell);
117
- }
118
- }
119
-
120
- return cells;
121
- }
122
-
123
- getDownRightDiagonal (center: Coordinate) {
124
- const cells: Array<D2BoardCell<BF>> = [];
125
-
126
- for (let row = center.y, col = center.x; row < 8 && col < this.cells.length; row += 1, col += 1) {
127
- const foundCell = this.getCellByCoordinate(row, col);
128
- if (foundCell) {
129
- cells.push(foundCell);
130
- }
131
- }
132
-
133
- return cells;
134
- }
135
-
136
- getUpVertical (center: Coordinate): Array<D2BoardCell<BF>> {
137
- const cells: Array<D2BoardCell<BF>> = [];
138
-
139
- for (let row = center.y, col = center.x; row >= 0; row -= 1) {
140
- const foundCell = this.getCellByCoordinate(row, col);
141
- if (foundCell) {
142
- cells.push(foundCell);
143
- }
144
- }
145
-
146
- return cells;
147
- }
148
-
149
- getDownVertical (center: Coordinate): Array<D2BoardCell<BF>> {
150
- const cells: Array<D2BoardCell<BF>> = [];
151
-
152
- for (let row = center.y, col = center.x; row < this.cells.length; row += 1) {
153
- const foundCell = this.getCellByCoordinate(row, col);
154
- if (foundCell) {
155
- cells.push(foundCell);
156
- }
157
- }
158
-
159
- return cells;
160
- }
161
-
162
- getLeftHorizontal (center: Coordinate): Array<D2BoardCell<BF>> {
163
- const cells: Array<D2BoardCell<BF>> = [];
164
-
165
- for (let row = center.y, col = center.x; col >= 0; col -= 1) {
166
- const foundCell = this.getCellByCoordinate(row, col);
167
- if (foundCell) {
168
- cells.push(foundCell);
169
- }
170
- }
171
-
172
- return cells;
173
- }
174
-
175
- getRightHorizontal (center: Coordinate): Array<D2BoardCell<BF>> {
176
- const cells: Array<D2BoardCell<BF>> = [];
177
-
178
- for (let row = center.y, col = center.x; col < this.cells.length; col += 1) {
179
- const foundCell = this.getCellByCoordinate(row, col);
180
- if (foundCell) {
181
- cells.push(foundCell);
182
- }
183
- }
184
-
185
- return cells;
186
- }
187
-
188
- getEdgedCells (center: Coordinate): Array<D2BoardCell<BF>> {
189
- const length = 3;
190
- const shift = 2;
191
-
192
- const first: Coordinate = { x: center.x - 1, y: center.y - 1 };
193
- const second: Coordinate = { x: first.x + shift, y: first.y };
194
- const third: Coordinate = { x: second.x, y: second.y + shift };
195
- const fourth: Coordinate = { x: second.x - shift, y: second.y };
196
-
197
- const list = [
198
- take(this.getRightHorizontal(first), length),
199
- take(this.getDownVertical(second), length),
200
- take(this.getLeftHorizontal(third), length),
201
- take(this.getUpVertical(fourth), length),
202
- ];
203
-
204
- return uniqBy(flatten(list), (item) => item.getId());
205
- }
206
-
207
- getEdgedRectangleCells (list: Array<Coordinate>): Array<D2BoardCell<BF>> {
208
- let cells: Array<Array<D2BoardCell<BF>>> = [];
209
-
210
- list.forEach((center) => {
211
- cells.push(this.getEdgedCells(center));
212
- });
213
-
214
- return uniqBy(flatten(cells), (item) => item.getId());
215
- }
216
-
217
- getPistolUpVerticalLeftCells (center: Coordinate): Array<D2BoardCell<BF>> {
218
- return this.getPistolCells(this.getUpVertical(center), this.getLeftHorizontal);
219
- }
220
-
221
- getPistolUpVerticalRightCells (center: Coordinate): Array<D2BoardCell<BF>> {
222
- return this.getPistolCells(this.getUpVertical(center), this.getRightHorizontal);
223
- }
224
-
225
- getPistolDownVerticalLeftCells (center: Coordinate): Array<D2BoardCell<BF>> {
226
- return this.getPistolCells(this.getDownVertical(center), this.getLeftHorizontal);
227
- }
228
-
229
- getPistolDownVerticalRightCells (center: Coordinate): Array<D2BoardCell<BF>> {
230
- return this.getPistolCells(this.getDownVertical(center), this.getRightHorizontal);
231
- }
232
-
233
- getPistolLeftHorizontalUpCells (center: Coordinate): Array<D2BoardCell<BF>> {
234
- return this.getPistolCells(this.getLeftHorizontal(center), this.getUpVertical);
235
- }
236
-
237
- getPistolLeftHorizontalDownCells (center: Coordinate): Array<D2BoardCell<BF>> {
238
- return this.getPistolCells(this.getLeftHorizontal(center), this.getDownVertical);
239
- }
240
-
241
- getPistolRightHorizontalUpCells (center: Coordinate): Array<D2BoardCell<BF>> {
242
- return this.getPistolCells(this.getRightHorizontal(center), this.getUpVertical);
243
- }
244
-
245
- getPistolRightHorizontalDownCells (center: Coordinate): Array<D2BoardCell<BF>> {
246
- return this.getPistolCells(this.getRightHorizontal(center), this.getDownVertical);
247
- }
248
-
249
- private getPistolCells (directPath: Array<D2BoardCell<BF>>, sidePath: (center: Coordinate) => Array<D2BoardCell<BF>>): Array<D2BoardCell<BF>> {
250
- const KNIGHT_UP_MOVE = 3;
251
- const KNIGHT_SIDE_MOVE = 2;
252
-
253
- const lastDirectCell = last(take(directPath, KNIGHT_UP_MOVE));
254
- if (lastDirectCell) {
255
- const sideCells = take(sidePath(lastDirectCell.getCoordinate()), KNIGHT_SIDE_MOVE);
256
-
257
- return uniqBy([...directPath, ...sideCells], (item) => item.getId());
258
- }
259
-
260
- return [];
261
- }
262
- }
1
+ // import { flatten, last, take, uniqBy } from 'lodash';
2
+ //
3
+ // import { GamePlayer } from '../../base';
4
+ // import { GameTableConfig } from '../../base/game-table';
5
+ // import { BoardFigure } from '../base/board-figure';
6
+ // import { BoardTable } from '../base/board-table';
7
+ //
8
+ // import { D2BoardCell } from './d2-board-cell';
9
+ // import { Coordinate } from './types';
10
+ //
11
+ // export interface ID2BoardTable<BF extends BoardFigure> {
12
+ // getUpLeftDiagonal (center: Coordinate): Array<D2BoardCell<BF>>;
13
+ //
14
+ // getUpRightDiagonal (center: Coordinate): Array<D2BoardCell<BF>>;
15
+ //
16
+ // getDownLeftDiagonal (center: Coordinate): Array<D2BoardCell<BF>>;
17
+ //
18
+ // getDownRightDiagonal (center: Coordinate): Array<D2BoardCell<BF>>;
19
+ //
20
+ // getUpVertical (center: Coordinate): Array<D2BoardCell<BF>>;
21
+ //
22
+ // getDownVertical (center: Coordinate): Array<D2BoardCell<BF>>;
23
+ //
24
+ // getLeftHorizontal (center: Coordinate): Array<D2BoardCell<BF>>;
25
+ //
26
+ // getRightHorizontal (center: Coordinate): Array<D2BoardCell<BF>>;
27
+ // }
28
+ //
29
+ // export abstract class D2BoardTable<
30
+ // GP extends GamePlayer,
31
+ // GM,
32
+ // GSR,
33
+ // BF extends BoardFigure,
34
+ // > extends BoardTable<GP, GM, GSR, BF, D2BoardCell<BF>> implements ID2BoardTable<BF> {
35
+ // cells: Array<Array<D2BoardCell<BF>>>;
36
+ // readonly height: number;
37
+ // readonly width: number;
38
+ //
39
+ // protected constructor (config: GameTableConfig<GP>, height: number, width: number) {
40
+ // super(config);
41
+ // this.height = height;
42
+ // this.width = width;
43
+ // this.initCells();
44
+ // }
45
+ //
46
+ // initCells () {
47
+ // const cells: Array<Array<D2BoardCell<BF>>> = [];
48
+ // let id = 0;
49
+ // for (let i = 0; i < this.getHeight(); i += 1) {
50
+ // cells.push([]);
51
+ // for (let j = 0; j < this.getWidth(); j += 1) {
52
+ // cells[i].push(new D2BoardCell(id, j, i));
53
+ // id += 1;
54
+ // }
55
+ // }
56
+ //
57
+ // this.cells = cells;
58
+ // }
59
+ //
60
+ // getHeight () {
61
+ // return this.height;
62
+ // }
63
+ //
64
+ // getWidth () {
65
+ // return this.width;
66
+ // }
67
+ //
68
+ // getCell (id: number): D2BoardCell<BF> | null {
69
+ // return this.getCellsArray().find((item) => item.getId() === id) ?? null;
70
+ // }
71
+ //
72
+ // getCellByCoordinate (y: number, x: number): D2BoardCell<BF> | null {
73
+ // return this.cells[y]?.[x] ?? null;
74
+ // }
75
+ //
76
+ // getCells (): Array<Array<D2BoardCell<BF>>> {
77
+ // return this.cells;
78
+ // }
79
+ //
80
+ // getCellsArray (): Array<D2BoardCell<BF>> {
81
+ // return flatten(this.cells);
82
+ // }
83
+ //
84
+ // getUpLeftDiagonal (center: Coordinate): Array<D2BoardCell<BF>> {
85
+ // const cells: Array<D2BoardCell<BF>> = [];
86
+ //
87
+ // for (let row = center.y, col = center.x; row >= 0 && col >= 0; row -= 1, col -= 1) {
88
+ // const foundCell = this.getCellByCoordinate(row, col);
89
+ // if (foundCell) {
90
+ // cells.push(foundCell);
91
+ // }
92
+ // }
93
+ //
94
+ // return cells;
95
+ // }
96
+ //
97
+ // getUpRightDiagonal (center: Coordinate): Array<D2BoardCell<BF>> {
98
+ // const cells: Array<D2BoardCell<BF>> = [];
99
+ //
100
+ // for (let row = center.y, col = center.x; row >= 0 && col < this.cells.length; row -= 1, col += 1) {
101
+ // const foundCell = this.getCellByCoordinate(row, col);
102
+ // if (foundCell) {
103
+ // cells.push(foundCell);
104
+ // }
105
+ // }
106
+ //
107
+ // return cells;
108
+ // }
109
+ //
110
+ // getDownLeftDiagonal (center: Coordinate) {
111
+ // const cells: Array<D2BoardCell<BF>> = [];
112
+ //
113
+ // for (let row = center.y, col = center.x; row < 8 && col >= 0; row += 1, col -= 1) {
114
+ // const foundCell = this.getCellByCoordinate(row, col);
115
+ // if (foundCell) {
116
+ // cells.push(foundCell);
117
+ // }
118
+ // }
119
+ //
120
+ // return cells;
121
+ // }
122
+ //
123
+ // getDownRightDiagonal (center: Coordinate) {
124
+ // const cells: Array<D2BoardCell<BF>> = [];
125
+ //
126
+ // for (let row = center.y, col = center.x; row < 8 && col < this.cells.length; row += 1, col += 1) {
127
+ // const foundCell = this.getCellByCoordinate(row, col);
128
+ // if (foundCell) {
129
+ // cells.push(foundCell);
130
+ // }
131
+ // }
132
+ //
133
+ // return cells;
134
+ // }
135
+ //
136
+ // getUpVertical (center: Coordinate): Array<D2BoardCell<BF>> {
137
+ // const cells: Array<D2BoardCell<BF>> = [];
138
+ //
139
+ // for (let row = center.y, col = center.x; row >= 0; row -= 1) {
140
+ // const foundCell = this.getCellByCoordinate(row, col);
141
+ // if (foundCell) {
142
+ // cells.push(foundCell);
143
+ // }
144
+ // }
145
+ //
146
+ // return cells;
147
+ // }
148
+ //
149
+ // getDownVertical (center: Coordinate): Array<D2BoardCell<BF>> {
150
+ // const cells: Array<D2BoardCell<BF>> = [];
151
+ //
152
+ // for (let row = center.y, col = center.x; row < this.cells.length; row += 1) {
153
+ // const foundCell = this.getCellByCoordinate(row, col);
154
+ // if (foundCell) {
155
+ // cells.push(foundCell);
156
+ // }
157
+ // }
158
+ //
159
+ // return cells;
160
+ // }
161
+ //
162
+ // getLeftHorizontal (center: Coordinate): Array<D2BoardCell<BF>> {
163
+ // const cells: Array<D2BoardCell<BF>> = [];
164
+ //
165
+ // for (let row = center.y, col = center.x; col >= 0; col -= 1) {
166
+ // const foundCell = this.getCellByCoordinate(row, col);
167
+ // if (foundCell) {
168
+ // cells.push(foundCell);
169
+ // }
170
+ // }
171
+ //
172
+ // return cells;
173
+ // }
174
+ //
175
+ // getRightHorizontal (center: Coordinate): Array<D2BoardCell<BF>> {
176
+ // const cells: Array<D2BoardCell<BF>> = [];
177
+ //
178
+ // for (let row = center.y, col = center.x; col < this.cells.length; col += 1) {
179
+ // const foundCell = this.getCellByCoordinate(row, col);
180
+ // if (foundCell) {
181
+ // cells.push(foundCell);
182
+ // }
183
+ // }
184
+ //
185
+ // return cells;
186
+ // }
187
+ //
188
+ // getEdgedCells (center: Coordinate): Array<D2BoardCell<BF>> {
189
+ // const length = 3;
190
+ // const shift = 2;
191
+ //
192
+ // const first: Coordinate = { x: center.x - 1, y: center.y - 1 };
193
+ // const second: Coordinate = { x: first.x + shift, y: first.y };
194
+ // const third: Coordinate = { x: second.x, y: second.y + shift };
195
+ // const fourth: Coordinate = { x: second.x - shift, y: second.y };
196
+ //
197
+ // const list = [
198
+ // take(this.getRightHorizontal(first), length),
199
+ // take(this.getDownVertical(second), length),
200
+ // take(this.getLeftHorizontal(third), length),
201
+ // take(this.getUpVertical(fourth), length),
202
+ // ];
203
+ //
204
+ // return uniqBy(flatten(list), (item) => item.getId());
205
+ // }
206
+ //
207
+ // getEdgedRectangleCells (list: Array<Coordinate>): Array<D2BoardCell<BF>> {
208
+ // let cells: Array<Array<D2BoardCell<BF>>> = [];
209
+ //
210
+ // list.forEach((center) => {
211
+ // cells.push(this.getEdgedCells(center));
212
+ // });
213
+ //
214
+ // return uniqBy(flatten(cells), (item) => item.getId());
215
+ // }
216
+ //
217
+ // getPistolUpVerticalLeftCells (center: Coordinate): Array<D2BoardCell<BF>> {
218
+ // return this.getPistolCells(this.getUpVertical(center), this.getLeftHorizontal);
219
+ // }
220
+ //
221
+ // getPistolUpVerticalRightCells (center: Coordinate): Array<D2BoardCell<BF>> {
222
+ // return this.getPistolCells(this.getUpVertical(center), this.getRightHorizontal);
223
+ // }
224
+ //
225
+ // getPistolDownVerticalLeftCells (center: Coordinate): Array<D2BoardCell<BF>> {
226
+ // return this.getPistolCells(this.getDownVertical(center), this.getLeftHorizontal);
227
+ // }
228
+ //
229
+ // getPistolDownVerticalRightCells (center: Coordinate): Array<D2BoardCell<BF>> {
230
+ // return this.getPistolCells(this.getDownVertical(center), this.getRightHorizontal);
231
+ // }
232
+ //
233
+ // getPistolLeftHorizontalUpCells (center: Coordinate): Array<D2BoardCell<BF>> {
234
+ // return this.getPistolCells(this.getLeftHorizontal(center), this.getUpVertical);
235
+ // }
236
+ //
237
+ // getPistolLeftHorizontalDownCells (center: Coordinate): Array<D2BoardCell<BF>> {
238
+ // return this.getPistolCells(this.getLeftHorizontal(center), this.getDownVertical);
239
+ // }
240
+ //
241
+ // getPistolRightHorizontalUpCells (center: Coordinate): Array<D2BoardCell<BF>> {
242
+ // return this.getPistolCells(this.getRightHorizontal(center), this.getUpVertical);
243
+ // }
244
+ //
245
+ // getPistolRightHorizontalDownCells (center: Coordinate): Array<D2BoardCell<BF>> {
246
+ // return this.getPistolCells(this.getRightHorizontal(center), this.getDownVertical);
247
+ // }
248
+ //
249
+ // private getPistolCells (directPath: Array<D2BoardCell<BF>>, sidePath: (center: Coordinate) => Array<D2BoardCell<BF>>): Array<D2BoardCell<BF>> {
250
+ // const KNIGHT_UP_MOVE = 3;
251
+ // const KNIGHT_SIDE_MOVE = 2;
252
+ //
253
+ // const lastDirectCell = last(take(directPath, KNIGHT_UP_MOVE));
254
+ // if (lastDirectCell) {
255
+ // const sideCells = take(sidePath(lastDirectCell.getCoordinate()), KNIGHT_SIDE_MOVE);
256
+ //
257
+ // return uniqBy([...directPath, ...sideCells], (item) => item.getId());
258
+ // }
259
+ //
260
+ // return [];
261
+ // }
262
+ // }
@@ -1,4 +1,4 @@
1
- export type Coordinate = {
2
- x: number;
3
- y: number;
4
- }
1
+ // export type Coordinate = {
2
+ // x: number;
3
+ // y: number;
4
+ // }
@@ -1,4 +1,4 @@
1
- import { superShuffle } from '../utils/shuffle';
1
+ import { superShuffle } from '../utils';
2
2
 
3
3
  export class Dice {
4
4
  private readonly sides = [1, 2, 3, 4, 5, 6];
@@ -1,28 +1,28 @@
1
- import { BoardCell } from './base/board-cell';
2
- import { BoardFigure } from './base/board-figure';
3
- import { BoardGameMaster } from './base/board-game-master';
4
- import { BoardPlayer } from './base/board-player';
5
- import { BoardPlayerMove } from './base/board-player-move';
6
- import { BoardTable } from './base/board-table';
7
- import { D1BoardTable } from './d1-board-game/d1-board-table';
8
- import { D2BoardCell } from './d2-board-game/d2-board-cell';
9
- import { D2BoardPatternMoveFigure } from './d2-board-game/d2-board-pattern-move-figure';
10
- import { D2BoardTable } from './d2-board-game/d2-board-table';
11
- import { Dice } from './dice';
12
-
13
- export {
14
- BoardCell,
15
- BoardFigure,
16
- BoardGameMaster,
17
- BoardPlayer,
18
- BoardPlayerMove,
19
- BoardTable,
20
- D1BoardTable,
21
- D2BoardCell,
22
- D2BoardPatternMoveFigure,
23
- D2BoardTable,
24
- Dice,
25
- }
26
-
27
-
28
-
1
+ // import { BoardCell } from './base/board-cell';
2
+ // import { BoardFigure } from './base/board-figure';
3
+ // import { BoardGameMaster } from './base/board-game-master';
4
+ // import { BoardPlayer } from './base/board-player';
5
+ // import { BoardPlayerMove } from './base/board-player-move';
6
+ // import { BoardTable } from './base/board-table';
7
+ // import { D1BoardTable } from './d1-board-game/d1-board-table';
8
+ // import { D2BoardCell } from './d2-board-game/d2-board-cell';
9
+ // import { D2BoardPatternMoveFigure } from './d2-board-game/d2-board-pattern-move-figure';
10
+ // import { D2BoardTable } from './d2-board-game/d2-board-table';
11
+ // import { Dice } from './dice';
12
+ //
13
+ // export {
14
+ // BoardCell,
15
+ // BoardFigure,
16
+ // BoardGameMaster,
17
+ // BoardPlayer,
18
+ // BoardPlayerMove,
19
+ // BoardTable,
20
+ // D1BoardTable,
21
+ // D2BoardCell,
22
+ // D2BoardPatternMoveFigure,
23
+ // D2BoardTable,
24
+ // Dice,
25
+ // }
26
+ //
27
+ //
28
+ //