crapsgame 1.0.0.pre → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/crapsgame.rb +59 -2
- metadata +4 -4
data/lib/crapsgame.rb
CHANGED
@@ -1,3 +1,60 @@
|
|
1
|
-
|
1
|
+
require "#{File.dirname(__FILE__)}/crapsgame/dice"
|
2
|
+
require "#{File.dirname(__FILE__)}/crapsgame/player"
|
3
|
+
|
2
4
|
class Crapsgame
|
3
|
-
|
5
|
+
include Dice
|
6
|
+
|
7
|
+
attr_accessor :currentdice, :dicetotal, :point, :player
|
8
|
+
|
9
|
+
def initialize(player = nil)
|
10
|
+
@player = (player == nil ? Player.new : player)
|
11
|
+
end
|
12
|
+
|
13
|
+
def diceroll
|
14
|
+
@currentdice = roll_dice
|
15
|
+
@dicetotal = roll_total(@currentdice)
|
16
|
+
puts("The roll was: #{@dicetotal} (#{@currentdice[0]} and #{@currentdice[1]})")
|
17
|
+
end
|
18
|
+
|
19
|
+
def handle_roll
|
20
|
+
case @dicetotal
|
21
|
+
when 4, 5, 6, 8, 9, 10
|
22
|
+
puts("Point Roll")
|
23
|
+
if(@point == @dicetotal) then
|
24
|
+
@point = 0
|
25
|
+
puts("You Won!")
|
26
|
+
elsif @point == 0 then
|
27
|
+
@point = @dicetotal
|
28
|
+
end
|
29
|
+
when 2, 3, 12
|
30
|
+
puts("Craps")
|
31
|
+
when 7
|
32
|
+
puts("Seven")
|
33
|
+
if @point != 0 then
|
34
|
+
puts("You Lose")
|
35
|
+
@point = 0
|
36
|
+
end
|
37
|
+
when 11
|
38
|
+
puts("Eleven")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def roll
|
43
|
+
diceroll
|
44
|
+
@player.payout(@dicetotal, point?)
|
45
|
+
handle_roll
|
46
|
+
@player.setbets(@dicetotal, point?)
|
47
|
+
displaygamedata
|
48
|
+
@player.displaystatus
|
49
|
+
end
|
50
|
+
|
51
|
+
def displaygamedata
|
52
|
+
puts("The point is set to #{@point}")
|
53
|
+
end
|
54
|
+
|
55
|
+
def point?
|
56
|
+
@point != 0
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crapsgame
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Steven Curtiss
|
@@ -33,9 +33,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
33
33
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
34
|
none: false
|
35
35
|
requirements:
|
36
|
-
- - ! '
|
36
|
+
- - ! '>='
|
37
37
|
- !ruby/object:Gem::Version
|
38
|
-
version:
|
38
|
+
version: '0'
|
39
39
|
requirements: []
|
40
40
|
rubyforge_project:
|
41
41
|
rubygems_version: 1.8.24
|