Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Abilities
- attr_accessor :caster, :opponent
- def initialize(player1, player2)
- @caster = player1
- @opponent = player2
- end
- def switch_sides
- @caster, @opponent = @opponent, @caster
- end
- def ability_choice
- puts 'Choose ability'
- i = 1
- @caster.abilities.each do |key, value|
- puts "#{i} - #{value}"
- i += 1
- end
- puts "\n\n"
- choice = 0
- until choice.between?(1, @caster.abilities.size)
- puts "Input must be between 1 and #{@caster.abilities.size}"
- choice = STDIN.gets.chomp.to_i
- end
- choice
- end
- def ability_call(choice)
- ability = @caster.abilities.keys[choice - 1]
- if buffs.keys.include?(ability)
- if ability == :curse
- if @caster.status[:curse][2].is_a?(FalseClass)
- buff(buffs[:curse])
- else
- ability_choice
- end
- else
- if @caster.status[ability][1].is_a?(FalseClass)
- buff(buffs[ability])
- else
- ability_choice
- end
- end
- elsif spells.keys.include?(ability)
- cast_spell(spells[ability])
- else
- method(ability).call
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment