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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b33f8bdbd1afcaf77894dc28dbbc8df377c8545
4
- data.tar.gz: 7a33706dbf1b54929e9d0699d66756f4a95cfcc2
3
+ metadata.gz: dc6e83199ec2a0e3fec25dbf43cfe35a226211e1
4
+ data.tar.gz: fc925097a8a0e287d370d496553ab659513df0ef
5
5
  SHA512:
6
- metadata.gz: b2546134da2266b3e2fd713e7cc98dd88fc5f562fa8933242fdae0cf667792f29c89a594b5a3518998adf9b162feb0ef3dd99fdb88545bd59ec81734ce0f684f
7
- data.tar.gz: 16eee1788926db454d8d3c26e39abd40b3707066f4f647cbd72f748287a475fd3e74a30cdeaf2fea4a31bff4eaf27c8808e9a6e2cdabb58b47f3bb3e11e0a5b2
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
- game_state.squares.in_range(square, 1).in_direction(square, forwards_direction).diagonal(square).occupied_by_opponent(player_number)
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.capture_squares(s, game_state).squares
151
+ s.piece.potential_capture_squares(s, game_state).squares
152
152
  end.flatten.uniq
153
153
 
154
154
  self.class.new(squares: _squares)
@@ -1,4 +1,4 @@
1
1
  module JustChess
2
2
  # :nodoc:
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
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.1
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-20 00:00:00.000000000 Z
11
+ date: 2018-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler