void Player::updateNameAndDescriptions() const { if (updateNameAndDescr == true) { updateNameAndDescr = false; if (Class()->getFullName(*this, name) == false && name.empty() == true) { name = SimpleName(); } for (size_t i = 0; i < descriptions.size(); i++) { Class()->getDescription(i, *this, descriptions[i]); } } }
bool Player::getProperty(const std::string_view prop, Variable& var) const { if (prop.empty() == true) { return false; } auto props = Utils::splitStringIn2(prop, '.'); auto propHash = str2int16(props.first); if (getLevelObjProp(propHash, props.second, var) == true) { return true; } switch (propHash) { case str2int16("name"): var = Variable(Name()); break; case str2int16("simpleName"): var = Variable(SimpleName()); break; case str2int16("d"): case str2int16("description"): { updateNameAndDescriptions(); size_t idx = Utils::strtou(props.second); if (idx >= descriptions.size()) { idx = 0; } var = Variable(descriptions[idx]); break; } case str2int16("eval"): var = Variable((int64_t)Formula::evalString(props.second, *this)); break; case str2int16("evalMin"): var = Variable((int64_t)Formula::evalMinString(props.second, *this)); break; case str2int16("evalMax"): var = Variable((int64_t)Formula::evalMaxString(props.second, *this)); break; case str2int16("evalf"): var = Variable(Formula::evalString(props.second, *this)); break; case str2int16("evalMinf"): var = Variable(Formula::evalMinString(props.second, *this)); break; case str2int16("evalMaxf"): var = Variable(Formula::evalMaxString(props.second, *this)); break; case str2int16("totalKills"): var = Variable((int64_t)Class()->TotalKills()); break; case str2int16("hasMaxStats"): var = Variable(hasMaxStats()); break; case str2int16("hasProperty"): var = Variable(hasInt(props.second)); break; case str2int16("canUseSelectedItem"): { if (selectedItem == nullptr) { return false; } var = Variable(canUseObject(*selectedItem)); break; } case str2int16("canUseSelectedSpell"): { if (selectedSpell == nullptr) { return false; } var = Variable(canUseObject(*selectedSpell->spell)); break; } case str2int16("canUseItem"): { std::string_view props2; size_t invIdx; size_t itemIdx; if (inventories.parseInventoryAndItem( props.second, props2, invIdx, itemIdx) == true) { auto item = inventories[invIdx].get(itemIdx); if (item != nullptr) { var = Variable(canUseObject(*item)); break; } } return false; } case str2int16("hasEquipedItemType"): var = Variable(hasEquipedItemType(props.second)); break; case str2int16("hasEquipedItemSubType"): var = Variable(hasEquipedItemSubType(props.second)); break; case str2int16("hasSelectedItem"): var = Variable(selectedItem != nullptr); break; case str2int16("hasItem"): { std::string_view props2; size_t invIdx; size_t itemIdx; if (inventories.parseInventoryAndItem( props.second, props2, invIdx, itemIdx) == true) { var = Variable(inventories[invIdx].get(itemIdx) != nullptr); break; } return false; } case str2int16("hasItemClass"): var = Variable(inventories.hasItem(str2int16(props.second))); break; case str2int16("hasSpell"): { var = Variable(getSpell(std::string(props.second)) != nullptr); break; } case str2int16("hasSelectedSpell"): { var = Variable(selectedSpell != nullptr); break; } case str2int16("isItemSlotInUse"): { std::string_view props2; size_t invIdx; size_t itemIdx; if (inventories.parseInventoryAndItem( props.second, props2, invIdx, itemIdx) == true) { var = Variable(inventories[invIdx].isSlotInUse(itemIdx)); break; } return false; } case str2int16("isStanding"): var = Variable(playerStatus == PlayerStatus::Stand); break; case str2int16("isWalking"): var = Variable(playerStatus == PlayerStatus::Walk); break; case str2int16("isAttacking"): var = Variable(playerStatus == PlayerStatus::Attack); break; case str2int16("isDead"): var = Variable(playerStatus == PlayerStatus::Dead); break; case str2int16("selectedItem"): { if (selectedItem != nullptr) { return selectedItem->getProperty(props.second, var); } return false; } case str2int16("item"): { std::string_view props2; size_t invIdx; size_t itemIdx; if (inventories.parseInventoryAndItem( props.second, props2, invIdx, itemIdx) == true) { auto item = inventories[invIdx].get(itemIdx); if (item != nullptr) { return item->getProperty(props2, var); } } return false; } case str2int16("inventory"): { auto props2 = Utils::splitStringIn2(props.second, '.'); auto invIdx = GameUtils::getPlayerInventoryIndex(props2.first); if (invIdx < inventories.size()) { return inventories[invIdx].getProperty(props2.second, var); } return false; } case str2int16("itemQuantity"): { auto classIdHash16 = str2int16(props.second); uint32_t itemQuantity = 0; if (itemQuantityCache.getValue(classIdHash16, itemQuantity) == false) { if (inventories.getQuantity(classIdHash16, itemQuantity) == true) { itemQuantityCache.updateValue(classIdHash16, itemQuantity); } } var = Variable((int64_t)itemQuantity); break; } case str2int16("selectedSpell"): { if (selectedSpell != nullptr) { return selectedSpell->getProperty(props.second, var); } return false; } case str2int16("spell"): { auto props2 = Utils::splitStringIn2(props.second, '.'); auto spell = getSpellInstance(std::string(props2.first)); if (spell != nullptr) { return spell->getProperty(props2.second, var); } return false; } default: { Number32 value; if (getNumberByHash(propHash, props.second, value) == true) { var = Variable(value.getInt64()); break; } return false; } } return true; }
virtual SimpleName name () const { return SimpleName (""); }