Skip to content

Instantly share code, notes, and snippets.

@epaulet
Created April 12, 2016 01:15
Show Gist options
  • Save epaulet/62cb891388e9e5429abfe581e9c25f50 to your computer and use it in GitHub Desktop.
Save epaulet/62cb891388e9e5429abfe581e9c25f50 to your computer and use it in GitHub Desktop.
Simple Sales Game
DISMISSIVE_STATEMENT = 'Hmm... not quite sure... (Customer is feeling dismissive, sell harder!)'
ANGRY_STATEMENT = "This just doesn't seem like a good fit. (Customer is feeling uncomfortable, soothe them!)"
SWEET_SPOT_STATEMENT = "Tell me more... (The customer feels calm and comfortable, keep them that way!)"
interest = 0
mood = 50
MAX_MOOD = 100
MIN_MOOD = 0
puts 'Hello, I would like to know more about Rainforest!'
loop do
puts "Customer Interest: #{interest}%"
puts '1: Sell Aggressively (increase interest, may make customer uncomfortable)'
puts '2: Soothe (slightly decrease interest, calms customer)'
puts ''
input = gets.chomp.to_i
puts ''
case input
when 1
mood += rand(35)
interest += rand(30)
when 2
mood -= rand(35)
interest -= rand(30)
end
interest = [interest, 0].max
if interest >= 100
puts "SOLD!"
exit 3
end
if mood < 0
puts "I'll pass"
puts "Customer walks off..."
exit 1
elsif mood > 100
puts "I said no and that's final!"
puts "Customer walks off..."
exit 2
elsif mood.between?(0, 33)
puts DISMISSIVE_STATEMENT
elsif mood.between?(34, 76)
puts SWEET_SPOT_STATEMENT
elsif mood.between?(77, 100)
puts ANGRY_STATEMENT
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment