Created
December 10, 2010 04:24
-
-
Save jefftrudeau/735777 to your computer and use it in GitHub Desktop.
Jeff Trudeau's "Engine Yard Lucky 13 Content Entry"
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
// Copyright Jeff Trudeau | |
require 'json' | |
require 'net/http' | |
require 'uri' | |
puts 'Welcome, a bet of -1 will end the game.' | |
earnings = 0 | |
while (true) | |
puts 'Your earnings are '.concat(earnings.to_s).concat('. Please place your bet.') | |
bet = gets.to_f | |
if bet > -1 | |
earnings -= bet | |
winner = JSON.parse(Net::HTTP.get(URI.parse('http://roulette.engineyard.com/')))['winning_number'] | |
if winner == '13' | |
earnings += (winnings = bet * 35) | |
puts 'Lucky you, you won '.concat((winnings).to_s) | |
else | |
puts 'Sorry, the winning number was '.concat(winner) | |
end | |
else | |
break | |
end | |
end | |
puts 'Your total earnings are '.concat(earnings.to_s).concat('. Thanks for playing!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment