Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Role
- def initialize(type, job)
- @type = type
- @job = job
- end
- def to_s
- "#{@type}: #{@job}"
- end
- end
- class Fight
- def initialize(player1, player2)
- round = 1
- puts "Each round you attack first. Then your opponent attacks you."
- puts "#{player2} Enemy Starting Round", "#{player1} You Starting Round"
- puts "NOW FIGHT!"
- while player2['hp'] >= 1
- player2['hp'] = player2['hp'] - (player1['atk'] - player2['def']).abs
- player1['hp'] = player1['hp'] - (player2['atk'] - player1['def']).abs
- puts "#{player2} Enemy Round #{round.to_s}", "#{player1} You Round #{round.to_s}"
- round = round + 1
- end
- end
- end
- warstats = { 'hp' => 14, 'atk' => 9, 'def' => 8 }
- arcstats = { 'hp' => 10, 'atk' => 5, 'def' => 4 }
- wizstats = { 'hp' => 4, 'atk' => 15, 'def' => 3 }
- b1 = Role.new("Rock", "Warrior")
- puts b1
- b2 = Role.new("Scissors", "Archer")
- puts b2
- b3 = Role.new("Paper", "Wizard")
- puts b3
- puts "What are you?"
- chosenclass = gets
- chosenclass.chomp!
- if chosenclass == "Warrior"
- player1 = warstats
- player2 = arcstats
- Fight.new(player1, player2)
- puts "You beat the Archer, but any Wizard would beat you!"
- puts "Fight over."
- puts "HP: #{warstats['hp']} ATK: #{warstats['atk']} DEF: #{warstats['def']}"
- else
- if chosenclass == "Archer"
- puts "Archers get defensive bonus vs. Wizards."
- arcstats['def'] = 14
- player1 = arcstats
- player2 = wizstats
- Fight.new(player1, player2)
- puts "You beat the Wizard, but any Warrior would beat you!"
- puts "Fight over."
- puts "HP: #{arcstats['hp']} ATK: #{arcstats['atk']} DEF: #{arcstats['def']}"
- else
- if chosenclass == "Wizard"
- puts "You cast a defensive barrier!"
- wizstats['def'] = 8
- player1 = wizstats
- player2 = warstats
- Fight.new(player1, player2)
- puts "You beat the Warrior, but any Archer would beat you!"
- puts "Fight over."
- puts "HP: #{wizstats['hp']} ATK: #{wizstats['atk']} DEF: #{wizstats['def']}"
- else
- puts "That isn't a class!"
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement