1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
252 | }; |
252 | }; |
253 | |
253 | |
254 | int |
254 | int |
255 | get_power_from_ench (int ench) |
255 | get_power_from_ench (int ench) |
256 | { |
256 | { |
257 | if (ench < 0) ench = 0; |
|
|
258 | if (ench > 20) ench = 20; |
|
|
259 | |
|
|
260 | return enc_to_item_power[ench]; |
257 | return enc_to_item_power [clamp (ench, 0, 20)]; |
261 | } |
258 | } |
262 | |
259 | |
263 | /* This takes an object 'op' and figures out what its item_power |
260 | /* This takes an object 'op' and figures out what its item_power |
264 | * rating should be. This should only really be used by the treasure |
261 | * rating should be. This should only really be used by the treasure |
265 | * generation code, and when loading legacy objects. It returns |
262 | * generation code, and when loading legacy objects. It returns |
… | |
… | |
576 | if (op->type != SPELLBOOK) |
573 | if (op->type != SPELLBOOK) |
577 | buf.printf (" (lvl %d)", op->level); |
574 | buf.printf (" (lvl %d)", op->level); |
578 | } |
575 | } |
579 | break; |
576 | break; |
580 | |
577 | |
581 | case ALTAR: |
578 | case ALTAR: |
582 | case TRIGGER_ALTAR: |
579 | case TRIGGER_ALTAR: |
583 | case IDENTIFY_ALTAR: |
580 | case IDENTIFY_ALTAR: |
584 | case CONVERTER: |
581 | case CONVERTER: |
585 | if (op->slaying == shstr_money) |
582 | if (op->slaying == shstr_money) |
586 | { |
583 | { |
587 | bool wrap = !!buf.size (); |
584 | bool wrap = !!buf.size (); |
588 | |
585 | |
589 | if (wrap) buf << " ["; |
586 | if (wrap) buf << " ["; |
590 | |
587 | |
591 | archetype *coin = 0; |
588 | archetype *coin = 0; |
592 | |
589 | |
593 | for (char const *const *c = coins; *coins; ++c) |
590 | for (char const *const *c = coins; *coins; ++c) |
594 | if ((coin = archetype::find (*c))) |
591 | if ((coin = archetype::find (*c))) |
595 | if (op->stats.food % coin->value == 0) |
592 | if (op->stats.food % coin->value == 0) |
596 | break; |
593 | break; |
597 | |
594 | |
598 | sint32 coins = op->stats.food / coin->value; |
595 | sint32 coins = op->stats.food / coin->value; |
599 | |
596 | |
600 | buf.printf ("drop %d %s (or equivalent)", coins, coins == 1 ? &coin->name : &coin->name_pl); |
597 | buf.printf ("drop %d %s (or equivalent)", coins, coins == 1 ? &coin->name : &coin->name_pl); |
601 | |
598 | |
602 | if (wrap) buf << ']'; |
599 | if (wrap) buf << ']'; |
603 | } |
600 | } |
604 | break; |
601 | break; |
605 | |
602 | |
606 | case SKILL: |
603 | case SKILL: |
607 | case AMULET: |
604 | case AMULET: |
608 | case RING: |
605 | case RING: |
609 | if (!op->title) |
606 | if (!op->title) |
… | |
… | |
1215 | { |
1212 | { |
1216 | static dynbuf_text buf; buf.clear (); |
1213 | static dynbuf_text buf; buf.clear (); |
1217 | |
1214 | |
1218 | for (object *tmp = inv; tmp; tmp = tmp->below) |
1215 | for (object *tmp = inv; tmp; tmp = tmp->below) |
1219 | if (who && QUERY_FLAG (who, FLAG_WIZ)) |
1216 | if (who && QUERY_FLAG (who, FLAG_WIZ)) |
1220 | buf.printf ("%s- %-28.28s (%5d) %-8s\n", indent, query_name (tmp), tmp->count, query_weight (tmp)); |
1217 | buf.printf ("%s- %-28.28s (%5d) %-8s\n", indent, tmp->query_name (), tmp->count, tmp->query_weight ()); |
1221 | else if (!tmp->invisible && (type == CONTAINER || QUERY_FLAG (tmp, FLAG_APPLIED))) |
1218 | else if (!tmp->invisible && (type == CONTAINER || QUERY_FLAG (tmp, FLAG_APPLIED))) |
1222 | buf.printf ("%s- %-36.36s %-8s\n", indent, query_name (tmp), query_weight (tmp)); |
1219 | buf.printf ("%s- %-36.36s %-8s\n", indent, tmp->query_name (), tmp->query_weight ()); |
1223 | |
1220 | |
1224 | if (buf.size ()) |
1221 | if (buf.size ()) |
1225 | buf.printf ("%s(total weight: %s)\n", indent, query_weight (this)); |
1222 | buf.printf ("%s(total weight: %s)\n", indent, query_weight ()); |
1226 | else |
1223 | else |
1227 | buf.printf ("%s(empty)\n", indent); |
1224 | buf.printf ("%s(empty)\n", indent); |
1228 | |
1225 | |
1229 | return buf; |
1226 | return buf; |
1230 | } |
1227 | } |