findGBP
This commit is contained in:
parent
2349e5a602
commit
b2fa6f9b97
Binary file not shown.
@ -12,6 +12,7 @@ std::string genericResponse();
|
|||||||
std::string helpMessage();
|
std::string helpMessage();
|
||||||
std::string findNum(int pos);
|
std::string findNum(int pos);
|
||||||
std::string findName(std::string user);
|
std::string findName(std::string user);
|
||||||
|
std::string findGBP(int gbpinp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ##commandParse
|
* ##commandParse
|
||||||
@ -35,17 +36,14 @@ std::string commandParse(std::vector<std::string> args)
|
|||||||
} else if (args[0] == "findpos" ) {
|
} else if (args[0] == "findpos" ) {
|
||||||
if (args.size() >= 2)
|
if (args.size() >= 2)
|
||||||
return findNum(std::stoi(args[1]));
|
return findNum(std::stoi(args[1]));
|
||||||
else
|
|
||||||
return "Invalid command!";
|
|
||||||
} else if (args[0] == "findname") {
|
} else if (args[0] == "findname") {
|
||||||
if (args.size() >= 2)
|
if (args.size() >= 2)
|
||||||
return findName(args[1]);
|
return findName(args[1]);
|
||||||
else
|
} else if (args[0] == "findgbp") {
|
||||||
return "Invalid command!";
|
if (args.size() >= 2)
|
||||||
|
return findGBP(std::stoi(args[1]));
|
||||||
} else {
|
|
||||||
return "Invalid command!";
|
|
||||||
}
|
}
|
||||||
|
return "Invalid command!";
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FILE_NAME "temp-GBP"
|
#define FILE_NAME "temp-GBP"
|
||||||
@ -98,6 +96,19 @@ std::string findName(std::string user)
|
|||||||
return "User not found!";
|
return "User not found!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string findGBP(int gbpinp)
|
||||||
|
{
|
||||||
|
std::string out = "";
|
||||||
|
std::map<unsigned short int, std::pair<int, std::string>> gbp = readGBPIntoList();
|
||||||
|
for (std::map<unsigned short int, std::pair<int, std::string>>::iterator it = gbp.begin(); it != gbp.end(); it++)
|
||||||
|
if (it->second.first == gbpinp)
|
||||||
|
out += "#" + std::to_string(it->first) + ": " + it->second.second + " (" + std::to_string(it->second.first) + " GBP)\n";
|
||||||
|
|
||||||
|
if (out == "")
|
||||||
|
return "No users found with that GBP!";
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ##genericResponse
|
* ##genericResponse
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user