double Yield::gatherMean(const ServerItem *item) const { auto it = _entries.find(item); if (it == _entries.end()) { SERVER_ERROR("Object doesn't yield that item"); return 0; } return it->second._gatherMean; }
Permissions::Usernames Permissions::ownerAsUsernames() { const Server &server = Server::instance(); switch (_owner.type) { case Owner::NONE: return {}; case Owner::PLAYER: return {_owner.name}; case Owner::CITY: return server.cities().membersOf(_owner.name); default: SERVER_ERROR("Trying to fetch owning users when owner has no type"); return {}; } }
void Class::takeTalent(const Talent *talent) { ++_talentPointsAllocated; if (_talentRanks.find(talent) == _talentRanks.end()) { _talentRanks[talent] = 1; } else { if (talent->type() != Talent::STATS && _talentRanks[talent] > 0) { SERVER_ERROR("Can't take a second rank of a non-stats talent"); return; } ++_talentRanks[talent]; } _owner->sendMessage(SV_TALENT, makeArgs(talent->name(), _talentRanks[talent])); _owner->sendMessage(SV_POINTS_IN_TREE, makeArgs(talent->tree(), pointsInTree(talent->tree()))); }
bool Permissions::doesUserHaveAccess(const std::string &username) const { switch (_owner.type) { case Owner::NONE: return true; case Owner::PLAYER: return _owner.name == username; case Owner::CITY: { const Cities &cities = Server::instance()._cities; const std::string &playerCity = cities.getPlayerCity(username); return playerCity == _owner.name; } default: SERVER_ERROR("Checking permission when owner has no type"); return false; } }