Advertisement
Guest User

player2

a guest
May 22nd, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 10.82 KB | None | 0 0
  1. case MANAGER_ACCOUNT: {
  2. Account account = IOLoginData::getInstance()->loadAccount(managerNumber);
  3. if(checkText(text, "cancel") || (checkText(text, "account") && !talkState[1]))
  4. {
  5. talkState[1] = true;
  6. for(int8_t i = 2; i <= 12; i++)
  7. talkState[i] = false;
  8.  
  9. msg << "Do you want to change your 'password', request a 'recovery key', add a 'character', or 'delete' a character?";
  10. }
  11. else if(checkText(text, "delete") && talkState[1])
  12. {
  13. talkState[1] = false;
  14. talkState[2] = true;
  15. msg << "Which character would you like to delete?";
  16. }
  17. else if(talkState[2])
  18. {
  19. std::string tmp = text;
  20. trimString(tmp);
  21. if(!isValidName(tmp, false))
  22. msg << "That name contains invalid characters, try to say your name again, you might have typed it wrong.";
  23. else
  24. {
  25. talkState[2] = false;
  26. talkState[3] = true;
  27. managerString = tmp;
  28. msg << "Do you really want to delete the character named " << managerString << "?";
  29. }
  30. }
  31. else if(checkText(text, "yes") && talkState[3])
  32. {
  33. switch(IOLoginData::getInstance()->deleteCharacter(managerNumber, managerString))
  34. {
  35. case DELETE_INTERNAL:
  36. msg << "An error occured while deleting your character. Either the character does not belong to you or it doesn't exist.";
  37. break;
  38.  
  39. case DELETE_SUCCESS:
  40. msg << "Your character has been deleted.";
  41. break;
  42.  
  43. case DELETE_HOUSE:
  44. msg << "Your character owns a house. To make sure you really want to lose your house by deleting your character, you have to login and leave the house or pass it to someone else first.";
  45. break;
  46.  
  47. case DELETE_LEADER:
  48. msg << "Your character is the leader of a guild. You need to disband or pass the leadership someone else to delete your character.";
  49. break;
  50.  
  51. case DELETE_ONLINE:
  52. msg << "A character with that name is currently online, to delete a character it has to be offline.";
  53. break;
  54. }
  55.  
  56. talkState[1] = true;
  57. for(int8_t i = 2; i <= 12; i++)
  58. talkState[i] = false;
  59. }
  60. else if(checkText(text, "no") && talkState[3])
  61. {
  62. talkState[1] = true;
  63. talkState[3] = false;
  64. msg << "Tell me what character you want to delete.";
  65. }
  66. else if(checkText(text, "password") && talkState[1])
  67. {
  68. talkState[1] = false;
  69. talkState[4] = true;
  70. msg << "Tell me your new password please.";
  71. }
  72. else if(talkState[4])
  73. {
  74. std::string tmp = text;
  75. trimString(tmp);
  76. if(tmp.length() < 6)
  77. msg << "That password is too short, at least 6 digits are required. Please select a longer password.";
  78. else if(!isValidPassword(tmp))
  79. msg << "Your password contains invalid characters... please tell me another one.";
  80. else
  81. {
  82. talkState[4] = false;
  83. talkState[5] = true;
  84. managerString = tmp;
  85. msg << "Should '" << managerString << "' be your new password?";
  86. }
  87. }
  88. else if(checkText(text, "yes") && talkState[5])
  89. {
  90. talkState[1] = true;
  91. for(int8_t i = 2; i <= 12; i++)
  92. talkState[i] = false;
  93.  
  94. IOLoginData::getInstance()->setPassword(managerNumber, managerString);
  95. msg << "Your password has been changed.";
  96. }
  97. else if(checkText(text, "no") && talkState[5])
  98. {
  99. talkState[1] = true;
  100. for(int8_t i = 2; i <= 12; i++)
  101. talkState[i] = false;
  102.  
  103. msg << "Then not.";
  104. }
  105. else if(checkText(text, "character") && talkState[1])
  106. {
  107. if(account.charList.size() <= 15)
  108. {
  109. talkState[1] = false;
  110. talkState[6] = true;
  111. msg << "What would you like as your character name?";
  112. }
  113. else
  114. {
  115. talkState[1] = true;
  116. for(int8_t i = 2; i <= 12; i++)
  117. talkState[i] = false;
  118.  
  119. msg << "Your account reach the limit of 15 players, you can 'delete' a character if you want to create a new one.";
  120. }
  121. }
  122. else if(talkState[6])
  123. {
  124. managerString = text;
  125. trimString(managerString);
  126. if(managerString.length() < 4)
  127. msg << "Your name you want is too short, please select a longer name.";
  128. else if(managerString.length() > 20)
  129. msg << "The name you want is too long, please select a shorter name.";
  130. else if(!isValidName(managerString))
  131. msg << "That name seems to contain invalid symbols, please choose another name.";
  132. else if(IOLoginData::getInstance()->playerExists(managerString, true))
  133. msg << "A player with that name already exists, please choose another name.";
  134. else
  135. {
  136. std::string tmp = asLowerCaseString(managerString);
  137. if(tmp.substr(0, 4) != "god " && tmp.substr(0, 3) != "cm " && tmp.substr(0, 3) != "gm ")
  138. {
  139. talkState[6] = false;
  140. talkState[7] = true;
  141. msg << managerString << ", are you sure?";
  142. }
  143. else
  144. msg << "Your character is not a staff member, please tell me another name!";
  145. }
  146. }
  147. else if(checkText(text, "no") && talkState[7])
  148. {
  149. talkState[6] = true;
  150. talkState[7] = false;
  151. msg << "What else would you like to name your character?";
  152. }
  153. else if(checkText(text, "yes") && talkState[7])
  154. {
  155. talkState[7] = false;
  156. talkState[8] = true;
  157. msg << "Should your character be a 'male' or a 'female'.";
  158. }
  159. else if(talkState[8] && (checkText(text, "female") || checkText(text, "male")))
  160. {
  161. talkState[8] = false;
  162. talkState[9] = true;
  163. if(checkText(text, "female"))
  164. {
  165. msg << "A female, are you sure?";
  166. managerSex = PLAYERSEX_FEMALE;
  167. }
  168. else
  169. {
  170. msg << "A male, are you sure?";
  171. managerSex = PLAYERSEX_MALE;
  172. }
  173. }
  174. else if(checkText(text, "no") && talkState[9])
  175. {
  176. talkState[8] = true;
  177. talkState[9] = false;
  178. msg << "Tell me... would you like to be a 'male' or a 'female'?";
  179. }
  180. else if(checkText(text, "yes") && talkState[9])
  181. {
  182. if(g_config.getBool(ConfigManager::START_CHOOSEVOC))
  183. {
  184. talkState[9] = false;
  185. talkState[11] = true;
  186.  
  187. bool firstPart = true;
  188. for(VocationsMap::iterator it = Vocations::getInstance()->getFirstVocation(); it != Vocations::getInstance()->getLastVocation(); ++it)
  189. {
  190. if(it->first == it->second->getFromVocation() && it->first != 0)
  191. {
  192. if(firstPart)
  193. {
  194. msg << "What do you want to be... " << it->second->getDescription();
  195. firstPart = false;
  196. }
  197. else if(it->first - 1 != 0)
  198. msg << ", " << it->second->getDescription();
  199. else
  200. msg << " or " << it->second->getDescription() << ".";
  201. }
  202. }
  203. }
  204. else if(g_config.getBool(ConfigManager::START_CHOOSETOWN))
  205. {
  206. talkState[9] = false;
  207. talkState[13] = true;
  208.  
  209. bool firstPart = true;
  210. for(TownMap::const_iterator it = Towns::getInstance()->getFirstTown(); it != Towns::getInstance()->getLastTown(); ++it)
  211. {
  212. if(it->second->getID() < 100)
  213. {
  214. if(firstPart)
  215. {
  216. msg << "Where do you want to live... " << it->second->getName();
  217. firstPart = false;
  218. }
  219. else if(it->first - 1 != 0)
  220. msg << ", " << it->second->getName();
  221. else
  222. msg << " or " << it->second->getName() << ".";
  223. }
  224. }
  225. }
  226. else if(!IOLoginData::getInstance()->playerExists(managerString, true))
  227. {
  228. talkState[1] = true;
  229. for(int8_t i = 2; i <= 12; i++)
  230. talkState[i] = false;
  231.  
  232. if(IOLoginData::getInstance()->createCharacter(managerNumber, managerString, managerNumber2, (uint16_t)managerSex, managerNumber3))
  233. msg << "Your character has been created.";
  234. else
  235. msg << "Your character couldn't be created, please try again.";
  236. }
  237. else
  238. {
  239. talkState[6] = true;
  240. talkState[9] = false;
  241. msg << "A player with that name already exists, please choose another name.";
  242. }
  243. }
  244. else if(talkState[11])
  245. {
  246. for(VocationsMap::iterator it = Vocations::getInstance()->getFirstVocation(); it != Vocations::getInstance()->getLastVocation(); ++it)
  247. {
  248. std::string tmp = asLowerCaseString(it->second->getName());
  249. if(checkText(text, tmp) && it != Vocations::getInstance()->getLastVocation() && it->first == it->second->getFromVocation() && it->first != 0)
  250. {
  251. msg << "So you would like to be " << it->second->getDescription() << "... are you sure?";
  252. managerNumber2 = it->first;
  253. talkState[11] = false;
  254. talkState[12] = true;
  255. }
  256. }
  257.  
  258. if(msg.str().length() == 17)
  259. msg << "I don't understand what vocation you would like to be... could you please repeat it?";
  260. }
  261. else if(checkText(text, "yes") && talkState[12])
  262. {
  263. if(g_config.getBool(ConfigManager::START_CHOOSETOWN))
  264. {
  265. talkState[12] = false;
  266. talkState[13] = true;
  267.  
  268. bool firstPart = true;
  269. for(TownMap::const_iterator it = Towns::getInstance()->getFirstTown(); it != Towns::getInstance()->getLastTown(); ++it)
  270. {
  271. if(it->second->getID() < 100)
  272. {
  273. if(firstPart)
  274. {
  275. msg << "Where do you want to live... " << it->second->getName();
  276. firstPart = false;
  277. }
  278. else if(it->first - 1 != 0)
  279. msg << ", " << it->second->getName();
  280. else
  281. msg << " or " << it->second->getName() << ".";
  282. }
  283. }
  284. }
  285. else if(!IOLoginData::getInstance()->playerExists(managerString, true))
  286. {
  287. talkState[1] = true;
  288. for(int8_t i = 2; i <= 12; i++)
  289. talkState[i] = false;
  290.  
  291. if(IOLoginData::getInstance()->createCharacter(managerNumber, managerString, managerNumber2, (uint16_t)managerSex, managerNumber3))
  292. msg << "Your character has been created.";
  293. else
  294. msg << "Your character couldn't be created, please try again.";
  295. }
  296. else
  297. {
  298. talkState[6] = true;
  299. talkState[9] = false;
  300. msg << "A player with that name already exists, please choose another name.";
  301. }
  302. }
  303. else if(checkText(text, "no") && talkState[12])
  304. {
  305. talkState[11] = true;
  306. talkState[12] = false;
  307. msg << "No? Then what would you like to be?";
  308. }
  309. else if(talkState[13])
  310. {
  311. for(TownMap::const_iterator it = Towns::getInstance()->getFirstTown(); it != Towns::getInstance()->getLastTown(); it++)
  312. {
  313. std::string tmp = asLowerCaseString(it->second->getName());
  314. if(checkText(text, tmp) && it != Towns::getInstance()->getLastTown() && it->second->getID() < 100)
  315. {
  316. msg << "So do you want to live in " << it->second->getName() << ".. are you sure?";
  317. managerNumber3 = it->first;
  318. talkState[13] = false;
  319. talkState[14] = true;
  320. }
  321. }
  322.  
  323. if(msg.str().length() == 17)
  324. msg << "I don't understand where you would like to live... could you please repeat it?";
  325. }
  326. else if(checkText(text, "yes") && talkState[14])
  327. {
  328. if(!IOLoginData::getInstance()->playerExists(managerString, true))
  329. {
  330. talkState[1] = true;
  331. for(int8_t i = 2; i <= 14; i++)
  332. talkState[i] = false;
  333.  
  334. if(IOLoginData::getInstance()->createCharacter(managerNumber, managerString, managerNumber2, (uint16_t)managerSex, managerNumber3))
  335. msg << "Your character has been created.";
  336. else
  337. msg << "Your character couldn't be created, please try again.";
  338. }
  339. else
  340. {
  341. talkState[6] = true;
  342. talkState[9] = false;
  343. msg << "A player with that name already exists, please choose another name.";
  344. }
  345. }
  346. else if(checkText(text, "no") && talkState[14])
  347. {
  348. talkState[13] = true;
  349. talkState[14] = false;
  350. msg << "So where do you want to live?";
  351. }
  352. else if(checkText(text, "recovery key") && talkState[1])
  353. {
  354. talkState[1] = false;
  355. talkState[10] = true;
  356. msg << "Would you like a recovery key?";
  357. }
  358. else if(checkText(text, "yes") && talkState[10])
  359. {
  360. if(account.recoveryKey != "0")
  361. msg << "Sorry, you already have a recovery key, for security reasons I may not give you a new one.";
  362. else
  363. {
  364. managerString = generateRecoveryKey(4, 4);
  365. IOLoginData::getInstance()->setRecoveryKey(managerNumber, managerString);
  366. msg << "Your recovery key is: " << managerString << ".";
  367. }
  368.  
  369. talkState[1] = true;
  370. for(int8_t i = 2; i <= 12; i++)
  371. talkState[i] = false;
  372. }
  373. else if(checkText(text, "no") && talkState[10])
  374. {
  375. msg << "Then not.";
  376. talkState[1] = true;
  377. for(int8_t i = 2; i <= 12; i++)
  378. talkState[i] = false;
  379. }
  380. else
  381. msg << "Please read the latest message that I have specified, I don't understand the current requested action.";
  382.  
  383. break;
  384. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement