chessmate 0.8.2 → 0.8.3

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: 5eff4c50ea2e728782b66659f9445403fa7b6259146f8080eeef792bc6205a98
4
- data.tar.gz: 64d8742b853658b7ea366d0649b0c858a4bc32dfd56bba11bfd1e09d8008c380
3
+ metadata.gz: eaacf6aa4d8e0dd9a6b40f01fb136c1fbe50c201fff256d062965dd0e37cea10
4
+ data.tar.gz: fd4f655e91cbc7fa4c47df3b986ce5e77eb918de29e8bbe9f7c59f093b28d5a1
5
5
  SHA512:
6
- metadata.gz: 7de212e19fbda503f67b9ed871fa20639839901f2f35c927f29f245a42f4f23316028452710e952279c47651dfd381d5c3a9160bf0fbbe64aa240412ecd99a4e
7
- data.tar.gz: 6f189d1a5e27e04f5f3e4b343830b6095ae807848ae2bec455c2d887b8c5a0e33016492b70de2d135d83bdf63937b8fe8f7b440eda82a6783b14040e2d79b273
6
+ metadata.gz: cb07a9daa65eeafd1158aebcdcd457700d157cd226b5382c8f9a8a794e6397dced03c4223bbaa6bb42b27a1762f078efec21b640ad09c5eb51b07c2f08006bba
7
+ data.tar.gz: 3d1e5177494c9a450ffdc87731551f010035aa24a1f1cec37091345ac9ceddbc13bab8cb1ce4561a94ae1a7dd8e2e4d25e86f2131c4a87fe73a4bc8b527e1981
File without changes
data/Gemfile CHANGED
File without changes
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chessmate (0.8.1)
4
+ chessmate (0.8.3)
5
5
  deep_dup (~> 0)
6
6
 
7
7
  GEM
@@ -58,4 +58,4 @@ DEPENDENCIES
58
58
  rubocop (= 0.75.1)
59
59
 
60
60
  BUNDLED WITH
