just_chess 1.0.8 → 1.0.9

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
  SHA256:
3
- metadata.gz: fd9b8430fe1b330224a23bf84568883bf58d1266339db0feddb18e251f12f5bc
4
- data.tar.gz: 65ecd066dc1df89fd55331836bd19a118830ec88658ed6f45aca9bbc82ee0f13
3
+ metadata.gz: 513e0e3d88555f73b703cf696f3af05c52015b5be36ce85493493f538009fffd
4
+ data.tar.gz: d5af65bc28abc00dd7cffb897fb20d6b310b8ffcab0c036cc6eaec92409d6c83
5
5
  SHA512:
6
- metadata.gz: 95155deb95f2ec9a3a5a63ea854e2c48aaa22a52a4f37e03259f7e57502c0e3dd97488b02b96d87dec3014f1dcda426f5a5a1d59d703b76b610e0eece210c073
7
- data.tar.gz: 3b9db2efd203a5e29e0925dc5a420f3f8e7a0b1a7aa4c3bb80987172bc86f70db2717701f980deaf759c54759a63eddba750fac596c58dee715c4af9436bcf13
6
+ metadata.gz: 8fb19fcb38947cf44382d3954a9226da4ee43c0f93b32d0db987ec45cd88159671e7cfec29818b102408ccf0a3bf8e50354c1a350da2e9e4e4f09ea5228547cf
7
+ data.tar.gz: b0db033c28bb159a35b6f521a335745de02932f36ab2ca60cd2ba37212d8c9144924cf5edb70a8f393b6571986b0f7ba00f9f268e9922dea93305189a0d0a7d7
@@ -27,5 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "rake", "~> 13.0.1"
28
28
  spec.add_development_dependency "minitest", "~> 5.14.0"
29
29
 
30
- spec.add_runtime_dependency "board_game_grid", "~> 0.1.4"
30
+ spec.add_runtime_dependency "board_game_grid", "~> 0.1.6"
31
31
  end
@@ -1,33 +1,21 @@
1
+ require 'board_game_grid'
2
+
1
3
  module JustChess
2
4
 
3
5
  # = Piece
4
6
  #
5
7
  # A piece that can move on a chess board
6
- class Piece
8
+ class Piece < BoardGameGrid::Piece
7
9
  def initialize(id: , player_number: , type: nil, has_moved: false)
8
10
  @id = id
9
11
  @player_number = player_number
10
12
  @has_moved = has_moved
11
13
  end
12
14
 
13
- # @return [Fixnum] the identifier of the piece.
14
- attr_reader :id
15
-
16
- # @return [Fixnum] the owner of the piece.
17
- attr_reader :player_number
18
-
19
15
  # @return [Boolean] determines if the piece has moved.
20
16
  attr_reader :has_moved
21
-
22
17
  alias_method :has_moved?, :has_moved
23
18
 
24
- # The opposing player number
25
- #
26
- # @return [Fixnum]
27
- def opponent
28
- player_number == 1 ? 2 : 1
29
- end
30
-
31
19
  # mark the piece as moved
32
20
  #
33
21
  # @return [TrueClass]
@@ -35,88 +23,13 @@ module JustChess
35
23
  @has_moved = true
36
24
  end
37
25
 
38
- # The stringified identifier of the piece type.
26
+ # Has the piece not moved yet?
39
27
  #
40
- # @return [String]
28
+ # @return [TrueClass, FalseClass]
41
29
  def has_not_moved?
42
30
  !has_moved?
43
31
  end
44
32
 
45
- # The stringified identifier of the piece type.
46
- #
47
- # @return [String]
48
- def type
49
- self.class.to_s.split('::').last.downcase
50
- end
51
-
52
- # Can the piece move from a square, to a square, given the game state?
53
- #
54
- # @param [Square] from
55
- # the origin square.
56
- #
57
- # @param [Square] to
58
- # the destination square.
59
- #
60
- # @param [GameState] game_state
61
- # the current game state.
62
- #
63
- # @return [Boolean]
64
- def can_move?(from, to, game_state)
65
- destinations(from, game_state).include?(to)
66
- end
67
-
68
- # All the squares that the piece can move to and/or capture.
69
- #
70
- # @param [Square] square
71
- # the origin square.
72
- #
73
- # @param [GameState] game_state
74
- # the current game state.
75
- #
76
- # @return [SquareSet]
77
- def destinations(square, game_state)
78
- []
79
- end
80
-
81
- # All the squares that the piece can move to.
82
- #
83
- # @param [Square] square
84
- # the origin square.
85
- #
86
- # @param [GameState] game_state
87
- # the current game state.
88
- #
89
- # @return [SquareSet]
90
- def move_squares(square, game_state)
91
- destinations(square, game_state)
92
- end
93
-
94
- # All the squares that the piece can capture.
95
- #
96
- # @param [Square] square
97
- # the origin square.
98
- #
99
- # @param [GameState] game_state
100
- # the current game state.
101
- #
102
- # @return [SquareSet]
103
- def capture_squares(square, game_state)
104
- destinations(square, game_state)
105
- end
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
-
120
33
  # returns a serialized piece as a hash
121
34
  #
122
35
  # @return [Hash]
@@ -129,4 +42,4 @@ module JustChess
129
42
  }
130
43
  end
131
44
  end
132
- end
45
+ end
@@ -1,4 +1,4 @@
1
1
  module JustChess
2
2
  # :nodoc:
3
- VERSION = "1.0.8"
3
+ VERSION = "1.0.9"
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.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Humphreys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-10 00:00:00.000000000 Z
11
+ date: 2020-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.1.4
61
+ version: 0.1.6
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.1.4
68
+ version: 0.1.6
69
69
  description: Provides a representation of a chess game complete with rules enforcement
70
70
  and serialisation.
71
71
  email: