Advertisement
Guest User

rpsfight

a guest
May 22nd, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. class Role
  2.  
  3. def initialize(type, job)
  4. @type = type
  5. @job = job
  6. end
  7.  
  8. def to_s
  9. "#{@type}: #{@job}"
  10. end
  11.  
  12. end
  13.  
  14. class Fight
  15.  
  16. def initialize(warstats, arcstats)
  17. arcstats[0] = arcstats[0] - (warstats[1] - arcstats[3])
  18. warstats[0] = warstats[0] - (arcstats[1] - warstats[3])
  19. return player1
  20. return player2
  21. end
  22.  
  23. end
  24.  
  25. warstats = { 'hp' => 10, 'atk' => 5, 'def' => 6 }
  26. arcstats = { 'hp' => 9 , 'atk' => 7, 'def' => 4 }
  27. wizstats = { 'hp' => 4 , 'atk' => 11, 'def' => 3 }
  28.  
  29. b1 = Role.new("Rock", "Warrior")
  30. puts b1
  31. b2 = Role.new("Scissors", "Archer")
  32. puts b2
  33. b3 = Role.new("Paper", "Wizard")
  34. puts b3
  35. puts "What are you?"
  36. chosenclass = gets
  37. chosenclass.chomp!
  38.  
  39. if chosenclass == "Warrior"
  40. player1=warstats
  41. player2=arcstats
  42. round1 = Fight.new(player1, player2)
  43. puts round1
  44. puts "You beat Archer, but Wizard beats you!"
  45. puts "HP: #{warstats['hp']} ATK: #{warstats['atk']} DEF: #{warstats['def']}"
  46.  
  47. else
  48. if chosenclass == "Archer"
  49.  
  50. puts "You beat Wizard, but Warrior beats you!"
  51. puts "HP: #{arcstats['hp']} ATK: #{arcstats['atk']} DEF: #{arcstats['def']}"
  52.  
  53. else
  54. if chosenclass == "Wizard"
  55.  
  56. puts "You beat Warrior, but Archer beats you!"
  57. puts "HP: #{wizstats['hp']} ATK: #{wizstats['atk']} DEF: #{wizstats['def']}"
  58.  
  59. else
  60. puts "That isn't a class!"
  61. end
  62. end
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement