module GBOGH
Public Class Methods
start(nop)
click to toggle source
# File lib/gobig_gohome.rb, line 4 def GBOGH.start(nop) nop.to_i p1score = 0 p2score = 0 p3score = 0 p4score = 0 p1 = true p2 = true p3 = true p4 = true if nop == 3 p4 = false p4score = "This player is not playing." end if nop == 2 p3 = false p3score = "This player is not playing." p4 = false p4score = "This player is not playing either." end if nop == 1 p2 = false p2score = "This player is not playing." p3 = false p3score = "This player is not playing either." p4 = false p4score = "This player is not playing, just like P2 and P3! This must be a one player game." end t = 0 puts "Go Big or Go Home is a game about betting high enough, but not too high.\nEach round, of which there are six, ten dice are rolled. You will be told the highest number.\nYou then bid a number from zero to three.\nThe dice are added up, then multiplied by your bid and added to your score." 6.times do v1 = rand(-10..10) v2 = rand(-10..10) v3 = rand(-10..10) v4 = rand(-10..10) v5 = rand(-10..10) v6 = rand(-10..10) v7 = rand(-10..10) v8 = rand(-10..10) v9 = rand(-10..10) v10 = rand(-10..10) max = [v1, v2, v3, v4, v5, v6, v7, v8, v9, v10].max sum = v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8 + v9 + v10 puts "The highest die (from -10 to 10), is #{max}." if p1 == true print "P1 bid: " p1bid = Integer(gets.chomp) if p1bid > 3 p1bid = 3 end if p1bid < 0 p1bid = 0 end p1score = p1score + (p1bid*sum) end if p2 == true print "P2 bid: " p2bid = Integer(gets.chomp) if p2bid > 3 p2bid = 3 end if p2bid < 0 p2bid = 0 end p2score = p2score + (p2bid*sum) end if p3 == true print "P3 bid: " p3bid = Integer(gets.chomp) if p3bid > 3 p3bid = 3 end if p3bid < 0 p3bid = 0 end p3score = p3score + (p3bid*sum) end if p4 == true print "P4 bid: " p4bid = Integer(gets.chomp) if p4bid > 3 p4bid = 3 end if p4bid < 0 p4bid = 0 end p4score = p4score + (p4bid*sum) end puts "The sum was #{sum}." t = t + 1 if t < 6 puts "P1 Score: #{p1score}\nP2 Score: #{p2score}\nP3 Score: #{p3score}\nP4 Score: #{p4score}" else puts "P1 Final Score: #{p1score}\nP2 Final Score: #{p2score}\nP3 Final Score: #{p3score}\nP4 Final Score: #{p4score}" end end end