ruby-chess 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1dbaef900f4bf29124a7fd5ed6f7691ed338b360
4
- data.tar.gz: 603583f812ec47bc0c70abbcda4c242fb6d685a9
3
+ metadata.gz: a3a4ce154416026e554379b3a5ca09ca1f7b37ac
4
+ data.tar.gz: 2f4a80afbe2e50cda73bfebbfcf301cbf183bb9c
5
5
  SHA512:
6
- metadata.gz: e11bbcfecd51bf0d34038f9eae59976a10e28bab4637ef033838304fb6574f2d4eb64aaa1658f2756ce4e9e7e7a3684f2969151a573d3c4047f3beb55d58dfef
7
- data.tar.gz: 7fee948640443b881447975a4b05f29a15b5828707ef649678cb4ce6b73ae615e715c5b27cd04c08d30af79a6f23ecceb047ac6224a36ba4af57689564ec17e8
6
+ metadata.gz: 75219a358a760de19304d904ba23861a220afc57e24fb111e9fb92ef866af25ce3590d4e80af11be10f9f1cc633516cb411537c2ccdee40f2741c29a44dd2f9a
7
+ data.tar.gz: 596000ad217c193bb07402d35cefc435c0f4dbfcabaf9032048bafb1e7b88e553d1e37189eb35d147907cfc2f56721fc824817b3a2c694cd3efc6a2691525dfb
@@ -29,8 +29,8 @@ class Board
29
29
  pieces << BlackBishop.new(x,7) << WhiteBishop.new(x,0)
30
30
  end
31
31
 
32
- pieces << BlackQueen.new(4,7) << WhiteQueen.new(3,0)
33
- pieces << BlackKing.new(3,7) << WhiteKing.new(4,0)
32
+ pieces << BlackQueen.new(3,7) << WhiteQueen.new(4,0)
33
+ pieces << BlackKing.new(4,7) << WhiteKing.new(3,0)
34
34
 
35
35
  pieces.each {|piece| place(piece)}
36
36
  end
@@ -3,7 +3,7 @@ class Game
3
3
  attr_reader :turn
4
4
  def initialize
5
5
  @board = Board.new
6
- @kings = {white: @board.at(4,0), black: @board.at(3,7)}
6
+ @king_to_check = {black: @board.at(3,0), white: @board.at(4,7)}
7
7
  @moves = []
8
8
  @turn = :white
9
9
  @over = false
@@ -52,13 +52,12 @@ class Game
52
52
  },
53
53
  capture: at_destination,
54
54
  }
55
+ switch_turn
55
56
 
56
- if @kings[@turn].checked?(@board)
57
+ if @king_to_check[@turn].checked?(@board)
57
58
  undo
58
59
  raise Game::IllegalMove, "#{@turn}'s king is in check!"
59
60
  end
60
-
61
- switch_turn
62
61
  end
63
62
 
64
63
  def resign
@@ -14,10 +14,10 @@ class GameTest < Minitest::Test
14
14
 
15
15
  def white_in_check
16
16
  game = Game.new
17
- game.play([3,1],[3,3])
18
- game.play([4,6],[4,5])
19
- game.play([1,1],[1,3])
20
- game.play([5,7],[1,3])
17
+ game.play([4,1],[4,3])
18
+ game.play([3,6],[3,5])
19
+ game.play([6,1],[6,3])
20
+ game.play([2,7],[6,3])
21
21
  game
22
22
  end
23
23
 
@@ -46,10 +46,10 @@ class GameTest < Minitest::Test
46
46
 
47
47
  def test_cannot_move_into_check
48
48
  game = white_in_check
49
- game.play([2,1],[2,2])
49
+ game.play([5,1],[5,2])
50
50
  game.play([6,6],[6,5])
51
51
  assert_raises(Game::IllegalMove) do
52
- game.play([2,2],[2,3])
52
+ game.play([5,2],[5,3])
53
53
  end
54
54
  end
55
55
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-chess
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - jphager2