#include #include using namespace std; enum ResultT {YELLOW_SIGN, TENTACLE, ELDER_SIGN, CTHULHU, EYE, UNKNOWN}; //enum StatusT {ALIVE, INSANE, DEAD, UNKNOWN}; // define some constants that make life easier using a ResultT const ResultT FIRST_RESULT = YELLOW_SIGN; const size_t RESULT_COUNT = UNKNOWN - FIRST_RESULT; // define some operations to support ResultT ResultT Next(ResultT r); string ResultTToString(ResultT r); ResultT StringToResultT(string s); string ToUpperString(string s); /* * * result = RollDie; * if (result == YELLOW_SIGN) { * targetSanity -= 1; * } else if (result == TENTACLE) { * if (caster) { * sanity += 1; * targetSanity -= 1; * } else { * cs * } * } */ int main() { ResultT x = YELLOW_SIGN; cout << "There are " << RESULT_COUNT << " different results " << endl; for(x = FIRST_RESULT; x < UNKNOWN; x= Next(x)) { cout << ResultTToString(x) << endl; } return 0; } string ToUpperString(string s){ size_t i; for(i = 0; i < s.size(); i++) { s[i] = static_cast(toupper(s[i])); } return s; } string ResultTToString(ResultT r){ string result {"UNKNOWN"}; switch(r) { case YELLOW_SIGN: result = "Yellow Sign"; break; case TENTACLE: result = "Tentacle"; break; case ELDER_SIGN: result = "Elder Sign"; break; case CTHULHU: result = "Cthulhu"; break; case EYE: result = "Eye"; break; case UNKNOWN: default: result = "Error"; } return result; } ResultT StringToResultT(string s){ ResultT result; s = ToUpperString(s); if (s == "YELLOW SIGN") { result = YELLOW_SIGN; } else if (s == "TENTACLE") { result = TENTACLE; } else if (s == "ELDER SIGN") { result = ELDER_SIGN; } else if (s == "CTHULHU") { result = CTHULHU; } else if (s == "EYE") { result = EYE; } else { result = UNKNOWN; } return result; } ResultT Next(ResultT r){ ResultT result{UNKNOWN}; if(r < UNKNOWN) { result = static_cast(r +1); } return result; }