MCPcopy Create free account
hub / github.com/NetHack/NetHack / getprice

Function getprice

src/shk.c:4318–4358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4316}
4317
4318staticfn long
4319getprice(struct obj *obj, boolean shk_buying)
4320{
4321 long tmp = (long) objects[obj->otyp].oc_cost;
4322
4323 if (obj->oartifact) {
4324 tmp = arti_cost(obj);
4325 if (shk_buying)
4326 tmp /= 4;
4327 }
4328 switch (obj->oclass) {
4329 case FOOD_CLASS:
4330 tmp += corpsenm_price_adj(obj);
4331
4332 /* simpler hunger check, (2-4)*cost */
4333 if (u.uhs >= HUNGRY && !shk_buying)
4334 tmp *= (long) u.uhs;
4335 if (obj->oeaten)
4336 tmp = 0L;
4337 break;
4338 case WAND_CLASS:
4339 if (obj->spe == -1)
4340 tmp = 0L;
4341 break;
4342 case POTION_CLASS:
4343 if (obj->otyp == POT_WATER && !obj->blessed && !obj->cursed)
4344 tmp = 0L;
4345 break;
4346 case ARMOR_CLASS:
4347 case WEAPON_CLASS:
4348 if (obj->spe > 0)
4349 tmp += 10L * (long) obj->spe;
4350 break;
4351 case TOOL_CLASS:
4352 if (Is_candle(obj)
4353 && obj->age < 20L * (long) objects[obj->otyp].oc_cost)
4354 tmp /= 2L;
4355 break;
4356 }
4357 return tmp;
4358}
4359
4360/* shk catches thrown pick-axe */
4361struct monst *

Callers 2

get_costFunction · 0.85
set_costFunction · 0.85

Calls 2

arti_costFunction · 0.85
corpsenm_price_adjFunction · 0.85

Tested by

no test coverage detected