61
- 2.0.2
61
+ 2.1.4
data/LICENSE CHANGED
File without changes
data/README.md CHANGED
@@ -31,13 +31,13 @@ Click [here](http://chessmate-demo.herokuapp.com/) to play with a Rails app runn
31
31
  ## Usage
32
32
  Simply add ChessMate to your Gemfile:
33
33
 
34
- ```
34
+ ```ruby
35
35
  gem 'chessmate'
36
36
  ```
37
37
 
38
38
  and then you can require it in a model, controller, etc.
39
39
 
40
- ```
40
+ ```ruby
41
41
  require 'chessmate'
42
42
  ```
43
43
 
@@ -45,13 +45,13 @@ From there, you are free to utilize all the functions and features of ChessMate!
45
45
 
46
46
  ## Building a new game and playing
47
47
 
48
- ```
48
+ ```ruby
49
49
  game = ChessMate.new
50
50
  ```
51
51
 
52
52
  Moving pieces works based on chess notation: for example, a common first move is `e2` to `e4`. ChessMate accepts these squares as arguments to the `move` method, so you don't need to specify a piece type like in normal chess notation. To make this move in ChessMate:
53
53
 
54
- ```
54
+ ```ruby
55
55
  game.move('e2', 'e4')
56
56
  ```
57
57
 
@@ -59,9 +59,9 @@ If a move is invalid, `ChessMate.move` will return `false`, and the board and ga
59
59
 
60
60
  Other functions you might call:
61
61
 
62
- ```
62
+ ```ruby
63
63
  game.promote?(square) # Check if a square is capable of pawn promotion
64
- game.promote!(square, piece) # Promote a promotable pawn, accepts 'rook'/'knight'/'bishop'/'queen'
64
+ game.promote!(square, piece) # Promote a promotable pawn, accepts 'rook'/'knight'/'bishop'/'queen'
65
65
  game.in_check? # Determine if either color is currently in check
66
66
  game.checkmate?(color) # Determine if the game is over, accepts 'W'/'B'
67
67
  game.draw?(color) # Same as checkmate, for draw
@@ -74,7 +74,7 @@ With ChessMate, it's very easy to build your own custom games. Below is a list o
74
74
 
75
75
  For instance, for a custom board, on turn 10, with the white king in check:
76
76
 
77
- ```
77
+ ```ruby
78
78
  custom_board = [
79
79
  [nil, nil, nil, nil, 'BK', nil, nil, nil],
80
80
  [nil, nil, nil, nil, 'BQ', nil, nil, nil],
@@ -94,7 +94,7 @@ game = ChessMate.new(board: custom_board, turn: turn, in_check: in_check)
94
94
  ChessMate can build a game with those parameters!
95
95
 
96
96
  Here is a list of all the defaults:
97
- ```
97
+ ```ruby
98
98
  board: [
99
99
  %w[BR BN BB BQ BK BB BN BR],
100
100
  %w[BP BP BP BP BP BP BP BP],
@@ -128,5 +128,3 @@ castling: {
128
128
 
129
129
  ## Contributing
130
130
  ChessMate is open to contributions! If you have a feature request, a bug, or a suggestion, please open an issue! Please note that a review is required and passing TravisCI build before your PR can be merged with master.
131
-
132
- Currently looking to expand ChessMate features by allowing chess notation logging as well as better documentation!
File without changes
@@ -73,7 +73,7 @@ class ChessLogger
73
73
  end
74
74
 
75
75
  def check_or_mate
76
- game = ChessMate.new(board: @board, ignore_logging: true)
76
+ game = ChessMate.new(board: @board, ignore_logging: true, allow_out_of_turn: true)
77
77
  encoded_orig = NotationParser.encode_notation(@orig)
78
78
  encoded_dest = NotationParser.encode_notation(@dest)
79
79
  opposite_color_letter = @piece_color == 'W' ? 'B' : 'W'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1457,6 +1457,40 @@ describe ChessMate do
1457
1457
  chess.promote!([0, 0], 'queen')
1458
1458
  expect(chess.move_history[-1]).to eql('a8=(Q)')
1459
1459
  end
1460
+
1461
+ context 'check moves' do
1462
+ it 'logs checks against black' do
1463
+ board = [
1464
+ [nil, nil, nil, 'WQ', nil, nil, nil, nil],
1465
+ [nil, nil, nil, nil, nil, nil, nil, nil],
1466
+ [nil, nil, nil, nil, nil, nil, nil, nil],
1467
+ [nil, nil, nil, nil, nil, nil, nil, nil],
1468
+ [nil, nil, nil, nil, nil, nil, nil, nil],
1469
+ ['WN', nil, nil, nil, nil, nil, nil, nil],
1470
+ [nil, nil, nil, 'BP', nil, 'BP', nil, nil],
1471
+ [nil, nil, nil, 'BR', 'BK', 'BR', nil, nil]
1472
+ ]
1473
+ chess = ChessMate.new(board: board)
1474
+ chess.move('a3', 'c2')
1475
+ expect(chess.move_history.last).to eql('Nc2+')
1476
+ end
1477
+
1478
+ it 'logs checks against white' do
1479
+ board = [
1480
+ [nil, nil, nil, 'BQ', nil, nil, nil, nil],
1481
+ [nil, nil, nil, nil, nil, nil, nil, nil],
1482
+ [nil, nil, nil, nil, nil, nil, nil, nil],
1483
+ [nil, nil, nil, nil, nil, nil, nil, nil],
1484
+ [nil, nil, nil, nil, nil, nil, nil, nil],
1485
+ ['BN', nil, nil, nil, nil, nil, nil, nil],
1486
+ [nil, nil, nil, 'WP', nil, 'WP', nil, nil],
1487
+ [nil, nil, nil, 'WR', 'WK', 'WR', nil, nil]
1488
+ ]
1489
+ chess = ChessMate.new(board: board)
1490
+ chess.move('a3', 'c2')
1491
+ expect(chess.move_history.last).to eql('Nc2+')
1492
+ end
1493
+ end
1460
1494
  end
1461
1495
  end
1462
1496
 
@@ -50,7 +50,7 @@ describe 'ChessLogger' do
50
50
  ['WR', nil, nil, nil, 'WK', nil, nil, 'WR']
51
51
  ]
52
52
 
53
- @check_board = [
53
+ @white_check_board = [
54
54
  [nil, nil, nil, 'BQ', nil, nil, nil, nil],
55
55
  [nil, nil, nil, nil, nil, nil, nil, nil],
56
56
  [nil, nil, nil, nil, nil, nil, nil, nil],
@@ -60,6 +60,17 @@ describe 'ChessLogger' do
60
60
  [nil, nil, nil, 'WP', nil, 'WP', nil, nil],
61
61
  [nil, nil, nil, 'WR', 'WK', 'WR', nil, nil]
62
62
  ]
63
+
64
+ @black_check_board = [
65
+ [nil, nil, nil, 'WQ', nil, nil, nil, nil],
66
+ [nil, nil, nil, nil, nil, nil, nil, nil],
67
+ [nil, nil, nil, nil, nil, nil, nil, nil],
68
+ [nil, nil, nil, nil, nil, nil, nil, nil],
69
+ [nil, nil, nil, nil, nil, nil, nil, nil],
70
+ ['WN', nil, nil, nil, nil, nil, nil, nil],
71
+ [nil, nil, nil, 'BP', nil, 'BP', nil, nil],
72
+ [nil, nil, nil, 'BR', 'BK', 'BR', nil, nil]
73
+ ]
63
74
  end
64
75
 
65
76
  context 'pawn moves' do
@@ -169,14 +180,28 @@ describe 'ChessLogger' do
169
180
  end
170
181
 
171
182
  context 'game status indications' do
172
- it 'should log check' do
173
- logger = ChessLogger.new([5, 0], [6, 2], @check_board)
174
- expect(logger.log_move).to eql('Nc2+')
183
+ context 'for white' do
184
+ it 'should log check' do
185
+ logger = ChessLogger.new([5, 0], [6, 2], @white_check_board)
186
+ expect(logger.log_move).to eql('Nc2+')
187
+ end
188
+
189
+ it 'should log checkmate' do
190
+ logger = ChessLogger.new([0, 3], [0, 4], @white_check_board)
191
+ expect(logger.log_move).to eql('Qe8#')
192
+ end
175
193
  end
176
194
 
177
- it 'should log checkmate' do
178
- logger = ChessLogger.new([0, 3], [0, 4], @check_board)
179
- expect(logger.log_move).to eql('Qe8#')
195
+ context 'for black' do
196
+ it 'should log check' do
197
+ logger = ChessLogger.new([5, 0], [6, 2], @black_check_board)
198
+ expect(logger.log_move).to eql('Nc2+')
199
+ end
200
+
201
+ it 'should log checkmate' do
202
+ logger = ChessLogger.new([0, 3], [0, 4], @black_check_board)
203
+ expect(logger.log_move).to eql('Qe8#')
204
+ end
180
205
  end
181
206
  end
182
207
  end
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chessmate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Porter
@@ -121,15 +121,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: 2.5.8
125
125
  required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  requirements:
127
127
  - - ">="
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  requirements: []
131
- rubyforge_project:
132
- rubygems_version: 2.7.6.2
131
+ rubygems_version: 3.0.3
133
132
  signing_key:
134
133
  specification_version: 4
135
134
  summary: Chess for Rails