49 lines
1.3 KiB
GDScript
49 lines
1.3 KiB
GDScript
class_name BattleAction
|
|
extends RefCounted
|
|
|
|
#ce qu'un emplacement choisit de faire pendant un tour
|
|
|
|
enum Type { MOVE, SWITCH, ITEM, FLEE }
|
|
|
|
var type : Type = Type.MOVE
|
|
var slot : BattleSlot #qui agit
|
|
var move : MoveData
|
|
var move_slot : MoveSlot #null pour Lutte
|
|
var chosen_target : BattleSlot = null #cible choisie (null = automatique)
|
|
var switch_to : PokemonInstance
|
|
|
|
#calcules par Battle au moment de trier les actions
|
|
var priority : int = 0
|
|
var speed : float = 0.0
|
|
var tiebreak : float = 0.0
|
|
|
|
static func use_move(p_slot : BattleSlot, p_move_slot : MoveSlot, p_target : BattleSlot = null) -> BattleAction:
|
|
var a := BattleAction.new()
|
|
a.type = Type.MOVE
|
|
a.slot = p_slot
|
|
a.move_slot = p_move_slot
|
|
a.move = p_move_slot.move
|
|
a.chosen_target = p_target
|
|
return a
|
|
|
|
static func use_struggle(p_slot : BattleSlot) -> BattleAction:
|
|
#plus aucune capacite utilisable : Lutte
|
|
var a := BattleAction.new()
|
|
a.type = Type.MOVE
|
|
a.slot = p_slot
|
|
a.move = Battle.make_struggle()
|
|
return a
|
|
|
|
static func switch_pokemon(p_slot : BattleSlot, p_pokemon : PokemonInstance) -> BattleAction:
|
|
var a := BattleAction.new()
|
|
a.type = Type.SWITCH
|
|
a.slot = p_slot
|
|
a.switch_to = p_pokemon
|
|
return a
|
|
|
|
static func flee(p_slot : BattleSlot) -> BattleAction:
|
|
var a := BattleAction.new()
|
|
a.type = Type.FLEE
|
|
a.slot = p_slot
|
|
return a
|