chess_vwong 0.0.1 → 0.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 +4 -4
- data/.DS_Store +0 -0
- data/README.md +27 -14
- data/Rakefile +3 -3
- data/bin/chess_vwong +10 -10
- data/chess_vwong-0.0.1.gem +0 -0
- data/chess_vwong.gemspec +12 -12
- data/example/example_game.rb +17 -17
- data/lib/chess_vwong.rb +13 -17
- data/lib/chess_vwong/bishop.rb +6 -9
- data/lib/chess_vwong/board.rb +151 -89
- data/lib/chess_vwong/game.rb +21 -16
- data/lib/chess_vwong/king.rb +4 -6
- data/lib/chess_vwong/knight.rb +4 -6
- data/lib/chess_vwong/node.rb +1 -1
- data/lib/chess_vwong/pawn.rb +23 -22
- data/lib/chess_vwong/piece.rb +13 -15
- data/lib/chess_vwong/player.rb +2 -2
- data/lib/chess_vwong/preload.rb +49 -48
- data/lib/chess_vwong/queen.rb +10 -13
- data/lib/chess_vwong/rook.rb +6 -9
- data/lib/chess_vwong/version.rb +1 -1
- data/spec/bishop_spec.rb +24 -27
- data/spec/board_spec.rb +227 -147
- data/spec/game_spec.rb +13 -15
- data/spec/king_spec.rb +24 -28
- data/spec/knight_spec.rb +31 -33
- data/spec/node_spec.rb +10 -11
- data/spec/pawn_spec.rb +54 -56
- data/spec/piece_spec.rb +23 -23
- data/spec/player_spec.rb +11 -13
- data/spec/queen_spec.rb +24 -27
- data/spec/rook_spec.rb +24 -27
- data/spec/spec_helper.rb +1 -1
- metadata +5 -3
data/spec/player_spec.rb
CHANGED
@@ -1,21 +1,19 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
module ChessVwong
|
4
|
-
describe Player do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
player
|
9
|
-
expect(player.color).to eq "w"
|
4
|
+
describe Player do
|
5
|
+
context '#color' do
|
6
|
+
it 'returns color' do
|
7
|
+
player = Player.new('Van Damme', 'w')
|
8
|
+
expect(player.color).to eq 'w'
|
10
9
|
end
|
11
10
|
end
|
12
11
|
|
13
|
-
context
|
14
|
-
it
|
15
|
-
player = Player.new(
|
16
|
-
expect(player.name).to eq
|
12
|
+
context '#name' do
|
13
|
+
it 'returns name' do
|
14
|
+
player = Player.new('Van Damme', 'w')
|
15
|
+
expect(player.name).to eq 'Van Damme'
|
17
16
|
end
|
18
17
|
end
|
19
|
-
|
20
18
|
end
|
21
|
-
end
|
19
|
+
end
|
data/spec/queen_spec.rb
CHANGED
@@ -1,50 +1,47 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
module ChessVwong
|
4
|
-
describe Queen do
|
5
|
-
let (:current_space) { [1,1]}
|
6
|
-
let (:queen) { Queen.new(current_space,
|
7
|
-
context
|
8
|
-
it
|
9
|
-
expect(queen.color).to eq
|
4
|
+
describe Queen do
|
5
|
+
let (:current_space) { [1, 1] }
|
6
|
+
let (:queen) { Queen.new(current_space, 'w') }
|
7
|
+
context '#initialize' do
|
8
|
+
it 'should return Piece attributes: color' do
|
9
|
+
expect(queen.color).to eq 'w'
|
10
10
|
end
|
11
11
|
|
12
|
-
it
|
12
|
+
it 'should return Piece attributes: current_space' do
|
13
13
|
expect(queen.current_space).to eq current_space
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
context
|
18
|
-
it
|
19
|
-
expect(queen.character).to eq "\u{
|
17
|
+
context '#character' do
|
18
|
+
it 'should return a white queen character' do
|
19
|
+
expect(queen.character).to eq "\u{2655}"
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
23
|
-
queen_2 = Queen.new(current_space,
|
24
|
-
expect(queen_2.character).to eq "\u{
|
25
|
-
end
|
26
|
-
end
|
22
|
+
it 'should return a black queen character' do
|
23
|
+
queen_2 = Queen.new(current_space, 'b')
|
24
|
+
expect(queen_2.character).to eq "\u{265B}"
|
25
|
+
end
|
26
|
+
end
|
27
27
|
|
28
|
-
context
|
29
|
-
it
|
28
|
+
context '#generate_neighbours' do
|
29
|
+
it 'should return only 21 neighbour when [1,1]' do
|
30
30
|
queen.generate_neighbours(current_space)
|
31
31
|
expect(queen.neighbours.count).to eq 21
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
35
|
-
current_space = [8,8]
|
34
|
+
it 'should return only 21 neighbour when [8,8]' do
|
35
|
+
current_space = [8, 8]
|
36
36
|
queen.generate_neighbours(current_space)
|
37
37
|
expect(queen.neighbours.count).to eq 21
|
38
38
|
end
|
39
39
|
|
40
|
-
it
|
41
|
-
current_space = [4,4]
|
40
|
+
it 'should return only 14 neighbour when in the middle' do
|
41
|
+
current_space = [4, 4]
|
42
42
|
queen.generate_neighbours(current_space)
|
43
43
|
expect(queen.neighbours.count).to eq 27
|
44
|
-
end
|
45
|
-
|
44
|
+
end
|
46
45
|
end
|
47
|
-
|
48
|
-
|
49
46
|
end
|
50
|
-
end
|
47
|
+
end
|
data/spec/rook_spec.rb
CHANGED
@@ -1,50 +1,47 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
module ChessVwong
|
4
|
-
describe Rook do
|
5
|
-
let (:current_space) { [1,1]}
|
6
|
-
let (:rook) { Rook.new(current_space,
|
7
|
-
context
|
8
|
-
it
|
9
|
-
expect(rook.color).to eq
|
4
|
+
describe Rook do
|
5
|
+
let (:current_space) { [1, 1] }
|
6
|
+
let (:rook) { Rook.new(current_space, 'w') }
|
7
|
+
context '#initialize' do
|
8
|
+
it 'should return Piece attributes: color' do
|
9
|
+
expect(rook.color).to eq 'w'
|
10
10
|
end
|
11
11
|
|
12
|
-
it
|
12
|
+
it 'should return Piece attributes: current_space' do
|
13
13
|
expect(rook.current_space).to eq current_space
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
context
|
18
|
-
it
|
19
|
-
expect(rook.character).to eq "\u{
|
17
|
+
context '#character' do
|
18
|
+
it 'should return a white rook character' do
|
19
|
+
expect(rook.character).to eq "\u{2656}"
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
23
|
-
rook_2 = Rook.new(current_space,
|
24
|
-
expect(rook_2.character).to eq "\u{
|
25
|
-
end
|
26
|
-
end
|
22
|
+
it 'should return a black rook character' do
|
23
|
+
rook_2 = Rook.new(current_space, 'b')
|
24
|
+
expect(rook_2.character).to eq "\u{265C}"
|
25
|
+
end
|
26
|
+
end
|
27
27
|
|
28
|
-
context
|
29
|
-
it
|
28
|
+
context '#generate_neighbours' do
|
29
|
+
it 'should return only 14 neighbour when [1,1]' do
|
30
30
|
rook.generate_neighbours(current_space)
|
31
31
|
expect(rook.neighbours.count).to eq 14
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
35
|
-
current_space = [8,8]
|
34
|
+
it 'should return only 14 neighbour when [8,8]' do
|
35
|
+
current_space = [8, 8]
|
36
36
|
rook.generate_neighbours(current_space)
|
37
37
|
expect(rook.neighbours.count).to eq 14
|
38
38
|
end
|
39
39
|
|
40
|
-
it
|
41
|
-
current_space = [4,4]
|
40
|
+
it 'should return only 14 neighbour when in the middle' do
|
41
|
+
current_space = [4, 4]
|
42
42
|
rook.generate_neighbours(current_space)
|
43
43
|
expect(rook.neighbours.count).to eq 14
|
44
|
-
end
|
45
|
-
|
44
|
+
end
|
46
45
|
end
|
47
|
-
|
48
|
-
|
49
46
|
end
|
50
|
-
end
|
47
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative '../lib/chess_vwong.rb'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chess_vwong
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Wong
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -60,12 +60,14 @@ executables:
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
+
- ".DS_Store"
|
63
64
|
- ".gitignore"
|
64
65
|
- Gemfile
|
65
66
|
- LICENSE.txt
|
66
67
|
- README.md
|
67
68
|
- Rakefile
|
68
69
|
- bin/chess_vwong
|
70
|
+
- chess_vwong-0.0.1.gem
|
69
71
|
- chess_vwong.gemspec
|
70
72
|
- example/example_game.rb
|
71
73
|
- lib/chess_vwong.rb
|
@@ -94,7 +96,7 @@ files:
|
|
94
96
|
- spec/queen_spec.rb
|
95
97
|
- spec/rook_spec.rb
|
96
98
|
- spec/spec_helper.rb
|
97
|
-
homepage:
|
99
|
+
homepage: https://github.com/wingyu/chess_vwong
|
98
100
|
licenses:
|
99
101
|
- MIT
|
100
102
|
metadata: {}
|