本文整理汇总了C++中Vocations::getVocationId方法的典型用法代码示例。如果您正苦于以下问题:C++ Vocations::getVocationId方法的具体用法?C++ Vocations::getVocationId怎么用?C++ Vocations::getVocationId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vocations
的用法示例。
在下文中一共展示了Vocations::getVocationId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: configureEvent
bool Weapon::configureEvent(const pugi::xml_node& node)
{
pugi::xml_attribute attr;
if (!(attr = node.attribute("id"))) {
std::cout << "[Error - Weapon::configureEvent] Weapon without id." << std::endl;
return false;
}
id = pugi::cast<uint16_t>(attr.value());
if ((attr = node.attribute("level"))) {
level = pugi::cast<uint32_t>(attr.value());
}
if ((attr = node.attribute("maglv")) || (attr = node.attribute("maglevel"))) {
magLevel = pugi::cast<uint32_t>(attr.value());
}
if ((attr = node.attribute("mana"))) {
mana = pugi::cast<uint32_t>(attr.value());
}
if ((attr = node.attribute("manapercent"))) {
manaPercent = pugi::cast<uint32_t>(attr.value());
}
if ((attr = node.attribute("soul"))) {
soul = pugi::cast<uint32_t>(attr.value());
}
if ((attr = node.attribute("prem"))) {
premium = attr.as_bool();
}
if ((attr = node.attribute("breakchance"))) {
breakChance = std::min<uint8_t>(100, pugi::cast<uint16_t>(attr.value()));
}
if ((attr = node.attribute("action"))) {
action = getWeaponAction(attr.as_string());
if (action == WEAPONACTION_NONE) {
std::cout << "[Warning - Weapon::configureEvent] Unknown action " << attr.as_string() << std::endl;
}
}
if ((attr = node.attribute("enabled"))) {
enabled = attr.as_bool();
}
if ((attr = node.attribute("unproperly"))) {
wieldUnproperly = attr.as_bool();
}
std::list<std::string> vocStringList;
for (pugi::xml_node vocationNode = node.first_child(); vocationNode; vocationNode = vocationNode.next_sibling()) {
if (!(attr = vocationNode.attribute("name"))) {
continue;
}
int32_t vocationId = g_vocations.getVocationId(attr.as_string());
if (vocationId != -1) {
vocWeaponMap[vocationId] = true;
int32_t promotedVocation = g_vocations.getPromotedVocation(vocationId);
if (promotedVocation != 0) {
vocWeaponMap[promotedVocation] = true;
}
if (vocationNode.attribute("showInDescription").as_bool(true)) {
vocStringList.push_back(asLowerCaseString(attr.as_string()));
}
}
}
range = Item::items[id].shootRange;
std::string vocationString;
for (const std::string& str : vocStringList) {
if (!vocationString.empty()) {
if (str != vocStringList.back()) {
vocationString.push_back(',');
vocationString.push_back(' ');
} else {
vocationString += " and ";
}
}
vocationString += str;
vocationString.push_back('s');
}
uint32_t wieldInfo = 0;
if (getReqLevel() > 0) {
wieldInfo |= WIELDINFO_LEVEL;
}
if (getReqMagLv() > 0) {
wieldInfo |= WIELDINFO_MAGLV;
}
if (!vocationString.empty()) {
wieldInfo |= WIELDINFO_VOCREQ;
}
//.........这里部分代码省略.........
示例2: configureEvent
bool MoveEvent::configureEvent(xmlNodePtr p)
{
std::string str;
int intValue;
if(readXMLString(p, "event", str)){
if(asLowerCaseString(str) == "stepin"){
m_eventType = MOVE_EVENT_STEP_IN;
}
else if(asLowerCaseString(str) == "stepout"){
m_eventType = MOVE_EVENT_STEP_OUT;
}
else if(asLowerCaseString(str) == "equip"){
m_eventType = MOVE_EVENT_EQUIP;
}
else if(asLowerCaseString(str) == "deequip"){
m_eventType = MOVE_EVENT_DEEQUIP;
}
else if(asLowerCaseString(str) == "additem"){
m_eventType = MOVE_EVENT_ADD_ITEM;
}
else if(asLowerCaseString(str) == "removeitem"){
m_eventType = MOVE_EVENT_REMOVE_ITEM;
}
else{
std::cout << "Error: [MoveEvent::configureMoveEvent] No valid event name " << str << std::endl;
return false;
}
if(m_eventType == MOVE_EVENT_EQUIP || m_eventType == MOVE_EVENT_DEEQUIP){
if(readXMLString(p, "slot", str)){
if(asLowerCaseString(str) == "head"){
slot = SLOT_HEAD;
}
else if(asLowerCaseString(str) == "necklace"){
slot = SLOT_NECKLACE;
}
else if(asLowerCaseString(str) == "backpack"){
slot = SLOT_BACKPACK;
}
else if(asLowerCaseString(str) == "armor"){
slot = SLOT_ARMOR;
}
else if(asLowerCaseString(str) == "right-hand"){
slot = SLOT_RIGHT;
}
else if(asLowerCaseString(str) == "left-hand"){
slot = SLOT_LEFT;
}
else if(asLowerCaseString(str) == "legs"){
slot = SLOT_LEGS;
}
else if(asLowerCaseString(str) == "feet"){
slot = SLOT_FEET;
}
else if(asLowerCaseString(str) == "ring"){
slot = SLOT_RING;
}
else if(asLowerCaseString(str) == "ammo"){
slot = SLOT_AMMO;
}
else{
std::cout << "Warning: [MoveEvent::configureMoveEvent] " << "Unknown slot type " << str << std::endl;
}
}
wieldInfo = 0;
if(readXMLInteger(p, "lvl", intValue) || readXMLInteger(p, "level", intValue)){
reqLevel = intValue;
if(reqLevel > 0){
wieldInfo |= WIELDINFO_LEVEL;
}
}
if(readXMLInteger(p, "maglv", intValue) || readXMLInteger(p, "maglevel", intValue)){
reqMagLevel = intValue;
if(reqMagLevel > 0){
wieldInfo |= WIELDINFO_MAGLV;
}
}
if(readXMLInteger(p, "prem", intValue) || readXMLInteger(p, "premium", intValue)){
premium = (intValue != 0);
if(premium){
wieldInfo |= WIELDINFO_PREMIUM;
}
}
//Gather vocation information
typedef std::list<std::string> STRING_LIST;
STRING_LIST vocStringList;
xmlNodePtr vocationNode = p->children;
while(vocationNode){
if(xmlStrcmp(vocationNode->name,(const xmlChar*)"vocation") == 0){
if(readXMLString(vocationNode, "name", str)){
int32_t vocationId = g_vocations.getVocationId(str);
if(vocationId != -1){
vocEquipMap[vocationId] = true;
intValue = 1;
readXMLInteger(vocationNode, "showInDescription", intValue);
if(intValue != 0){
toLowerCaseString(str);
//.........这里部分代码省略.........
示例3: configureEvent
bool Weapon::configureEvent(xmlNodePtr p)
{
int32_t intValue;
std::string strValue;
if (readXMLInteger(p, "id", intValue)) {
id = intValue;
} else {
std::cout << "Error: [Weapon::configureEvent] Weapon without id." << std::endl;
return false;
}
if (readXMLInteger(p, "lvl", intValue) || readXMLInteger(p, "level", intValue)) {
level = intValue;
}
if (readXMLInteger(p, "maglv", intValue) || readXMLInteger(p, "maglevel", intValue)) {
magLevel = intValue;
}
if (readXMLInteger(p, "mana", intValue)) {
mana = intValue;
}
if (readXMLInteger(p, "manapercent", intValue)) {
manaPercent = intValue;
}
if (readXMLInteger(p, "soul", intValue)) {
soul = intValue;
}
if (readXMLInteger(p, "exhaustion", intValue)) {
exhaustion = intValue;
}
if (readXMLInteger(p, "prem", intValue)) {
premium = (intValue == 1);
}
if (readXMLInteger(p, "enabled", intValue)) {
enabled = (intValue == 1);
}
if (readXMLInteger(p, "unproperly", intValue)) {
wieldUnproperly = (intValue == 1);
}
if (readXMLString(p, "ammo", strValue)) {
std::cout << "Warning: ammo is not longer used in weapons.xml." << std::endl;
}
typedef std::list<std::string> STRING_LIST;
STRING_LIST vocStringList;
xmlNodePtr vocationNode = p->children;
while (vocationNode) {
if (xmlStrcmp(vocationNode->name, (const xmlChar*)"vocation") == 0) {
if (readXMLString(vocationNode, "name", strValue)) {
int32_t vocationId = g_vocations.getVocationId(strValue);
if (vocationId != -1) {
vocWeaponMap[vocationId] = true;
int32_t promotedVocation = g_vocations.getPromotedVocation(vocationId);
if (promotedVocation != 0) {
vocWeaponMap[promotedVocation] = true;
}
readXMLInteger(vocationNode, "showInDescription", intValue);
if (intValue != 0) {
toLowerCaseString(strValue);
vocStringList.push_back(strValue);
}
}
}
}
vocationNode = vocationNode->next;
}
range = Item::items[id].shootRange;
std::string vocationString;
if (!vocStringList.empty()) {
for (STRING_LIST::iterator it = vocStringList.begin(); it != vocStringList.end(); ++it) {
if (*it != vocStringList.front()) {
if (*it != vocStringList.back()) {
vocationString += ", ";
} else {
vocationString += " and ";
}
}
vocationString += *it;
vocationString += "s";
}
}
//.........这里部分代码省略.........
示例4: configureSpell
//.........这里部分代码省略.........
}
if ((attr = node.attribute("secondarygroupcooldown"))) {
secondaryGroupCooldown = pugi::cast<uint32_t>(attr.value());
}
if ((attr = node.attribute("level")) || (attr = node.attribute("lvl"))) {
level = pugi::cast<uint32_t>(attr.value());
}
if ((attr = node.attribute("magiclevel")) || (attr = node.attribute("maglv"))) {
magLevel = pugi::cast<uint32_t>(attr.value());
}
if ((attr = node.attribute("mana"))) {
mana = pugi::cast<uint32_t>(attr.value());
}
if ((attr = node.attribute("manapercent"))) {
manaPercent = pugi::cast<uint32_t>(attr.value());
}
if ((attr = node.attribute("soul"))) {
soul = pugi::cast<uint32_t>(attr.value());
}
if ((attr = node.attribute("range"))) {
range = pugi::cast<int32_t>(attr.value());
}
if ((attr = node.attribute("cooldown")) || (attr = node.attribute("exhaustion"))) {
cooldown = pugi::cast<uint32_t>(attr.value());
}
if ((attr = node.attribute("premium")) || (attr = node.attribute("prem"))) {
premium = attr.as_bool();
}
if ((attr = node.attribute("enabled"))) {
enabled = attr.as_bool();
}
if ((attr = node.attribute("needtarget"))) {
needTarget = attr.as_bool();
}
if ((attr = node.attribute("needweapon"))) {
needWeapon = attr.as_bool();
}
if ((attr = node.attribute("selftarget"))) {
selfTarget = attr.as_bool();
}
if ((attr = node.attribute("needlearn"))) {
learnable = attr.as_bool();
}
if ((attr = node.attribute("blocking"))) {
blockingSolid = attr.as_bool();
blockingCreature = blockingSolid;
}
if ((attr = node.attribute("blocktype"))) {
std::string tmpStrValue = asLowerCaseString(attr.as_string());
if (tmpStrValue == "all") {
blockingSolid = true;
blockingCreature = true;
} else if (tmpStrValue == "solid") {
blockingSolid = true;
} else if (tmpStrValue == "creature") {
blockingCreature = true;
} else {
std::cout << "[Warning - Spell::configureSpell] Blocktype \"" << attr.as_string() << "\" does not exist." << std::endl;
}
}
if ((attr = node.attribute("aggressive"))) {
aggressive = booleanString(attr.as_string());
}
if (group == SPELLGROUP_NONE) {
group = (aggressive ? SPELLGROUP_ATTACK : SPELLGROUP_HEALING);
}
for (auto vocationNode : node.children()) {
if (!(attr = vocationNode.attribute("name"))) {
continue;
}
int32_t vocationId = g_vocations.getVocationId(attr.as_string());
if (vocationId != -1) {
attr = vocationNode.attribute("showInDescription");
vocSpellMap[vocationId] = !attr || attr.as_bool();
} else {
std::cout << "[Warning - Spell::configureSpell] Wrong vocation name: " << attr.as_string() << std::endl;
}
}
return true;
}
示例5: configureEvent
bool MoveEvent::configureEvent(const pugi::xml_node& node)
{
pugi::xml_attribute eventAttr = node.attribute("event");
if (!eventAttr) {
std::cout << "[Error - MoveEvent::configureMoveEvent] Missing event" << std::endl;
return false;
}
std::string tmpStr = asLowerCaseString(eventAttr.as_string());
if (tmpStr == "stepin") {
m_eventType = MOVE_EVENT_STEP_IN;
} else if (tmpStr == "stepout") {
m_eventType = MOVE_EVENT_STEP_OUT;
} else if (tmpStr == "equip") {
m_eventType = MOVE_EVENT_EQUIP;
} else if (tmpStr == "deequip") {
m_eventType = MOVE_EVENT_DEEQUIP;
} else if (tmpStr == "additem") {
m_eventType = MOVE_EVENT_ADD_ITEM;
} else if (tmpStr == "removeitem") {
m_eventType = MOVE_EVENT_REMOVE_ITEM;
} else {
std::cout << "Error: [MoveEvent::configureMoveEvent] No valid event name " << eventAttr.as_string() << std::endl;
return false;
}
if (m_eventType == MOVE_EVENT_EQUIP || m_eventType == MOVE_EVENT_DEEQUIP) {
pugi::xml_attribute slotAttribute = node.attribute("slot");
if (slotAttribute) {
tmpStr = asLowerCaseString(slotAttribute.as_string());
if (tmpStr == "head") {
slot = SLOTP_HEAD;
} else if (tmpStr == "necklace") {
slot = SLOTP_NECKLACE;
} else if (tmpStr == "backpack") {
slot = SLOTP_BACKPACK;
} else if (tmpStr == "armor") {
slot = SLOTP_ARMOR;
} else if (tmpStr == "right-hand") {
slot = SLOTP_RIGHT;
} else if (tmpStr == "left-hand") {
slot = SLOTP_LEFT;
} else if (tmpStr == "hand" || tmpStr == "shield") {
slot = SLOTP_RIGHT | SLOTP_LEFT;
} else if (tmpStr == "legs") {
slot = SLOTP_LEGS;
} else if (tmpStr == "feet") {
slot = SLOTP_FEET;
} else if (tmpStr == "ring") {
slot = SLOTP_RING;
} else if (tmpStr == "ammo") {
slot = SLOTP_AMMO;
} else {
std::cout << "[Warning - MoveEvent::configureMoveEvent] Unknown slot type: " << slotAttribute.as_string() << std::endl;
}
}
wieldInfo = 0;
pugi::xml_attribute levelAttribute = node.attribute("level");
if (levelAttribute) {
reqLevel = pugi::cast<uint32_t>(levelAttribute.value());
if (reqLevel > 0) {
wieldInfo |= WIELDINFO_LEVEL;
}
}
pugi::xml_attribute magLevelAttribute = node.attribute("maglevel");
if (magLevelAttribute) {
reqMagLevel = pugi::cast<uint32_t>(magLevelAttribute.value());
if (reqMagLevel > 0) {
wieldInfo |= WIELDINFO_MAGLV;
}
}
pugi::xml_attribute premiumAttribute = node.attribute("premium");
if (premiumAttribute) {
premium = premiumAttribute.as_bool();
if (premium) {
wieldInfo |= WIELDINFO_PREMIUM;
}
}
//Gather vocation information
std::list<std::string> vocStringList;
for (auto vocationNode : node.children()) {
pugi::xml_attribute vocationNameAttribute = vocationNode.attribute("name");
if (!vocationNameAttribute) {
continue;
}
int32_t vocationId = g_vocations.getVocationId(vocationNameAttribute.as_string());
if (vocationId != -1) {
vocEquipMap[vocationId] = true;
if (vocationNode.attribute("showInDescription").as_bool(true)) {
vocStringList.push_back(asLowerCaseString(vocationNameAttribute.as_string()));
}
}
}
//.........这里部分代码省略.........