Guest User

Untitled

a guest
Jan 28th, 2020
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.26 KB | None | 0 0
  1.  
  2. class Abilities
  3.   attr_accessor :caster, :opponent
  4.  
  5.   def initialize(player1, player2)
  6.     @caster = player1
  7.     @opponent = player2
  8.   end
  9.  
  10.   def switch_sides
  11.     @caster, @opponent = @opponent, @caster
  12.   end
  13.  
  14. def ability_choice
  15.     puts 'Choose ability'
  16.  
  17.     i = 1
  18.  
  19.     @caster.abilities.each do |key, value|
  20.       puts "#{i} - #{value}"
  21.       i += 1
  22.     end
  23.  
  24.     puts "\n\n"
  25.  
  26.     choice = 0
  27.  
  28.     until choice.between?(1, @caster.abilities.size)
  29.       puts "Input must be between 1 and #{@caster.abilities.size}"
  30.       choice = STDIN.gets.chomp.to_i
  31.     end
  32.     choice
  33.   end
  34.  
  35.  
  36.   def ability_call(choice)
  37.     ability = @caster.abilities.keys[choice - 1]
  38.      
  39.     if buffs.keys.include?(ability)
  40.  
  41.       if ability == :curse
  42.        
  43.         if @caster.status[:curse][2].is_a?(FalseClass)
  44.          
  45.           buff(buffs[:curse])
  46.        
  47.         else
  48.          
  49.           ability_choice
  50.        
  51.         end
  52.  
  53.       else
  54.  
  55.         if @caster.status[ability][1].is_a?(FalseClass)
  56.  
  57.           buff(buffs[ability])
  58.  
  59.         else
  60.  
  61.           ability_choice
  62.  
  63.         end
  64.  
  65.       end
  66.  
  67.     elsif spells.keys.include?(ability)
  68.  
  69.       cast_spell(spells[ability])
  70.  
  71.     else
  72.  
  73.       method(ability).call
  74.  
  75.     end
  76.  
  77.   end
  78. end
Advertisement
Add Comment
Please, Sign In to add comment