Class: Battle::Actions::Item
- Defined in:
- scripts/01600 Alpha 25 Battle Engine/03000 Actions/00004 Item.rb
Overview
Class describing the usage of an Item
Instance Attribute Summary collapse
-
#item_wrapper ⇒ PFM::ItemDescriptor::Wrapper
readonly
Get the item wrapper executing the action.
-
#user ⇒ PFM::PokemonBattler
readonly
Get the Pokemon responsive of the item usage.
Instance Method Summary collapse
-
#<=>(other) ⇒ Integer
Compare this action with another.
-
#execute
Execute the action.
-
#initialize(scene, item_wrapper, bag, user) ⇒ Item
constructor
Create a new item action.
Methods inherited from Base
Constructor Details
#initialize(scene, item_wrapper, bag, user) ⇒ Item
Create a new item action
17 18 19 20 21 22 |
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00004 Item.rb', line 17 def initialize(scene, item_wrapper, bag, user) super(scene) @item_wrapper = item_wrapper @bag = bag @user = user end |
Instance Attribute Details
#item_wrapper ⇒ PFM::ItemDescriptor::Wrapper (readonly)
Get the item wrapper executing the action
10 11 12 |
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00004 Item.rb', line 10 def item_wrapper @item_wrapper end |
#user ⇒ PFM::PokemonBattler (readonly)
Get the Pokemon responsive of the item usage
7 8 9 |
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00004 Item.rb', line 7 def user @user end |
Instance Method Details
#<=>(other) ⇒ Integer
Compare this action with another
27 28 29 30 31 32 33 |
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00004 Item.rb', line 27 def <=>(other) return 1 if other.is_a?(HighPriorityItem) return 1 if other.is_a?(Attack) && Attack.from(other).pursuit_enabled return Item.from(other).user.spd <=> @user.spd if other.is_a?(Item) return -1 end |
#execute
Execute the action
36 37 38 39 40 41 42 43 44 |
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00004 Item.rb', line 36 def execute names = @scene.battle_info.names trname = names.dig(@user.bank, @user.party_id) || names.dig(@user.bank, 0) || names.dig(0, 0) = parse_text(18, 34, PFM::Text::ITEM2[1] => @item_wrapper.item.name, PFM::Text::TRNAME[0] => trname) @scene.() @bag.remove_item(@item_wrapper.item.id, 1) if @item_wrapper.item.is_limited @bag.last_battle_item_db_symbol = @item_wrapper.item.db_symbol @item_wrapper.execute_battle_action end |