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.
Files changed (3) hide show
  1. data/bin/crapsgame +8 -4
  2. data/lib/crapsgame/player.rb +16 -8
  3. 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("Quiting cash value=$#{endingcash}")
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 q to quit")
36
- while(gets.chomp != "q" && c.player.cash >= c.player.standardbetvalue && c.player.cash < endingcash)
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("You finish the game with $#{c.player.cash}")
46
+ puts 'You finish the game with $' + p.green(c.player.cash)
@@ -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("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}")
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("Cash=$#{@cash}")
99
- puts("Bets Total=$#{allbetsvalue}")
100
- puts("Passline=$#{@passbet}")
101
- puts("Comeline=$#{@comebet}")
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crapsgame
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: