Skip to content

Instantly share code, notes, and snippets.

@jefftrudeau
Created December 10, 2010 04:24
Show Gist options
  • Save jefftrudeau/735777 to your computer and use it in GitHub Desktop.
Save jefftrudeau/735777 to your computer and use it in GitHub Desktop.
Jeff Trudeau's "Engine Yard Lucky 13 Content Entry"
// 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