Module: CombatView
- Defined in:
- lib/lotrd/view/combatView.rb
Class Method Summary collapse
- .defeat ⇒ Object
- .escape ⇒ Object
- .escapeFail ⇒ Object
- .escapeSuccess ⇒ Object
- .mobMiss ⇒ Object
- .mobStart(playerHP, mobHP) ⇒ Object
- .mobTurn ⇒ Object
- .mobTurnResolve(action, dmg, playerHP) ⇒ Object
- .playerMiss ⇒ Object
- .playerStart(playerHP, mobHP) ⇒ Object
- .playerTurn ⇒ Object
- .playerTurnResolve(action, dmg, mobHP) ⇒ Object
- .start(mob) ⇒ Object
- .victory(drop) ⇒ Object
Class Method Details
.defeat ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/lotrd/view/combatView.rb', line 141 def defeat system 'clear' puts "Combat" + "\n" + "=" * 40 + "\n"*2 puts "You have been defeated by the overwhelming power of the #{@mob.name.colorize(:red)}! You have lost all the gold and equipment you were carrying." sleep(3) puts "Respawning" sleep(2) system 'clear' puts "Respawning." sleep(2) system 'clear' puts "Respawning.." sleep(2) system 'clear' puts "Respawning..." sleep(2) ::Town. end |
.escape ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/lotrd/view/combatView.rb', line 101 def escape system 'clear' puts "Combat => Your turn" + "\n" + "=" * 40 + "\nPlayer HP: #{@currentPlayerHP}" + "\n" + "Enemy HP: #{@currentMobHP}" + "\n" + "=" * 20 + "\n"*2 puts "You attempt to run away" sleep(1) system 'clear' puts "Combat => Your turn" + "\n" + "=" * 40 + "\nPlayer HP: #{@currentPlayerHP}" + "\n" + "Enemy HP: #{@currentMobHP}" + "\n" + "=" * 20 + "\n"*2 puts "You attempt to run away." sleep(1) system 'clear' puts "Combat => Your turn" + "\n" + "=" * 40 + "\nPlayer HP: #{@currentPlayerHP}" + "\n" + "Enemy HP: #{@currentMobHP}" + "\n" + "=" * 20 + "\n"*2 puts "You attempt to run away.." sleep(1) system 'clear' puts "Combat => Your turn" + "\n" + "=" * 40 + "\nPlayer HP: #{@currentPlayerHP}" + "\n" + "Enemy HP: #{@currentMobHP}" + "\n" + "=" * 20 + "\n"*2 puts "You attempt to run away..." sleep(1) ::CombatSim.escapeCheck end |
.escapeFail ⇒ Object
127 128 129 130 131 |
# File 'lib/lotrd/view/combatView.rb', line 127 def escapeFail puts "You were too slow! The enemy has caught up to you!" sleep(3) ::CombatSim.turnHandler end |
.escapeSuccess ⇒ Object
121 122 123 124 125 |
# File 'lib/lotrd/view/combatView.rb', line 121 def escapeSuccess puts "You got away safely!" sleep(3) ::Town. end |
.mobMiss ⇒ Object
31 32 33 34 35 |
# File 'lib/lotrd/view/combatView.rb', line 31 def mobMiss puts "The #{@mob.name.colorize(:red)}'s attack missed you!" sleep(3) ::CombatSim.turnHandler end |
.mobStart(playerHP, mobHP) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/lotrd/view/combatView.rb', line 15 def mobStart(playerHP, mobHP) @currentPlayerHP = playerHP @currentMobHP = mobHP system 'clear' puts "Combat => Enemy turn" + "\n" + "=" * 40 + "\nPlayer HP: #{@currentPlayerHP}" + "\n" + "Enemy HP: #{@currentMobHP}" + "\n" + "=" * 20 + "\n"*2 puts "The #{@mob.name.colorize(:red)} sees you and attacks you suddenly!" sleep(5) ::CombatSim.mobHit end |
.mobTurn ⇒ Object
25 26 27 28 29 |
# File 'lib/lotrd/view/combatView.rb', line 25 def mobTurn system 'clear' puts "Combat => Enemy turn" + "\n" + "=" * 40 + "\nPlayer HP: #{@currentPlayerHP}" + "\n" + "Enemy HP: #{@currentMobHP}" + "\n" + "=" * 20 + "\n"*2 ::CombatSim.mobHit end |
.mobTurnResolve(action, dmg, playerHP) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/lotrd/view/combatView.rb', line 37 def mobTurnResolve(action, dmg, playerHP) @currentPlayerHP = playerHP system 'clear' puts "Combat => Enemy turn" + "\n" + "=" * 40 + "\nPlayer HP: #{@currentPlayerHP}" + "\n" + "Enemy HP: #{@currentMobHP}" + "\n" + "=" * 20 + "\n"*2 puts "#{@mob.name.colorize(:red)} #{ case action when 1 "swings their weapon at you and deals" when 2 "fires a spell at you and deals" when 3 "shoots an arrow at you and hits you for" end} #{dmg} damange." sleep(3) ::CombatSim.roundResolve end |
.playerMiss ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/lotrd/view/combatView.rb', line 76 def playerMiss system 'clear' puts "Combat => Your turn" + "\n" + "=" * 40 + "\nPlayer HP: #{@currentPlayerHP}" + "\n" + "Enemy HP: #{@currentMobHP}" + "\n" + "=" * 20 + "\n"*2 puts "The #{@mob.name.colorize(:red)} was too fast for you! Your attack missed." sleep(3) ::CombatSim.turnHandler end |
.playerStart(playerHP, mobHP) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/lotrd/view/combatView.rb', line 54 def playerStart(playerHP, mobHP) @currentPlayerHP = playerHP @currentMobHP = mobHP system 'clear' puts "Combat => Your turn" + "\n" + "=" * 40 + "\nPlayer HP: #{@currentPlayerHP}" + "\n" + "Enemy HP: #{@currentMobHP}" + "\n" + "=" * 20 + "\n"*2 puts "The #{@mob.name.colorize(:red)} hasn't noticed you yet. You get ready to surprise attack them." sleep(5) ::CombatView.playerTurn end |
.playerTurn ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/lotrd/view/combatView.rb', line 64 def playerTurn system 'clear' puts "Combat => Your turn" + "\n" + "=" * 40 + "\nPlayer HP: #{@currentPlayerHP}" + "\n" + "Enemy HP: #{@currentMobHP}" + "\n" + "=" * 20 + "\n"*2 prompt = TTY::Prompt.new prompt.select("What would you like to do?") do || .choice 'Melee Attack'.colorize(:light_red), -> {::CombatSim.playerHit(1)} .choice 'Cast a spell'.colorize(:light_yellow), -> {::CombatSim.playerHit(2)} .choice 'Ranger attack'.colorize(:light_green), -> {::CombatSim.playerHit(3)} .choice 'Run away'.colorize(:light_blue), -> {::CombatView.escape} end end |
.playerTurnResolve(action, dmg, mobHP) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/lotrd/view/combatView.rb', line 84 def playerTurnResolve(action, dmg, mobHP) system 'clear' @currentMobHP = mobHP puts "Combat => Your turn" + "\n" + "=" * 40 + "\nPlayer HP: #{@currentPlayerHP}" + "\n" + "Enemy HP: #{@currentMobHP}" + "\n" + "=" * 20 + "\n"*2 puts "You #{ case action when 1 "swing your weapon at #{@mob.name} and deal" when 2 "fire a spell at #{@mob.name} and deal" when 3 "shoot an arrow at #{@mob.name} and hit them for" end} #{dmg} damange." sleep(3) ::CombatSim.roundResolve end |
.start(mob) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/lotrd/view/combatView.rb', line 6 def start(mob) system 'clear' @mob = mob puts "Combat" + "\n" + "=" * 40 + "\n"*2 puts "You move foward cautiously and find a #{@mob.name.colorize(:red)}." sleep(3) ::CombatSim.initiative end |
.victory(drop) ⇒ Object
133 134 135 136 137 138 139 |
# File 'lib/lotrd/view/combatView.rb', line 133 def victory(drop) system 'clear' puts "Combat" + "\n" + "=" * 40 + "\n"*2 puts "Congratulations, you have defeated the #{@mob.name.colorize(:red)}! Rummaging their corpse you have found #{drop} gold." sleep(3) ::Town. end |