Created
August 28, 2019 04:34
-
-
Save gmile/3d6e903132d2a2cce7d1d0e89c88a0fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dice | |
attr_accessor :name, :bet | |
attr_reader :balance | |
def initialize(name, balance, bet) | |
@name = name | |
@balance = balance | |
@bet = bet | |
end | |
def self.roll | |
@roll_dice = rand(1..2) | |
end | |
def self.check_bet | |
if @player.bet > @player.balance | |
puts "Enter number from 1 to #{@player.balance}" | |
end | |
end | |
def self.increase_decrease_cash | |
if @roll == @my_number | |
@player.balance += @player.bet | |
else | |
@player.balance -= @player.bet | |
end | |
end | |
end | |
class Game < Dice | |
@player = Dice.new("foo", 600, 0) | |
puts "Hello #{@player.name} your balance is: #{@player.balance}" | |
puts "Bones throwing count times" | |
a = 2 #gets.chomp.to_i | |
while a > 0 do | |
puts "" | |
puts "Enter your bet !!!" | |
# PLAYER BET | |
@player.bet = 300 #gets.chomp.to_i | |
check_bet | |
puts "Respected #{@player.name} your bet is: #{@player.bet}" | |
puts "Now select number 1-2" | |
# BONES ROLL | |
@my_number = roll # gets.chomp.to_i | |
puts "###################" | |
puts "Now we throw bones" | |
@roll = roll | |
puts "Nuber is #{roll}" | |
if @roll == @my_number | |
puts "Your win, you get #{@player.bet}" | |
else | |
puts "You lose #{@player.bet}" | |
end | |
p "$$$$" | |
p @player.balance | |
p "$$$$" | |
a -= 1 | |
increase_decrease_cash | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment