void AccountAvailableState::runCommand(const std::string &command, const std::string &args) { if (CreateAcc == command) { Tokeniser tokeniser = Tokeniser(); tokeniser.initTokens(args); std::string uname = tokeniser.nextToken(); std::string password = tokeniser.nextToken(); std::string realname = tokeniser.remainingTokens(); std::string msg; msg = "Creating account: Name: [" + uname + "], Password: [" + password + "], Real Name: [" + realname + "]"; try { mAccount.createAccount(uname, realname, password); } catch (const std::exception& except) { S_LOG_WARNING("Got error on account creation." << except); return; } catch (...) { S_LOG_WARNING("Got unknown error on account creation."); return; } } else if (Login == command) { // Split string into userid / password pair Tokeniser tokeniser = Tokeniser(); tokeniser.initTokens(args); std::string userid = tokeniser.nextToken(); std::string password = tokeniser.remainingTokens(); mAccount.login(userid, password); std::string msg; msg = "Login: [" + userid + "," + password + "]"; ConsoleBackend::getSingleton().pushMessage(msg, "info"); } }
void LoggedInState::runCommand(const std::string &command, const std::string &args) { if (Logout == command) { ConsoleBackend::getSingleton().pushMessage("Logging out...", "important"); mAccount.logout(); // Create Character command } else if (CreateChar == command) { // Split string into name/type/sex/description Tokeniser tokeniser = Tokeniser(); tokeniser.initTokens(args); std::string name = tokeniser.nextToken(); std::string sex = tokeniser.nextToken(); std::string type = tokeniser.nextToken(); std::string spawnPoint = tokeniser.nextToken(); std::string description = tokeniser.remainingTokens(); createCharacter(name, sex, type, description, spawnPoint, Atlas::Message::MapType()); // Take Character Command } else if (TakeChar == command) { takeCharacter(args); // List Characters Command } else if (ListChars == command) { mAccount.refreshCharacterInfo(); // Say (In-Game chat) Command } }
void NonConnectedState::runCommand(const std::string &command, const std::string &args) { // Connect command if (Connect == command) { // Split string into server / port pair Tokeniser tokeniser = Tokeniser(); tokeniser.initTokens(args); std::string server = tokeniser.nextToken(); std::string port = tokeniser.remainingTokens(); std::string msg; msg = "Connecting to: [" + server + "]"; ConsoleBackend::getSingleton().pushMessage(msg, "info"); if (port == "") connect(server); else connect(server, (short)atoi(port.c_str())); // Disonnect command } }