Add reward tables for racing

This commit is contained in:
Gent S 2020-12-21 23:55:43 -05:00
parent b9013149f3
commit e953b51229
5 changed files with 52 additions and 5 deletions

View File

@ -971,7 +971,7 @@ int ItemManager::getCrateItem(sItemBase& result, int itemSetId, int rarity, int
std::pair key = std::make_pair(itemSetId, rarity); std::pair key = std::make_pair(itemSetId, rarity);
if (CrateItems.find(key) == CrateItems.end()) { if (CrateItems.find(key) == CrateItems.end()) {
std::cout << "[WARN] Item Set ID " << itemSetId << " Rarity " << rarity << " items have not been found" << std::endl; std::cout << "[WARN] Item Set ID " << itemSetId << " Rarity " << rarity << " does not exist" << std::endl;
return -1; return -1;
} }
@ -986,8 +986,7 @@ int ItemManager::getCrateItem(sItemBase& result, int itemSetId, int rarity, int
} }
if (items.size() == 0) { if (items.size() == 0) {
std::cout << "[WARN] Gender inequality! Set ID " << itemSetId << " Rarity " << rarity << " contains only " std::cout << "[WARN] Set ID " << itemSetId << " Rarity " << rarity << " contains no valid items" << std::endl;
<< (playerGender == 2 ? "boys" : "girls") << " items?!" << std::endl;
return -1; return -1;
} }

View File

@ -9,6 +9,7 @@
std::map<int32_t, EPInfo> RacingManager::EPData; std::map<int32_t, EPInfo> RacingManager::EPData;
std::map<CNSocket*, EPRace> RacingManager::EPRaces; std::map<CNSocket*, EPRace> RacingManager::EPRaces;
std::map<int32_t, std::pair<std::vector<int>, std::vector<int>>> RacingManager::EPRewards;
void RacingManager::init() { void RacingManager::init() {
REGISTER_SHARD_PACKET(P_CL2FE_REQ_EP_RACE_START, racingStart); REGISTER_SHARD_PACKET(P_CL2FE_REQ_EP_RACE_START, racingStart);

View File

@ -3,7 +3,7 @@
#include "CNShardServer.hpp" #include "CNShardServer.hpp"
struct EPInfo { struct EPInfo {
int zoneX, zoneY, EPID, maxScore; int zoneX, zoneY, EPID, maxScore, maxTime;
}; };
struct EPRace { struct EPRace {
@ -15,6 +15,7 @@ namespace RacingManager {
extern std::map<int32_t, EPInfo> EPData; extern std::map<int32_t, EPInfo> EPData;
extern std::map<CNSocket*, EPRace> EPRaces; extern std::map<CNSocket*, EPRace> EPRaces;
extern std::map<int32_t, std::pair<std::vector<int>, std::vector<int>>> EPRewards;
void init(); void init();

View File

@ -539,6 +539,52 @@ void TableData::loadDrops() {
std::cout << "[INFO] Loaded " << ItemManager::Crates.size() << " Crates containing " std::cout << "[INFO] Loaded " << ItemManager::Crates.size() << " Crates containing "
<< itemCount << " items" << std::endl; << itemCount << " items" << std::endl;
// Racing rewards
nlohmann::json racing = dropData["Racing"];
for (nlohmann::json::iterator _race = racing.begin(); _race != racing.end(); _race++) {
auto race = _race.value();
int raceEPID = race["EPID"];
// find the instance data corresponding to the EPID
int EPMap = -1;
for (auto& it = RacingManager::EPData.begin(); it != RacingManager::EPData.end(); it++) {
if (it->second.EPID == raceEPID) {
EPMap = it->first;
}
}
if (EPMap == -1) { // not found
char buff[255];
sprintf(buff, "EP with ID %d not found", raceEPID);
throw TableException(std::string(buff));
}
// time limit isn't stored in the XDT, so we include it in the reward table instead
RacingManager::EPData[EPMap].maxTime = race["TimeLimit"];
// score cutoffs
std::vector<int> rankScores;
for (nlohmann::json::iterator _rankScore = race["RankScores"].begin(); _rankScore != race["RankScores"].end(); _rankScore++) {
rankScores.push_back((int)_rankScore.value());
}
// reward IDs for each rank
std::vector<int> rankRewards;
for (nlohmann::json::iterator _rankReward = race["Rewards"].begin(); _rankReward != race["Rewards"].end(); _rankReward++) {
rankRewards.push_back((int)_rankReward.value());
}
if (rankScores.size() != 5 || rankScores.size() != rankRewards.size()) {
char buff[255];
sprintf(buff, "Race in EP %d doesn't have exactly 5 score/reward pairs", raceEPID);
throw TableException(std::string(buff));
}
RacingManager::EPRewards[raceEPID] = std::make_pair(rankScores, rankRewards);
}
std::cout << "[INFO] Loaded rewards for " << RacingManager::EPRewards.size() << " IZ races" << std::endl;
} }
catch (const std::exception& err) { catch (const std::exception& err) {
std::cerr << "[FATAL] Malformed drops.json file! Reason:" << err.what() << std::endl; std::cerr << "[FATAL] Malformed drops.json file! Reason:" << err.what() << std::endl;

2
tdata

@ -1 +1 @@
Subproject commit 75d82f3155687d73ad72cfc479d2c2c7c3ecd20f Subproject commit 9650bb3abbf55e77f9b7b10b93a4957757e93cd7