summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/attack.h
diff options
context:
space:
mode:
authorRobert Burnham <burnhamrobertp@gmail.com>2011-03-31 15:55:22 -0500
committerRobert Burnham <burnhamrobertp@gmail.com>2011-03-31 15:55:22 -0500
commitdd07df81c8e6820af65f8993c50ca5ae0992c87a (patch)
treecbf4604ef9beb5822de1dcc1f2443358ceee9de0 /crawl-ref/source/attack.h
parent3393595462a5522b334236b823b1c90f32f375ba (diff)
downloadcrawl-ref-dd07df81c8e6820af65f8993c50ca5ae0992c87a.tar.gz
crawl-ref-dd07df81c8e6820af65f8993c50ca5ae0992c87a.zip
Establish handle_{{phase}} class methods
Creates shell class methods in attack to serve as the classes overloaded in inheriting classes which handle each particular phase of an attack. Any given handle_{{phase}} class method returns whether or not that phase was successful. Success indicates to continue to the next phase based on the appropriate variable configuration (eg, if to_hit and !blocked, do handle_landed()). handle_phase_attempted is the only non pure-virtual method of the attack class because there are problably some initialization-related variables that we can always compute and/or set for all attacks. handle_phase_attempted will be called by the attack constructor.
Diffstat (limited to 'crawl-ref/source/attack.h')
-rw-r--r--crawl-ref/source/attack.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/crawl-ref/source/attack.h b/crawl-ref/source/attack.h
index ffb9d0eccd..621ffceb98 100644
--- a/crawl-ref/source/attack.h
+++ b/crawl-ref/source/attack.h
@@ -9,14 +9,15 @@ const int HIT_WEAK = 7;
const int HIT_MED = 18;
const int HIT_STRONG = 36;
-enum phase
+enum atk_phase
{
ATK_ATTEMPTED, // 0
ATK_DODGED,
ATK_BLOCKED,
ATK_HIT,
ATK_DAMAGED,
- ATK_KILLED
+ ATK_KILLED,
+ ATK_END
};
class attack
@@ -25,7 +26,8 @@ class attack
public:
// General attack properties, set on instantiation or through a normal
// thread of execution
- actor *attacker, *defender;
+ actor *attacker, *defender;
+ atk_phase attack_phase;
bool cancel_attack;
bool did_hit;
@@ -108,6 +110,15 @@ public:
// Private Methods
protected:
virtual void init_attack();
+
+ virtual bool handle_phase_attempted();
+ virtual bool handle_phase_dodged() = 0;
+ virtual bool handle_phase_blocked() = 0;
+ virtual bool handle_phase_hit() = 0;
+ virtual bool handle_phase_damaged() = 0;
+ virtual bool handle_phase_killed() = 0;
+ virtual bool handle_phase_end() = 0;
+
virtual bool check_unrand_effects() = 0;
// Methods which produce output