An enum made of structs

Started by
11 comments, last by jellyfishchris 11 years ago

Why not just declare objects?


// Move.h

extern const Move
  TACKLE,
  GROWL,
  HYPER_BEAM,
  ...;

// Move.cpp

const Move TACKLE(...);
const Move GROWL(...);
const Move HYPER_BEAM(...);

If you need these in a table (e.g., to refer to them by integer ID), then you can build that separately.

Advertisement

Yeah, I don't understand the need for enums here. They could just be global constants in your case.

I did a little shell for you to look at and fill in yourself. Consider using tinyXML to load XML. (No idea if any of this compiles, as it was only to show you what to do)


struct Move{    
char*       m_cpName;    
int         m_iID;    
MoveClass   m_class;    
Target      m_target;    
int         m_iPP;    
int         m_iAccuracy;    
int         m_iBasePower;    
int         m_iPriority;    
Type        m_type;    
int         m_iFlags;};
enum 
Moves{   TACKLE,   GROWL,   HYPER_BEAM};
class Moves{
public: bool LoadMoves(std::string filename) {  
//LoadXML file  
//As you load them you can tell in the XML I do <Move type = "1">  
//this means that this move is tackle because in the enums its the first value  
//Load in all of the related data to the move.  
return true; 
} 
Move* GetMove(int type) {  
//checking and return the move  
return nullptr; 
}
private:  
std::vector<Move*> m_listOfMoves;
};

?

?

<?xml version = "1.0"?>
<Moves>
<Move type = "1">
<Name>Tackle<Name/>
<ID>1</ID>
<PP>3</PP>
</Move>
</Moves>


This topic is closed to new replies.

Advertisement