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

Instance Method Summary collapse

Instance Attribute Details

#actionBattle::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

#indexInteger (readonly)

Get the index

Returns:



14
15
16
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00050 PlayerChoiceAbstraction.rb', line 14

def index
  @index
end

#resultSymbol? (readonly)

The result :attack, :bag, :pokemon, :flee, :cancel, :try_next, :action

Returns:

  • (Symbol, nil)


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

Parameters:

  • can_switch (Boolean)


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

Parameters:



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

Returns:

  • (Boolean)


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