crapsgame 1.0.2 → 1.0.3
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.
- data/bin/crapsgame +8 -4
- data/lib/crapsgame/player.rb +16 -8
- metadata +1 -1
data/bin/crapsgame
CHANGED
@@ -7,7 +7,7 @@ puts
|
|
7
7
|
puts("Starting Player Strategy")
|
8
8
|
p.displayplayersettings
|
9
9
|
endingcash = (p.cash + p.standardbetvalue) * 2
|
10
|
-
puts
|
10
|
+
puts 'Quiting cash value=$' + p.red(endingcash)
|
11
11
|
puts
|
12
12
|
puts("Would you like to customize your playing strategy? [Yn]")
|
13
13
|
choice = gets.chomp
|
@@ -32,11 +32,15 @@ end
|
|
32
32
|
|
33
33
|
c = Crapsgame.new(p)
|
34
34
|
|
35
|
-
puts("Press enter to roll the dice or
|
36
|
-
|
35
|
+
puts("Press enter to roll the dice, q to quit, or a to run to the end")
|
36
|
+
play = nil
|
37
|
+
while(play != "q" && (c.player.cash >= c.player.standardbetvalue || c.player.allbetsvalue != 0) && c.player.cash < endingcash)
|
37
38
|
c.roll
|
38
39
|
c.displaygamedata
|
39
40
|
c.player.displaystatus
|
41
|
+
if play != 'a' then
|
42
|
+
play = gets.chomp
|
43
|
+
end
|
40
44
|
end
|
41
45
|
|
42
|
-
puts
|
46
|
+
puts 'You finish the game with $' + p.green(c.player.cash)
|
data/lib/crapsgame/player.rb
CHANGED
@@ -87,18 +87,26 @@ class Player
|
|
87
87
|
@comebet = 0
|
88
88
|
end
|
89
89
|
|
90
|
+
def colorize(text, color_code)
|
91
|
+
"#{color_code}#{text}\033[0m"
|
92
|
+
end
|
93
|
+
|
94
|
+
def red(text); colorize(text, "\033[31m"); end
|
95
|
+
def green(text); colorize(text, "\033[32m"); end
|
96
|
+
def blue(text); colorize(text, "\033[34m"); end
|
97
|
+
|
90
98
|
def displayplayersettings
|
91
|
-
puts
|
92
|
-
puts
|
93
|
-
puts
|
94
|
-
puts
|
99
|
+
puts 'Starting Cash=$' + green(@cash+allbetsvalue)
|
100
|
+
puts 'Standard Betting Value=$' + blue(@standardbetvalue)
|
101
|
+
puts 'Odds Betting Value=$' + blue(@oddsbetvalue)
|
102
|
+
puts 'Maximum Number of Points to Bet On=' + blue(@maxpointstobet)
|
95
103
|
end
|
96
104
|
|
97
105
|
def displaystatus
|
98
|
-
puts(
|
99
|
-
puts
|
100
|
-
puts
|
101
|
-
puts
|
106
|
+
puts 'Cash=$' + green(@cash)
|
107
|
+
puts 'Bets Total=$' + red(allbetsvalue)
|
108
|
+
puts "Passline=$#{@passbet}"
|
109
|
+
puts "Comeline=$#{@comebet}"
|
102
110
|
@numberbets.each {|k,v| puts("Number #{k.to_s} = $#{v[0].to_s} Odds = $#{v[1].to_s}")}
|
103
111
|
end
|
104
112
|
end
|