From 147bb12b5d48c5432aa1bd1cbe60b8435294445b Mon Sep 17 00:00:00 2001 From: Matheus Date: Thu, 4 Sep 2025 17:20:48 -0300 Subject: Ações gratuitas são mais explícitas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/entities/actions/Action.cs | 3 ++- scripts/entities/actions/BumpAction.cs | 4 ++-- scripts/entities/actions/MeleeAction.cs | 7 ++++--- scripts/entities/actions/MovementAction.cs | 8 +++++--- scripts/entities/actions/WaitAction.cs | 3 ++- 5 files changed, 15 insertions(+), 10 deletions(-) (limited to 'scripts/entities/actions') diff --git a/scripts/entities/actions/Action.cs b/scripts/entities/actions/Action.cs index f20e262..3f15105 100644 --- a/scripts/entities/actions/Action.cs +++ b/scripts/entities/actions/Action.cs @@ -31,7 +31,8 @@ public abstract partial class Action : RefCounted { /// /// /// - public abstract void Perform(); + /// Se a ação foi executada ou não. + public abstract bool Perform(); /// /// É conveniente ter acesso ao mapa dentro de uma ação. diff --git a/scripts/entities/actions/BumpAction.cs b/scripts/entities/actions/BumpAction.cs index bee202b..fa2605f 100644 --- a/scripts/entities/actions/BumpAction.cs +++ b/scripts/entities/actions/BumpAction.cs @@ -13,7 +13,7 @@ public partial class BumpAction : DirectionalAction // Como esta ação inevitavelmente gera outras ações, // não faz sentido descontar a energia do ator. - public override void Perform() + public override bool Perform() { // Declaramos uma ação genérica. Action action; @@ -27,6 +27,6 @@ public partial class BumpAction : DirectionalAction } // Executa a ação. - action.Perform(); + return action.Perform(); } } diff --git a/scripts/entities/actions/MeleeAction.cs b/scripts/entities/actions/MeleeAction.cs index 6dfeb78..09c5cc7 100644 --- a/scripts/entities/actions/MeleeAction.cs +++ b/scripts/entities/actions/MeleeAction.cs @@ -12,14 +12,14 @@ public partial class MeleeAction : DirectionalAction /// /// Ataca o ator na direção da ação. /// - public override void Perform() + public override bool Perform() { // Eu te disse que este método seria útil. Entity potentialTarget = GetTarget(); // Só podemos atacar atores. if (potentialTarget is not Actor) { - return; + return false; } Actor target = (Actor)potentialTarget; @@ -27,7 +27,7 @@ public partial class MeleeAction : DirectionalAction // Se não houver um ator na direção, não podemos continuar. // Isto é uma ação gratuita. - if (target == null) return; + if (target == null) return false; // não podemos ter dano negativo. int damage = actor.Atk - target.Def; @@ -43,5 +43,6 @@ public partial class MeleeAction : DirectionalAction MessageLogData.Instance.AddMessage(attackDesc); actor.Energy -= cost; + return true; } } diff --git a/scripts/entities/actions/MovementAction.cs b/scripts/entities/actions/MovementAction.cs index 2c394fc..403ec0a 100644 --- a/scripts/entities/actions/MovementAction.cs +++ b/scripts/entities/actions/MovementAction.cs @@ -9,16 +9,18 @@ public partial class MovementAction : DirectionalAction { } - public override void Perform() + public override bool Perform() { // Não anda se o destino for um tile sólido. - if (!Map_Data.GetTile(Destination).IsWalkable) return; + if (!Map_Data.GetTile(Destination).IsWalkable) return true; // Não anda se o destino for oculpado por um ator. // Na maioria dos casos, essa condição nunca é verdadeira. - if (GetTarget() != null) return; + if (GetTarget() != null) return true; actor.Walk(Offset); actor.Energy -= cost; + + return true; } } diff --git a/scripts/entities/actions/WaitAction.cs b/scripts/entities/actions/WaitAction.cs index 2d3ccc2..c26d884 100644 --- a/scripts/entities/actions/WaitAction.cs +++ b/scripts/entities/actions/WaitAction.cs @@ -9,7 +9,7 @@ public partial class WaitAction : Action { } - public override void Perform() + public override bool Perform() { //-=-==============================================-======++++*@@%*+#%%+*%%#*#%%@%**%%#=:+%@%=--.....::::@@@:................... #@----::@@@@@@@@@@@@@ //--============--===========================================+@. :@ =% @ :* @#= @@*........@@@:................ .::::::@@@@@@@@@@@@ @@ -97,6 +97,7 @@ public partial class WaitAction : Action //@@@@@@@@@@@======++====+*%@@@@%%%@@@@%*+#@@@@@%#%@@#=+**=. =**+=***==*#*: :%@@@@@@@@@**=+#*==*###*=. -=**+::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@+==+==++=====++=====++=+++++++++===+++++#% +@@@* :#%= =@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ actor.Energy -= cost; + return true; } -- cgit v1.2.3