just_chess 1.0.1 → 1.0.2
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.
- checksums.yaml +4 -4
- data/lib/just_chess/pieces/pawn.rb +14 -1
- data/lib/just_chess/pieces/piece.rb +13 -0
- data/lib/just_chess/square_set.rb +1 -1
- data/lib/just_chess/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc6e83199ec2a0e3fec25dbf43cfe35a226211e1
|
4
|
+
data.tar.gz: fc925097a8a0e287d370d496553ab659513df0ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b128f5e5531be440e25bf2954d6ae822f337df7ecc72fda82080a26e24905541ba71ddecc028fff401171cc5832a20df8241ac04208fd65ab1d0402aae91f262
|
7
|
+
data.tar.gz: 6b29991fca0965a59bdce7059986f163e01cc0f63e0bf75635d6882c7c2db928811d2e5179271d407ea11ecf4118d5210a88879f9f3ddf82e75c52b91aa54586
|
@@ -58,7 +58,20 @@ module JustChess
|
|
58
58
|
#
|
59
59
|
# @return [SquareSet]
|
60
60
|
def capture_squares(square, game_state)
|
61
|
-
|
61
|
+
potential_capture_squares(square, game_state).occupied_by_opponent(player_number)
|
62
|
+
end
|
63
|
+
|
64
|
+
# All the squares that the piece could potentially capture. (i.e. even if a piece wasn't on the square.)
|
65
|
+
#
|
66
|
+
# @param [Square] square
|
67
|
+
# the origin square.
|
68
|
+
#
|
69
|
+
# @param [GameState] game_state
|
70
|
+
# the current game state.
|
71
|
+
#
|
72
|
+
# @return [SquareSet]
|
73
|
+
def potential_capture_squares(square, game_state)
|
74
|
+
game_state.squares.in_range(square, 1).in_direction(square, forwards_direction).diagonal(square)
|
62
75
|
end
|
63
76
|
|
64
77
|
# The Square that a pawn can capture en passant.
|
@@ -104,6 +104,19 @@ module JustChess
|
|
104
104
|
destinations(square, game_state)
|
105
105
|
end
|
106
106
|
|
107
|
+
# All the squares that the piece could potential capture. (e.g. if a piece was there)
|
108
|
+
#
|
109
|
+
# @param [Square] square
|
110
|
+
# the origin square.
|
111
|
+
#
|
112
|
+
# @param [GameState] game_state
|
113
|
+
# the current game state.
|
114
|
+
#
|
115
|
+
# @return [SquareSet]
|
116
|
+
def potential_capture_squares(square, game_state)
|
117
|
+
capture_squares(square, game_state)
|
118
|
+
end
|
119
|
+
|
107
120
|
# returns a serialized piece as a hash
|
108
121
|
#
|
109
122
|
# @return [Hash]
|
@@ -148,7 +148,7 @@ module JustChess
|
|
148
148
|
# @return [SquareSet]
|
149
149
|
def threatened_by(player_number, game_state)
|
150
150
|
_squares = occupied_by_player(player_number).map do |s|
|
151
|
-
s.piece.
|
151
|
+
s.piece.potential_capture_squares(s, game_state).squares
|
152
152
|
end.flatten.uniq
|
153
153
|
|
154
154
|
self.class.new(squares: _squares)
|
data/lib/just_chess/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: just_chess
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Humphreys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|