57 lines
2.2 KiB
GDScript
57 lines
2.2 KiB
GDScript
class_name BattleEvent
|
|
extends RefCounted
|
|
|
|
#ce qui se passe pendant un combat. La logique les emet ; la presentation (texte, animations 3D,
|
|
#barres de PV) les lit un par un. Les emplacements sont identifies par leur id.
|
|
|
|
enum Type {
|
|
BATTLE_START, BATTLE_END, TURN_START,
|
|
SENT_OUT, WITHDRAWN,
|
|
MOVE_USED, MOVE_MISSED, DAMAGE, CRITICAL,
|
|
SUPER_EFFECTIVE, NOT_VERY_EFFECTIVE, NO_EFFECT,
|
|
FAINTED, FLED, MESSAGE,
|
|
STATUS_CHANGED, HEAL, WEATHER_CHANGED,
|
|
}
|
|
|
|
var type : Type = Type.MESSAGE
|
|
var source_slot : int = -1
|
|
var target_slot : int = -1
|
|
var source_name : String = ""
|
|
var target_name : String = ""
|
|
var move : MoveData = null
|
|
var amount : int = 0 #degats, soin, numero de tour, nouveau statut (STATUS_CHANGED : 0 = gueri)...
|
|
var hp : int = 0 #PV restants de la cible
|
|
var max_hp : int = 0
|
|
var text : String = ""
|
|
|
|
static func make(p_type : Type, p_source : BattleSlot = null, p_target : BattleSlot = null) -> BattleEvent:
|
|
var e := BattleEvent.new()
|
|
e.type = p_type
|
|
if p_source != null:
|
|
e.source_slot = p_source.id
|
|
if p_source.mon != null: e.source_name = p_source.mon.display_name()
|
|
if p_target != null:
|
|
e.target_slot = p_target.id
|
|
if p_target.mon != null: e.target_name = p_target.mon.display_name()
|
|
return e
|
|
|
|
func describe() -> String:
|
|
#texte par defaut (boite de dialogue, journal de debug)
|
|
match type:
|
|
Type.BATTLE_START: return "Le combat commence !"
|
|
Type.BATTLE_END: return text
|
|
Type.TURN_START: return "— Tour %d —" % amount
|
|
Type.SENT_OUT: return "%s entre en combat !" % source_name
|
|
Type.WITHDRAWN: return "%s est rappelé !" % source_name
|
|
Type.MOVE_USED: return "%s utilise %s !" % [source_name, move.get_display_name() if move else "?"]
|
|
Type.MOVE_MISSED: return "%s évite l'attaque !" % target_name
|
|
Type.DAMAGE: return "%s perd %d PV (%d/%d)" % [target_name, amount, hp, max_hp]
|
|
Type.CRITICAL: return "Coup critique !"
|
|
Type.SUPER_EFFECTIVE: return "C'est super efficace !"
|
|
Type.NOT_VERY_EFFECTIVE: return "Ce n'est pas très efficace..."
|
|
Type.NO_EFFECT: return "Ça n'affecte pas %s..." % target_name
|
|
Type.FAINTED: return "%s est K.O. !" % source_name
|
|
Type.FLED: return "Vous prenez la fuite !"
|
|
Type.MESSAGE, Type.STATUS_CHANGED, Type.HEAL, Type.WEATHER_CHANGED: return text
|
|
return ""
|