module CombatView

Public Class Methods

defeat() click to toggle source
# 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.menu
end
escape() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# File lib/lotrd/view/combatView.rb, line 121
def escapeSuccess
    puts "You got away safely!"
    sleep(3)
    ::Town.menu
end
mobMiss() click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# 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 |menu|
        menu.choice 'Melee Attack'.colorize(:light_red), -> {::CombatSim.playerHit(1)}
        menu.choice 'Cast a spell'.colorize(:light_yellow), -> {::CombatSim.playerHit(2)}
        menu.choice 'Ranger attack'.colorize(:light_green), -> {::CombatSim.playerHit(3)}
        menu.choice 'Run away'.colorize(:light_blue), -> {::CombatView.escape}
    end
end
playerTurnResolve(action, dmg, mobHP) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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.menu
end

Private Instance Methods

defeat() click to toggle source
# 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.menu
end
escape() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# File lib/lotrd/view/combatView.rb, line 121
def escapeSuccess
    puts "You got away safely!"
    sleep(3)
    ::Town.menu
end
mobMiss() click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# 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 |menu|
        menu.choice 'Melee Attack'.colorize(:light_red), -> {::CombatSim.playerHit(1)}
        menu.choice 'Cast a spell'.colorize(:light_yellow), -> {::CombatSim.playerHit(2)}
        menu.choice 'Ranger attack'.colorize(:light_green), -> {::CombatSim.playerHit(3)}
        menu.choice 'Run away'.colorize(:light_blue), -> {::CombatView.escape}
    end
end
playerTurnResolve(action, dmg, mobHP) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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.menu
end