37 lines
1.2 KiB
GDScript
37 lines
1.2 KiB
GDScript
class_name BattleParticipant
|
|
extends RefCounted
|
|
|
|
#qui prend part au combat : joueur, dresseur ou pokemon sauvage.
|
|
#il possede une equipe (le "banc"), un controleur, et pilote slot_count emplacements.
|
|
|
|
var name : String = ""
|
|
var team : PokemonTeam
|
|
var side : int = 0
|
|
var slot_count : int = 1
|
|
var controller : BattleController
|
|
var lead : Array[PokemonInstance] = [] #pokemon a envoyer en premier (ex. celui lance par le joueur)
|
|
var is_player : bool = false
|
|
|
|
func _init(p_name : String, p_team : PokemonTeam, p_side : int, p_controller : BattleController = null, p_slot_count : int = 1) -> void:
|
|
name = p_name
|
|
team = p_team
|
|
side = p_side
|
|
slot_count = maxi(p_slot_count, 1)
|
|
controller = p_controller if p_controller != null else BattleAI.new()
|
|
|
|
func pick_starters() -> Array[PokemonInstance]:
|
|
#d'abord les "lead" (aptes), puis l'ordre de l'equipe, jusqu'a slot_count
|
|
var result : Array[PokemonInstance] = []
|
|
for p in lead:
|
|
if result.size() >= slot_count: break
|
|
if p != null and !p.is_fainted() and team.members.has(p) and !result.has(p):
|
|
result.append(p)
|
|
for p in team.members:
|
|
if result.size() >= slot_count: break
|
|
if !p.is_fainted() and !result.has(p):
|
|
result.append(p)
|
|
return result
|
|
|
|
func has_able_pokemon() -> bool:
|
|
return team.has_able_pokemon()
|