crapsgame 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/crapsgame +36 -6
- data/lib/crapsgame/player.rb +9 -2
- data/lib/crapsgame.rb +0 -4
- metadata +1 -1
data/bin/crapsgame
CHANGED
@@ -2,11 +2,41 @@
|
|
2
2
|
|
3
3
|
require 'crapsgame.rb'
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
p = Player.new
|
6
|
+
puts
|
7
|
+
puts("Starting Player Strategy")
|
8
|
+
p.displayplayersettings
|
9
|
+
endingcash = (p.cash + p.standardbetvalue) * 2
|
10
|
+
puts("Quiting cash value=$#{endingcash}")
|
11
|
+
puts
|
12
|
+
puts("Would you like to customize your playing strategy? [Yn]")
|
13
|
+
choice = gets.chomp
|
14
|
+
if choice == "Y" then
|
15
|
+
puts("Set starting cash:")
|
16
|
+
p.cash = gets.chomp.to_i
|
17
|
+
puts("Set standard bet value:")
|
18
|
+
p.standardbetvalue = gets.chomp.to_i
|
19
|
+
puts("Set odds bet value:")
|
20
|
+
p.oddsbetvalue = gets.chomp.to_i
|
21
|
+
puts("Set maximum number of points to bet on:")
|
22
|
+
p.maxpointstobet = gets.chomp.to_i
|
23
|
+
puts("Set maximum amount of cash before quiting:")
|
24
|
+
endingcash = gets.chomp.to_i
|
25
|
+
p.cash -= p.standardbetvalue
|
26
|
+
p.passbet = p.standardbetvalue
|
27
|
+
puts
|
28
|
+
puts("Updated Player Strategy")
|
29
|
+
p.displayplayersettings
|
30
|
+
puts("Quiting cash value=$#{endingcash}")
|
31
|
+
end
|
32
|
+
|
33
|
+
c = Crapsgame.new(p)
|
7
34
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
35
|
+
puts("Press enter to roll the dice or q to quit")
|
36
|
+
while(gets.chomp != "q" && c.player.cash >= c.player.standardbetvalue && c.player.cash < endingcash)
|
37
|
+
c.roll
|
38
|
+
c.displaygamedata
|
39
|
+
c.player.displaystatus
|
12
40
|
end
|
41
|
+
|
42
|
+
puts("You finish the game with $#{c.player.cash}")
|
data/lib/crapsgame/player.rb
CHANGED
@@ -41,7 +41,7 @@ class Player
|
|
41
41
|
def setbets(roll_value, point_on)
|
42
42
|
if POINTS.index(roll_value) then
|
43
43
|
@numberbets[roll_value][0] = @passbet + @comebet
|
44
|
-
if cashforbet?(@oddsbetvalue) then
|
44
|
+
if cashforbet?(@oddsbetvalue) and @numberbets[roll_value][0] > 0 then
|
45
45
|
@numberbets[roll_value][1] = @oddsbetvalue
|
46
46
|
@cash -= @oddsbetvalue
|
47
47
|
end
|
@@ -52,7 +52,7 @@ class Player
|
|
52
52
|
@passbet = @standardbetvalue
|
53
53
|
@cash -= @passbet
|
54
54
|
end
|
55
|
-
if point_on and @comebet == 0 and cashforbet?(@standardbetvalue) and numberofpoints
|
55
|
+
if point_on and @comebet == 0 and cashforbet?(@standardbetvalue) and numberofpoints < @maxpointstobet then
|
56
56
|
@comebet = @standardbetvalue
|
57
57
|
@cash -= @comebet
|
58
58
|
end
|
@@ -87,6 +87,13 @@ class Player
|
|
87
87
|
@comebet = 0
|
88
88
|
end
|
89
89
|
|
90
|
+
def displayplayersettings
|
91
|
+
puts("Starting Cash=$#{@cash+allbetsvalue}")
|
92
|
+
puts("Standard Betting Value=$#{@standardbetvalue}")
|
93
|
+
puts("Odds Betting Value=$#{@oddsbetvalue}")
|
94
|
+
puts("Maximum Number of Points to Bet On=#{@maxpointstobet}")
|
95
|
+
end
|
96
|
+
|
90
97
|
def displaystatus
|
91
98
|
puts("Cash=$#{@cash}")
|
92
99
|
puts("Bets Total=$#{allbetsvalue}")
|
data/lib/crapsgame.rb
CHANGED
@@ -35,8 +35,6 @@ class Crapsgame
|
|
35
35
|
@player.payout(@dicetotal, point_on?)
|
36
36
|
handle_roll
|
37
37
|
@player.setbets(@dicetotal, point_on?)
|
38
|
-
#displaygamedata
|
39
|
-
#@player.displaystatus
|
40
38
|
end
|
41
39
|
|
42
40
|
def displaygamedata
|
@@ -52,5 +50,3 @@ class Crapsgame
|
|
52
50
|
@point != 0
|
53
51
|
end
|
54
52
|
end
|
55
|
-
|
56
|
-
|