Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <fstream>
- #include <algorithm>
- #include <map>
- #include "Character.h"
- void Home(Character& newplayer);
- void CommandList (Character& newplayer, std::string userInput);
- int main()
- {
- Character newplayer;
- Home(newplayer);
- return 0;
- }
- void Home (Character& newplayer)
- {
- std::cout << "-->> ";
- std::string userInput;
- std::cin.clear();
- getline(std::cin, userInput);
- CommandList(newplayer, userInput);
- }
- void CommandList (Character& newplayer, std::string userInput)
- {
- if (!userInput.compare("register"))
- {
- std::cout << "What is your desired player name?: ";
- std::string pname;
- std::cin.clear();
- getline(std::cin, pname);
- if (newplayer.CheckPlayer(pname))
- {
- std::cout << "That player name already exists. Try another one." << std::endl;
- }
- else
- {
- std::cout << "Now, choose a memorable password: ";
- std::string ppass;
- std::cin.clear();
- getline(std::cin, ppass);
- newplayer.CreatePlayer(pname, ppass);
- }
- }
- else if (!userInput.compare("login"))
- {
- std::cout << "Player Name: ";
- std::string pname;
- std::cin.clear();
- getline(std::cin, pname);
- if (!newplayer.CheckPlayer(pname))
- {
- std::cout << "That player name has not been registered." << std::endl;
- }
- else
- {
- std::cout << "Player Password: ";
- std::string ppass;
- std::cin.clear();
- getline(std::cin, ppass);
- newplayer.LoadPlayer(pname, ppass);
- }
- }
- else if (!userInput.compare("stats"))
- {
- // How do I know which vector index to call for said player now?
- // Don't want to keep prompting the player to enter their name here to find their stats in that vector.
- // I have not yet changed the pass string in the Character class to a vector yet, but I hope you get the idea.
- // Both vectors name and pass will have the same index for that player.
- // Ex: newplayer.name[0] = "Allura". newplayer.pass[0] = "Hairycoconut". newplayer.name[1] = "Bob". newplayer.pass[1] = "Bobsucks".
- }
- else
- {
- std::cout << "You have entered an unrecognised command." << std::endl;
- }
- Home(newplayer);
- }
Advertisement
Add Comment
Please, Sign In to add comment