snakes_and_ladders 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/snakes_and_ladders/game.rb +15 -3
- data/lib/snakes_and_ladders/version.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7eaed87f2482a11baebded8cfa8de59e3076328
|
4
|
+
data.tar.gz: 5760373b5278e7483c1397110bccedbc6384312a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a60cbaa3fbc0d9e3d1cf5f6e7c0dc662eb57f0eabf5ea88b1be976ca00e06fb5387616f7e3755cd477243e0ba6583011c6464d18509a8588c167ec79342f9741
|
7
|
+
data.tar.gz: 3b71bcb261b47259e27be87ceaa25986c85cdcba82035f92184d4e7fc26625dd5365b12e032737974279130dfd04655cde7600f3de8bf2460760283e15bf492c
|
@@ -19,7 +19,7 @@ module SnakesAndLadders
|
|
19
19
|
|
20
20
|
puts "#{player} rolls #{player.last_roll}!"
|
21
21
|
|
22
|
-
if board.move(player,
|
22
|
+
if board.move(player, player_position, player_destination_after_last_roll)
|
23
23
|
self.winner = player if won?
|
24
24
|
else
|
25
25
|
self.winner = player if will_win?
|
@@ -43,16 +43,28 @@ module SnakesAndLadders
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def won?
|
46
|
-
|
46
|
+
player_position.equal?(board_size)
|
47
47
|
end
|
48
48
|
|
49
49
|
def will_win?
|
50
|
-
|
50
|
+
player_destination_after_last_roll >= board_size
|
51
51
|
end
|
52
52
|
|
53
53
|
def winner=(player)
|
54
54
|
@winner = player
|
55
55
|
puts "Game over! #{winner} wins in #{winner.turns} turns. Congratulations!"
|
56
56
|
end
|
57
|
+
|
58
|
+
def player_position
|
59
|
+
player.position
|
60
|
+
end
|
61
|
+
|
62
|
+
def player_destination_after_last_roll
|
63
|
+
player.destination_after_last_roll
|
64
|
+
end
|
65
|
+
|
66
|
+
def board_size
|
67
|
+
board.size
|
68
|
+
end
|
57
69
|
end
|
58
70
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snakes_and_ladders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mohamad El-Husseini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|