本文整理汇总了C++中item::is_book方法的典型用法代码示例。如果您正苦于以下问题:C++ item::is_book方法的具体用法?C++ item::is_book怎么用?C++ item::is_book使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类item
的用法示例。
在下文中一共展示了item::is_book方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
/*static*/ bool inventory::has_category(const item& it, item_cat cat, const player& u) {
switch (cat)
{
case IC_COMESTIBLE: // food
if (it.is_food(&u) || it.is_food_container(&u))
{
return true;
}
break;
case IC_AMMO: // ammo
if (it.is_ammo() || it.is_ammo_container())
{
return true;
}
break;
case IC_ARMOR: // armour
if (it.is_armor())
{
return true;
}
break;
case IC_BOOK: // books
if (it.is_book())
{
return true;
}
break;
case IC_TOOL: // tools
if (it.is_tool())
{
return true;
}
break;
case IC_CONTAINER: // containers for liquid handling
if (it.is_tool() || it.is_gun())
{
if (it.ammo_type() == "gasoline")
{
return true;
}
}
else
{
if (it.is_container())
{
return true;
}
}
break;
}
return false;
}
示例2: value
int npc::value(item &it)
{
int ret = it.price() / 50;
skill best = best_skill();
if (best != sk_unarmed) {
int weapon_val = it.weapon_value(sklevel) - weapon.weapon_value(sklevel);
if (weapon_val > 0)
ret += weapon_val;
}
if (it.is_food()) {
it_comest* comest = dynamic_cast<it_comest*>(it.type);
if (comest->nutr > 0 || comest->quench > 0)
ret++;
if (hunger > 40)
ret += (comest->nutr + hunger - 40) / 6;
if (thirst > 40)
ret += (comest->quench + thirst - 40) / 4;
}
if (it.is_ammo()) {
it_ammo* ammo = dynamic_cast<it_ammo*>(it.type);
it_gun* gun;
if (weapon.is_gun()) {
gun = dynamic_cast<it_gun*>(weapon.type);
if (ammo->type == gun->ammo)
ret += 14;
}
for (int i = 0; i < inv.size(); i++) {
if (inv[i].is_gun()) {
gun = dynamic_cast<it_gun*>(inv[i].type);
if (ammo->type == gun->ammo)
ret += 6;
}
}
}
if (it.is_book()) {
it_book* book = dynamic_cast<it_book*>(it.type);
if (book->intel <= int_cur) {
ret += book->fun;
if (sklevel[book->type] < book->level && sklevel[book->type] >= book->req)
ret += book->level * 3;
}
}
// TODO: Sometimes we want more than one tool? Also we don't want EVERY tool.
if (it.is_tool() && !has_amount(itype_id(it.type->id), 1)) {
ret += 8;
}
// TODO: Artifact hunting from relevant factions
// ALSO TODO: Bionics hunting from relevant factions
if (fac_has_job(FACJOB_DRUGS) && it.is_food() &&
(dynamic_cast<it_comest*>(it.type))->addict >= 5)
ret += 10;
if (fac_has_job(FACJOB_DOCTORS) && it.type->id >= itm_bandages &&
it.type->id <= itm_prozac)
ret += 10;
if (fac_has_value(FACVAL_BOOKS) && it.is_book())
ret += 14;
if (fac_has_job(FACJOB_SCAVENGE)) { // Computed last for _reasons_.
ret += 6;
ret *= 1.3;
}
return ret;
}