khetai 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/ext/khetai/khetai_lib.c +30 -28
- data/lib/khetai/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0de4779baa3060126c239bcb22e4ed4cff09168f223d282b4653ee0b48a49c0
|
4
|
+
data.tar.gz: add3d7364b84a82e2268b2ae2e17ee3169a63e1191f7bbfefe036ffb9b727a64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adeeb8e3bd8605661ad1a3a7a58cdcae7728bafc6c1fb329f4ba602600e103c25adcfbfbdbfc29390a28272df04d4f15a92ea84c55034c5b1ed77e7b0d103249
|
7
|
+
data.tar.gz: 184800f1ddfc7db6d7366a29e611e8edf8149177423ce9236ee685b6ed7aa6c3b6ecb1faffd520d6da6a68041daee91c34b00d5800cefd63f1a23e50b7f9437e
|
data/Gemfile.lock
CHANGED
data/ext/khetai/khetai_lib.c
CHANGED
@@ -211,31 +211,32 @@ void make_move(Move move) {
|
|
211
211
|
if (is_piece(board[end]))
|
212
212
|
hash ^= keys[board[end]][end];
|
213
213
|
|
214
|
-
Square
|
215
|
-
|
216
|
-
board[
|
214
|
+
Square starting_square = board[start];
|
215
|
+
Square ending_square = board[end];
|
216
|
+
board[start] = ending_square;
|
217
|
+
board[end] = starting_square;
|
218
|
+
|
217
219
|
// add starting piece to end location
|
218
|
-
hash ^= keys[
|
220
|
+
hash ^= keys[starting_square][end];
|
219
221
|
|
220
|
-
|
221
|
-
if (is_piece(
|
222
|
-
|
222
|
+
enum Player moving_player = get_owner(starting_square);
|
223
|
+
if (!is_piece(ending_square)) {
|
224
|
+
update_piece_tracker(moving_player, start, end, false);
|
225
|
+
} else {
|
226
|
+
// add ending piece to start location if swapping
|
227
|
+
hash ^= keys[ending_square][start];
|
223
228
|
|
224
|
-
enum Player other_player = get_owner(
|
225
|
-
if (get_owner(
|
229
|
+
enum Player other_player = get_owner(ending_square);
|
230
|
+
if (get_owner(starting_square) == other_player)
|
226
231
|
update_piece_tracker(other_player, end, start, true);
|
227
232
|
else {
|
228
|
-
update_piece_tracker(
|
233
|
+
update_piece_tracker(moving_player, start, end, false);
|
229
234
|
update_piece_tracker(other_player, end, start, false);
|
230
235
|
}
|
231
|
-
|
232
|
-
} else {
|
233
|
-
enum Player moving_player = get_owner(moving_piece);
|
234
|
-
update_piece_tracker(moving_player, start, end, false);
|
235
236
|
}
|
236
237
|
|
237
|
-
if (get_piece(
|
238
|
-
pharaoh_loc[get_owner(
|
238
|
+
if (get_piece(starting_square) == PHARAOH)
|
239
|
+
pharaoh_loc[get_owner(starting_square)] = end;
|
239
240
|
}
|
240
241
|
|
241
242
|
undo_moves[undo_index] = new_move(end, start, -rotation);
|
@@ -311,26 +312,27 @@ void undo_move() {
|
|
311
312
|
if (rotation != 0) {
|
312
313
|
board[start] = rotate(board[start], rotation);
|
313
314
|
} else {
|
314
|
-
Square
|
315
|
-
|
316
|
-
board[
|
315
|
+
Square starting_square = board[start];
|
316
|
+
Square ending_square = board[end];
|
317
|
+
board[start] = ending_square;
|
318
|
+
board[end] = starting_square;
|
317
319
|
|
318
|
-
|
319
|
-
|
320
|
+
enum Player moving_player = get_owner(starting_square);
|
321
|
+
if (ending_square == 0) {
|
322
|
+
update_piece_tracker(moving_player, start, end, false);
|
323
|
+
} else {
|
324
|
+
enum Player other_player = get_owner(ending_square);
|
320
325
|
|
321
|
-
if (get_owner(
|
326
|
+
if (get_owner(starting_square) == other_player)
|
322
327
|
update_piece_tracker(other_player, end, start, true);
|
323
328
|
else {
|
324
|
-
update_piece_tracker(
|
329
|
+
update_piece_tracker(moving_player, start, end, false);
|
325
330
|
update_piece_tracker(other_player, end, start, false);
|
326
331
|
}
|
327
|
-
} else {
|
328
|
-
enum Player moving_player = get_owner(moving_piece);
|
329
|
-
update_piece_tracker(moving_player, start, end, false);
|
330
332
|
}
|
331
333
|
|
332
|
-
if (get_piece(
|
333
|
-
pharaoh_loc[get_owner(
|
334
|
+
if (get_piece(starting_square) == PHARAOH)
|
335
|
+
pharaoh_loc[get_owner(starting_square)] = end;
|
334
336
|
}
|
335
337
|
checkmate = false;
|
336
338
|
}
|
data/lib/khetai/version.rb
CHANGED