Guest User

Main()

a guest
Nov 24th, 2016
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <fstream>
  4. #include <algorithm>
  5. #include <map>
  6. #include "Character.h"
  7.  
  8. void Home(Character& newplayer);
  9. void CommandList (Character& newplayer, std::string userInput);
  10.  
  11. int main()
  12. {
  13. Character newplayer;
  14.  
  15. Home(newplayer);
  16.  
  17. return 0;
  18. }
  19.  
  20. void Home (Character& newplayer)
  21. {
  22. std::cout << "-->> ";
  23. std::string userInput;
  24. std::cin.clear();
  25. getline(std::cin, userInput);
  26. CommandList(newplayer, userInput);
  27. }
  28.  
  29. void CommandList (Character& newplayer, std::string userInput)
  30. {
  31. if (!userInput.compare("register"))
  32. {
  33. std::cout << "What is your desired player name?: ";
  34. std::string pname;
  35. std::cin.clear();
  36. getline(std::cin, pname);
  37.  
  38. if (newplayer.CheckPlayer(pname))
  39. {
  40. std::cout << "That player name already exists. Try another one." << std::endl;
  41. }
  42. else
  43. {
  44. std::cout << "Now, choose a memorable password: ";
  45. std::string ppass;
  46. std::cin.clear();
  47. getline(std::cin, ppass);
  48.  
  49. newplayer.CreatePlayer(pname, ppass);
  50. }
  51. }
  52. else if (!userInput.compare("login"))
  53. {
  54. std::cout << "Player Name: ";
  55. std::string pname;
  56. std::cin.clear();
  57. getline(std::cin, pname);
  58.  
  59. if (!newplayer.CheckPlayer(pname))
  60. {
  61. std::cout << "That player name has not been registered." << std::endl;
  62. }
  63. else
  64. {
  65. std::cout << "Player Password: ";
  66. std::string ppass;
  67. std::cin.clear();
  68. getline(std::cin, ppass);
  69.  
  70. newplayer.LoadPlayer(pname, ppass);
  71. }
  72. }
  73. else if (!userInput.compare("stats"))
  74. {
  75. // How do I know which vector index to call for said player now?
  76. // Don't want to keep prompting the player to enter their name here to find their stats in that vector.
  77. // I have not yet changed the pass string in the Character class to a vector yet, but I hope you get the idea.
  78. // Both vectors name and pass will have the same index for that player.
  79. // Ex: newplayer.name[0] = "Allura". newplayer.pass[0] = "Hairycoconut". newplayer.name[1] = "Bob". newplayer.pass[1] = "Bobsucks".
  80. }
  81. else
  82. {
  83. std::cout << "You have entered an unrecognised command." << std::endl;
  84. }
  85. Home(newplayer);
  86. }
Advertisement
Add Comment
Please, Sign In to add comment