Module: BattleUI::PlayerChoiceAbstraction
- Includes:
- GenericChoice
- Included in:
- PlayerChoice
- Defined in:
- scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00050 PlayerChoiceAbstraction.rb
Overview
Abstraction helping to design player choice a way that complies to what Visual expect to handle
Instance Attribute Summary collapse
-
#action ⇒ Battle::Actions::Base
readonly
The possible action made by the player (other than choosing a sub action).
-
#index ⇒ Integer
readonly
Get the index.
-
#result ⇒ Symbol?
readonly
The result :attack, :bag, :pokemon, :flee, :cancel, :try_next, :action.
Instance Method Summary collapse
-
#reset(can_switch)
Reset the choice.
-
#use_item(item)
Force the action to use an item.
-
#validated? ⇒ Boolean
If the player made a choice.
Instance Attribute Details
#action ⇒ Battle::Actions::Base (readonly)
The possible action made by the player (other than choosing a sub action)
11 12 13 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00050 PlayerChoiceAbstraction.rb', line 11 def action @action end |
#index ⇒ Integer (readonly)
Get the index
14 15 16 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00050 PlayerChoiceAbstraction.rb', line 14 def index @index end |
#result ⇒ Symbol? (readonly)
The result :attack, :bag, :pokemon, :flee, :cancel, :try_next, :action
8 9 10 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00050 PlayerChoiceAbstraction.rb', line 8 def result @result end |
Instance Method Details
#reset(can_switch)
Reset the choice
18 19 20 21 22 23 24 25 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00050 PlayerChoiceAbstraction.rb', line 18 def reset(can_switch) @action = nil @result = nil @can_switch = can_switch @index = 0 scene.visual.set_info_state(:choice) super() if @super_reset end |
#use_item(item)
Force the action to use an item
35 36 37 38 39 40 41 42 43 44 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00050 PlayerChoiceAbstraction.rb', line 35 def use_item(item) item_wrapper = PFM::ItemDescriptor.actions(item.id) return use_item_on_creature_choice(item_wrapper) if item_wrapper.on_creature_choice? @result = :action user = scene.logic.battler(0, scene.player_actions.size) item_wrapper.bind(scene, user) $bag.remove_item(item_wrapper.item.db_symbol, 1) if item_wrapper.item.is_limited && item_wrapper.item.is_a?(Studio::BallItem) @action = Battle::Actions::Item.new(scene, item_wrapper, $bag, user) end |
#validated? ⇒ Boolean
If the player made a choice
29 30 31 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00050 PlayerChoiceAbstraction.rb', line 29 def validated? !@result.nil? && (respond_to?(:done?, true) ? done? : true) end |