From a93188b3a226c4d61e531eef270c6e7be975da4c Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sat, 27 Nov 2010 05:52:06 +0100 Subject: Split target type and target offset in Action. --- common/action.cpp | 6 +++--- common/action.h | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'common') diff --git a/common/action.cpp b/common/action.cpp index 77988d6..527d25e 100644 --- a/common/action.cpp +++ b/common/action.cpp @@ -1,14 +1,14 @@ #include "action.h" #include -Action::Action() { +Action::Action() : target_type(None), target_offset(0) { } -Action::Action(Type ty, int ta) : type(ty), target(ta) { +Action::Action(Type ty, TargetType tt, int to) : type(ty), target_type(tt), target_offset(to) { } bool Action::operator==(const Action& other) { - return type == other.type && target == other.target; + return type == other.type && target_type == other.target_type && target_offset == other.target_offset; } diff --git a/common/action.h b/common/action.h index e1b06f2..122411b 100644 --- a/common/action.h +++ b/common/action.h @@ -18,14 +18,22 @@ class Action { Draw // draw }; + //! Action target type. + enum TargetType { + None, // No target + Hand, // Target in hand. + Open // Target in open. + }; + //! Type of action. Type type; //! Target of action (if applicable). - int target; + TargetType target_type; + int target_offset; Action(); - Action(Type ty, int ta = 0); + Action(Type ty, TargetType tt = None, int to = 0); //! Compare to another action. bool operator==(const Action& other); @@ -33,7 +41,8 @@ class Action { template void serialize(Archive & ar, const unsigned int version) { ar & type; - ar & target; + ar & target_type; + ar & target_offset; } }; -- cgit v1.2.3