chess_game 0.0.11
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 +7 -0
- data/.rspec +1 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +58 -0
- data/README.md +24 -0
- data/Rakefile +3 -0
- data/bin/chess +3 -0
- data/chess-0.0.11.gem +0 -0
- data/chess.gemspec +29 -0
- data/game.dat +0 -0
- data/lib/chess/bishop.rb +28 -0
- data/lib/chess/board.rb +170 -0
- data/lib/chess/game.rb +73 -0
- data/lib/chess/king.rb +101 -0
- data/lib/chess/knight.rb +28 -0
- data/lib/chess/move_helper.rb +185 -0
- data/lib/chess/pawn.rb +58 -0
- data/lib/chess/piece.rb +134 -0
- data/lib/chess/player.rb +36 -0
- data/lib/chess/queen.rb +30 -0
- data/lib/chess/rook.rb +30 -0
- data/lib/chess/version.rb +3 -0
- data/lib/chess.rb +71 -0
- data/save/test +0 -0
- data/spec/bishop_spec.rb +32 -0
- data/spec/board_spec.rb +206 -0
- data/spec/game_spec.rb +32 -0
- data/spec/king_spec.rb +167 -0
- data/spec/knight_spec.rb +57 -0
- data/spec/pawn_spec.rb +144 -0
- data/spec/piece_spec.rb +43 -0
- data/spec/player_spec.rb +47 -0
- data/spec/queen_spec.rb +35 -0
- data/spec/rook_spec.rb +31 -0
- data/spec/spec_helper.rb +3 -0
- metadata +147 -0
data/spec/queen_spec.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative '../lib/chess/queen.rb'
|
2
|
+
|
3
|
+
describe Queen do
|
4
|
+
|
5
|
+
it { should be_a_kind_of(Piece) }
|
6
|
+
it { should respond_to :color }
|
7
|
+
it { should respond_to :location }
|
8
|
+
|
9
|
+
it "should know what its character is" do
|
10
|
+
@queen = Queen.new("White", "A1")
|
11
|
+
expect(@queen.icon).to eq("\u2655")
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "valid moves" do
|
15
|
+
before { @queen = Queen.new("white", "D4") }
|
16
|
+
before { @board = Board.new }
|
17
|
+
|
18
|
+
it "should be able to move vertically to any position" do
|
19
|
+
expect(@queen.valid_move?("D3", @board)).to be_truthy
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should be able to move horizontally to any position" do
|
23
|
+
expect(@queen.valid_move?("H4", @board)).to be_truthy
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should be able to move diagonally" do
|
27
|
+
expect(@queen.valid_move?("C3", @board)).to be_truthy
|
28
|
+
expect(@queen.valid_move?("E3", @board)).to be_truthy
|
29
|
+
expect(@queen.valid_move?("E5", @board)).to be_truthy
|
30
|
+
expect(@queen.valid_move?("E3", @board)).to be_truthy
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
data/spec/rook_spec.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative '../lib/chess/rook.rb'
|
2
|
+
|
3
|
+
describe Rook do
|
4
|
+
|
5
|
+
it { should be_a_kind_of(Piece) }
|
6
|
+
it { should respond_to :color }
|
7
|
+
it { should respond_to :location }
|
8
|
+
|
9
|
+
it "should know what its character is" do
|
10
|
+
@rook = Rook.new("White", "A1")
|
11
|
+
expect(@rook.icon).to eq("\u2656")
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "valid moves" do
|
15
|
+
before { @rook = Rook.new("white", "A5") }
|
16
|
+
before { @board = Board.new }
|
17
|
+
|
18
|
+
it "should be able to move vertically to any position" do
|
19
|
+
expect(@rook.valid_move?("A3", @board)).to be_truthy
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should be able to move horizontally to any position" do
|
23
|
+
expect(@rook.valid_move?("H5", @board)).to be_truthy
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should not be able to move diagonally" do
|
27
|
+
expect(@rook.valid_move?("B3", @board)).to be_falsey
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chess_game
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.11
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Benjamin Pearce
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 10.3.2
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 10.3.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: colorize
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.7.3
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.7.3
|
69
|
+
description: Contain libraries for setting up and playing games of chess, making
|
70
|
+
and validating moves, and evaluating victory conditionspec.
|
71
|
+
email:
|
72
|
+
- hawk.git@bcpearce.com
|
73
|
+
executables:
|
74
|
+
- chess
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- .rspec
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/chess
|
84
|
+
- chess-0.0.11.gem
|
85
|
+
- chess.gemspec
|
86
|
+
- game.dat
|
87
|
+
- lib/chess.rb
|
88
|
+
- lib/chess/bishop.rb
|
89
|
+
- lib/chess/board.rb
|
90
|
+
- lib/chess/game.rb
|
91
|
+
- lib/chess/king.rb
|
92
|
+
- lib/chess/knight.rb
|
93
|
+
- lib/chess/move_helper.rb
|
94
|
+
- lib/chess/pawn.rb
|
95
|
+
- lib/chess/piece.rb
|
96
|
+
- lib/chess/player.rb
|
97
|
+
- lib/chess/queen.rb
|
98
|
+
- lib/chess/rook.rb
|
99
|
+
- lib/chess/version.rb
|
100
|
+
- save/test
|
101
|
+
- spec/bishop_spec.rb
|
102
|
+
- spec/board_spec.rb
|
103
|
+
- spec/game_spec.rb
|
104
|
+
- spec/king_spec.rb
|
105
|
+
- spec/knight_spec.rb
|
106
|
+
- spec/pawn_spec.rb
|
107
|
+
- spec/piece_spec.rb
|
108
|
+
- spec/player_spec.rb
|
109
|
+
- spec/queen_spec.rb
|
110
|
+
- spec/rook_spec.rb
|
111
|
+
- spec/spec_helper.rb
|
112
|
+
homepage: https://github.com/bcpearce/command-line-chess
|
113
|
+
licenses:
|
114
|
+
- MIT
|
115
|
+
metadata: {}
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - '>='
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
requirements: []
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 2.4.3
|
133
|
+
signing_key:
|
134
|
+
specification_version: 4
|
135
|
+
summary: Play chess using the command line.
|
136
|
+
test_files:
|
137
|
+
- spec/bishop_spec.rb
|
138
|
+
- spec/board_spec.rb
|
139
|
+
- spec/game_spec.rb
|
140
|
+
- spec/king_spec.rb
|
141
|
+
- spec/knight_spec.rb
|
142
|
+
- spec/pawn_spec.rb
|
143
|
+
- spec/piece_spec.rb
|
144
|
+
- spec/player_spec.rb
|
145
|
+
- spec/queen_spec.rb
|
146
|
+
- spec/rook_spec.rb
|
147
|
+
- spec/spec_helper.rb
|