00001 #ifndef GameContext_I2abdb221m12355049952mm7d51_H
00002 #define GameContext_I2abdb221m12355049952mm7d51_H
00003
00004 #include <list>
00005
00006 #include "Game.h"
00007 #include "State.h"
00008 #include "StateStart.h"
00010
00015 class GameContext : public Game{
00016
00017 public:
00021 GameContext(int const minWordSize = 4)
00022 :state(0),word(""),words(0),minWordSize(minWordSize){
00023 }
00024 ~GameContext(){
00025 StateStart::deleteInstance();
00026 }
00030 void setState(State *state){
00031 this->state = state;
00032 }
00033 enum LANGUAGE{DE,ENG,NL,FR};
00037 void setWords(LANGUAGE lan){
00038 switch(lan){
00039 case DE:
00040 readWords("wordlist/de.txt");
00041 break;
00042 case ENG:
00043 readWords("wordlist/eng.txt");
00044 break;
00045 case NL:
00046 readWords("wordlist/nl.txt");
00047 break;
00048 case FR:
00049 readWords("wordlist/fr.txt");
00050 break;
00051 }
00052 }
00054 void generateNextWord();
00056 std::string getWord()const{
00057 return word;
00058 }
00060 int getListCount()const{
00061 return words.size();
00062 }
00063 protected:
00068 virtual bool doInit();
00072 virtual void doLoop();
00073
00074 private:
00076 State *state;
00078 std::list<std::string> words;
00080 std::string word;
00082 int const minWordSize;
00084 bool readWords(const std::string path);
00086 std::string trimString(std::string source,const std::string seq = " \t");
00087 };
00088 #endif // GameContext_I2abdb221m12355049952mm7d51_H