Last active
December 27, 2015 04:09
-
-
Save bramdemoor/7264589 to your computer and use it in GitHub Desktop.
Ruby Russian Roulette
This file contains hidden or 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
require 'colorize' | |
class Revolver | |
def initialize(chamberCount) | |
@chambers = Array.new(chamberCount, false) | |
@chambers[0] = true | |
end | |
def spin | |
return @chambers.sample | |
end | |
end | |
system('clear') | |
print "Russian Roulette\nKeep pressing enter to play!" | |
gun = Revolver.new(6) | |
alive = true | |
begin | |
gets | |
puts "Spinning..." | |
alive = !gun.spin | |
puts "You're winning! Keep playing!" if alive | |
end while alive | |
puts "BOOM HEADSHOT".red | |
puts "Game over!" |
A good way to "Kill" time and still look like you're doing something. 😏
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample output: