39 lines
1.8 KiB
GDScript
39 lines
1.8 KiB
GDScript
class_name BattleSetup
|
|
extends RefCounted
|
|
|
|
#description complete d'un combat, construite par le monde avant de le lancer.
|
|
#le format (1v1, 2v2, 1 contre plusieurs, plusieurs contre 1) vient simplement du nombre
|
|
#de participants par camp et du nombre d'emplacements (slot_count) de chacun.
|
|
|
|
var participants : Array[BattleParticipant] = []
|
|
var can_flee : bool = true #false pour un combat de dresseur
|
|
var seed_value : int = 0 #0 = hasard ; autre valeur = combat reproductible (tests)
|
|
|
|
func add(participant : BattleParticipant) -> BattleSetup:
|
|
participants.append(participant)
|
|
return self
|
|
|
|
func is_valid() -> bool:
|
|
var sides : Dictionary = {}
|
|
for p in participants:
|
|
if p.team != null and p.team.has_able_pokemon(): sides[p.side] = true
|
|
return sides.has(0) and sides.has(1)
|
|
|
|
#---------- fabriques ----------
|
|
|
|
static func player_participant(team : PokemonTeam, slot_count : int = 1, thrown : PokemonInstance = null, controller : BattleController = null) -> BattleParticipant:
|
|
#joueur qui initie : le pokemon lance passe en premier, puis l'ordre de l'equipe
|
|
#joueur defie (thrown = null) : l'ordre de l'equipe (le 1er, puis le 2e pour un duo...)
|
|
var p := BattleParticipant.new("Joueur", team, 0, controller, slot_count)
|
|
p.is_player = true
|
|
if thrown != null: p.lead.append(thrown)
|
|
return p
|
|
|
|
static func wild_participant(pokemon : PokemonInstance, controller : BattleController = null) -> BattleParticipant:
|
|
var team := PokemonTeam.new()
|
|
team.add_pokemon(pokemon)
|
|
return BattleParticipant.new(pokemon.get_display_name(), team, 1, controller, 1)
|
|
|
|
static func trainer_participant(trainer : TrainerData, slot_count : int = 1, controller : BattleController = null) -> BattleParticipant:
|
|
return BattleParticipant.new(trainer.get_display_name(), trainer.create_team(), 1, controller, slot_count)
|