本文整理汇总了C++中PhysicalObject::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ PhysicalObject::getName方法的具体用法?C++ PhysicalObject::getName怎么用?C++ PhysicalObject::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhysicalObject
的用法示例。
在下文中一共展示了PhysicalObject::getName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initCommands
//.........这里部分代码省略.........
}
PhysicalObject * physicalObject = env->find(commands[1]);
if(physicalObject == NULL) {
std::cout << "Found no item named: " << commands[1] << std::endl;
} else {
std::cout << physicalObject->getDescription() << std::endl;
}
} else if(commands.size() == 3) {
Item * item = NULL;
if(isCommandInventory(commands[1])) {
Inventory * inv = getInventory();
item = inv->find(commands[2]);
if(item == NULL) {
std::cout << "Found no item named: " << commands[2] << " in your inventory." << std::endl;
return false;
}
} else if(isCommandEquipment(commands[1])) {
Equipment * eq = getEquipment();
item = eq->find(commands[2]);
if(item == NULL) {
std::cout << "Found no item named: " << commands[2] << " in your equipment." << std::endl;
return false;
}
} else {
Container * con = env->find<Container>(OBJECT_TYPE_CONTAINER, commands[2]);
if(con == NULL) {
std::cout << "Found no container named: " <<commands[1] << std::endl;
return false;
} else {
item = con->find(commands[2]);
if(item == NULL) {
std::cout << "Found no item named: " << commands[2] << " in container: " << con->getName() << std::endl;
return false;
}
}
}
std::cout << item->getDescription() << std::endl;
}
return false;
});
addCommands({"stats"}, [this, isHelp](const std::vector<std::string> & commands) -> bool {
if(isHelp(commands,"Get information about you.", "")) { return false;}
std::cout << getDescription() << std::endl;
return false;
});
addCommands({"inventory", "backpack", "inv"}, [this, isHelp](const std::vector<std::string> & commands) -> bool {
if(isHelp(commands, "Get information about your inventory that contains items.", "")) { return false;}
Inventory * inv = getInventory();
std::cout << inv->getDescription() << std::endl;
return false;
});
addCommands({"equipment"}, [this, isHelp](const std::vector<std::string> & commands) -> bool {
if(isHelp(commands, "Get information about your current equipment.", "")) { return false;}
Equipment * eq = getEquipment();
std::cout << eq->getDescription() << std::endl;
return false;
});
addCommands({"pick"}, [this, isHelp](const std::vector<std::string> & commands) -> bool {
if(isHelp(commands,"Pick up items from the ground or from containers like for example Chests.", "[CONTAINER] ITEM")) { return false;}