SHOW:
|
|
- or go back to the newest paste.
| 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) |
| 16 | + | def initialize(player1, player2) |
| 17 | - | arcstats[0] = arcstats[0] - (warstats[1] - arcstats[3]) |
| 17 | + | round = 1 |
| 18 | - | warstats[0] = warstats[0] - (arcstats[1] - warstats[3]) |
| 18 | + | puts "Each round you attack first. Then your opponent attacks you." |
| 19 | - | return player1 |
| 19 | + | puts "#{player2} Enemy Starting Round", "#{player1} You Starting Round"
|
| 20 | - | return player2 |
| 20 | + | puts "NOW FIGHT!" |
| 21 | while player2['hp'] >= 1 | |
| 22 | player2['hp'] = player2['hp'] - (player1['atk'] - player2['def']).abs | |
| 23 | player1['hp'] = player1['hp'] - (player2['atk'] - player1['def']).abs | |
| 24 | puts "#{player2} Enemy Round #{round.to_s}", "#{player1} You Round #{round.to_s}"
| |
| 25 | - | warstats = { 'hp' => 10, 'atk' => 5, 'def' => 6 }
|
| 25 | + | round = round + 1 |
| 26 | - | arcstats = { 'hp' => 9 , 'atk' => 7, 'def' => 4 }
|
| 26 | + | end |
| 27 | - | wizstats = { 'hp' => 4 , 'atk' => 11, 'def' => 3 }
|
| 27 | + | |
| 28 | ||
| 29 | end | |
| 30 | ||
| 31 | warstats = { 'hp' => 14, 'atk' => 9, 'def' => 8 }
| |
| 32 | arcstats = { 'hp' => 10, 'atk' => 5, 'def' => 4 }
| |
| 33 | wizstats = { 'hp' => 4, 'atk' => 15, 'def' => 3 }
| |
| 34 | ||
| 35 | b1 = Role.new("Rock", "Warrior")
| |
| 36 | puts b1 | |
| 37 | b2 = Role.new("Scissors", "Archer")
| |
| 38 | puts b2 | |
| 39 | b3 = Role.new("Paper", "Wizard")
| |
| 40 | - | player1=warstats |
| 40 | + | |
| 41 | - | player2=arcstats |
| 41 | + | |
| 42 | - | round1 = Fight.new(player1, player2) |
| 42 | + | |
| 43 | - | puts round1 |
| 43 | + | |
| 44 | - | puts "You beat Archer, but Wizard beats you!" |
| 44 | + | |
| 45 | if chosenclass == "Warrior" | |
| 46 | player1 = warstats | |
| 47 | player2 = arcstats | |
| 48 | Fight.new(player1, player2) | |
| 49 | ||
| 50 | - | puts "You beat Wizard, but Warrior beats you!" |
| 50 | + | |
| 51 | puts "You beat the Archer, but any Wizard would beat you!" | |
| 52 | puts "Fight over." | |
| 53 | puts "HP: #{warstats['hp']} ATK: #{warstats['atk']} DEF: #{warstats['def']}"
| |
| 54 | ||
| 55 | else | |
| 56 | - | puts "You beat Warrior, but Archer beats you!" |
| 56 | + | |
| 57 | puts "Archers get defensive bonus vs. Wizards." | |
| 58 | arcstats['def'] = 14 | |
| 59 | player1 = arcstats | |
| 60 | player2 = wizstats | |
| 61 | Fight.new(player1, player2) | |
| 62 | ||
| 63 | puts "You beat the Wizard, but any Warrior would beat you!" | |
| 64 | puts "Fight over." | |
| 65 | puts "HP: #{arcstats['hp']} ATK: #{arcstats['atk']} DEF: #{arcstats['def']}"
| |
| 66 | ||
| 67 | else | |
| 68 | if chosenclass == "Wizard" | |
| 69 | puts "You cast a defensive barrier!" | |
| 70 | wizstats['def'] = 8 | |
| 71 | player1 = wizstats | |
| 72 | player2 = warstats | |
| 73 | Fight.new(player1, player2) | |
| 74 | ||
| 75 | puts "You beat the Warrior, but any Archer would beat you!" | |
| 76 | puts "Fight over." | |
| 77 | puts "HP: #{wizstats['hp']} ATK: #{wizstats['atk']} DEF: #{wizstats['def']}"
| |
| 78 | ||
| 79 | else | |
| 80 | puts "That isn't a class!" | |
| 81 | end | |
| 82 | end | |
| 83 | end |