Originally Posted by
phantomotap
The qualities of the attacks can be modeled separately. Basically, there is no need to attempt an inheritance related hierarchy of types/probabilities/power/yield/etc. when you can model those things separately and simply contain one or more of each model in an instance of a specific attack.
Don't really understand what you mean very well, but well in my current design I have a database_attacks class, which has the following datamember:
Code:
vector<Database_Attacks_Instance*> m_Attacks;
This vector get's filled from a textfile where data is stored like this:
Code:
//|name,functionID,base_damage,base_pp,accuracy,type|
|POUND,0,40,35,255,0|
the database_attacks_instance class looks like this:
Code:
class Database_Attacks_Instance
{
public:
Database_Attacks_Instance(); // Constructor
virtual ~Database_Attacks_Instance(); // Destructor
//-------------------------------------------------
// Methods
//-------------------------------------------------
void SetName(tstring &name) {m_Name = name;}
void SetBaseDamage(TinyIntU damage) {m_BaseDamage = damage;}
void SetType(TinyInt type) {m_Type = type;}
void SetAccuracy(TinyIntU acc) {m_Accuracy = acc;}
void SetBasePP(TinyIntU PP) {m_BasePP = PP;}
void SetFunctionID(TinyIntU func) {m_FunctionID = func;}
tstring GetName() {return m_Name;}
TinyIntU GetBaseDamage() {return m_BaseDamage;}
TinyInt GetType() {return m_Type;}
TinyIntU GetAccuracy() {return m_Accuracy;}
TinyIntU GetBasePP() {return m_BasePP;}
TinyIntU GetFunctionID() {return m_FunctionID;}
private:
//-------------------------------------------------
// Datamembers
//-------------------------------------------------
tstring m_Name; //name of the attack
TinyIntU m_BaseDamage; //base damage value
TinyInt m_Type; //type of attack
TinyIntU m_Accuracy; //accuracy, NOTE: base 256, so this value can be anything from 0 till 255
TinyIntU m_BasePP; //base PP
TinyIntU m_FunctionID; //ID that will point out which function (what code) should be called to handle this attack while in battle
// -------------------------
// Disabling default copy constructor and default
// assignment operator.
// -------------------------
Database_Attacks_Instance(const Database_Attacks_Instance& s);
Database_Attacks_Instance& operator=(const Database_Attacks_Instance& s);
};
So where should I go from there, just make an execute method in the database_attacks_instance, and make it a large switch depending on the m_FunctionID?
btw, tstring is wstring, TinyInt is char and TinyIntU is an unsigned char