Mercurial > hg > early-roguelike
comparison rogue4/things.c @ 12:9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
| author | edwarj4 |
|---|---|
| date | Sat, 24 Oct 2009 16:52:52 +0000 |
| parents | |
| children | 1b73a8641b37 |
comparison
equal
deleted
inserted
replaced
| 11:949d558c2162 | 12:9535a08ddc39 |
|---|---|
| 1 /* | |
| 2 * Contains functions for dealing with things like potions, scrolls, | |
| 3 * and other items. | |
| 4 * | |
| 5 * @(#)things.c 4.26 (Berkeley) 5/18/82 | |
| 6 * | |
| 7 * Rogue: Exploring the Dungeons of Doom | |
| 8 * Copyright (C) 1980, 1981, 1982 Michael Toy, Ken Arnold and Glenn Wichman | |
| 9 * All rights reserved. | |
| 10 * | |
| 11 * See the file LICENSE.TXT for full copyright and licensing information. | |
| 12 */ | |
| 13 | |
| 14 #include <curses.h> | |
| 15 #include <ctype.h> | |
| 16 #include <string.h> | |
| 17 #include "rogue.h" | |
| 18 | |
| 19 bool got_genocide = FALSE; | |
| 20 | |
| 21 /* | |
| 22 * inv_name: | |
| 23 * Return the name of something as it would appear in an | |
| 24 * inventory. | |
| 25 */ | |
| 26 char * | |
| 27 inv_name(obj, drop) | |
| 28 register THING *obj; | |
| 29 register bool drop; | |
| 30 { | |
| 31 register char *pb; | |
| 32 | |
| 33 pb = prbuf; | |
| 34 switch (obj->o_type) | |
| 35 { | |
| 36 case SCROLL: | |
| 37 if (obj->o_count == 1) | |
| 38 { | |
| 39 strcpy(pb, "A scroll "); | |
| 40 pb = &prbuf[9]; | |
| 41 } | |
| 42 else | |
| 43 { | |
| 44 sprintf(pb, "%d scrolls ", obj->o_count); | |
| 45 pb = &prbuf[strlen(prbuf)]; | |
| 46 } | |
| 47 if (s_know[obj->o_which]) | |
| 48 sprintf(pb, "of %s", s_magic[obj->o_which].mi_name); | |
| 49 else if (s_guess[obj->o_which]) | |
| 50 sprintf(pb, "called %s", s_guess[obj->o_which]); | |
| 51 else | |
| 52 sprintf(pb, "titled '%s'", s_names[obj->o_which]); | |
| 53 when POTION: | |
| 54 if (obj->o_count == 1) | |
| 55 { | |
| 56 strcpy(pb, "A potion "); | |
| 57 pb = &prbuf[9]; | |
| 58 } | |
| 59 else | |
| 60 { | |
| 61 sprintf(pb, "%d potions ", obj->o_count); | |
| 62 pb = &pb[strlen(prbuf)]; | |
| 63 } | |
| 64 if (p_know[obj->o_which]) | |
| 65 sprintf(pb, "of %s(%s)", p_magic[obj->o_which].mi_name, | |
| 66 p_colors[obj->o_which]); | |
| 67 else if (p_guess[obj->o_which]) | |
| 68 sprintf(pb, "called %s(%s)", p_guess[obj->o_which], | |
| 69 p_colors[obj->o_which]); | |
| 70 else if (obj->o_count == 1) | |
| 71 sprintf(prbuf, "A%s %s potion", vowelstr(p_colors[obj->o_which]), | |
| 72 p_colors[obj->o_which]); | |
| 73 else | |
| 74 sprintf(prbuf, "%d %s potions", obj->o_count, | |
| 75 p_colors[obj->o_which]); | |
| 76 when FOOD: | |
| 77 if (obj->o_which == 1) | |
| 78 if (obj->o_count == 1) | |
| 79 sprintf(pb, "A%s %s", vowelstr(fruit), fruit); | |
| 80 else | |
| 81 sprintf(pb, "%d %ss", obj->o_count, fruit); | |
| 82 else | |
| 83 if (obj->o_count == 1) | |
| 84 strcpy(pb, "Some food"); | |
| 85 else | |
| 86 sprintf(pb, "%d rations of food", obj->o_count); | |
| 87 when WEAPON: | |
| 88 if (obj->o_count > 1) | |
| 89 sprintf(pb, "%d ", obj->o_count); | |
| 90 else | |
| 91 sprintf(pb, "A%s ", vowelstr(w_names[obj->o_which])); | |
| 92 pb = &prbuf[strlen(prbuf)]; | |
| 93 if (obj->o_flags & ISKNOW) | |
| 94 sprintf(pb, "%s %s", num(obj->o_hplus, obj->o_dplus, WEAPON), | |
| 95 w_names[obj->o_which]); | |
| 96 else | |
| 97 sprintf(pb, "%s", w_names[obj->o_which]); | |
| 98 if (obj->o_count > 1) | |
| 99 strcat(pb, "s"); | |
| 100 when ARMOR: | |
| 101 if (obj->o_flags & ISKNOW) | |
| 102 { | |
| 103 sprintf(pb, "%s %s [", | |
| 104 num(a_class[obj->o_which] - obj->o_ac, 0, ARMOR), | |
| 105 a_names[obj->o_which]); | |
| 106 if (!terse) | |
| 107 strcat(pb, "armor class "); | |
| 108 pb = &prbuf[strlen(prbuf)]; | |
| 109 sprintf(pb, "%d]", obj->o_ac); | |
| 110 } | |
| 111 else | |
| 112 sprintf(pb, "%s", a_names[obj->o_which]); | |
| 113 when AMULET: | |
| 114 strcpy(pb, "The Amulet of Yendor"); | |
| 115 when STICK: | |
| 116 sprintf(pb, "A%s %s ", vowelstr(ws_type[obj->o_which]), | |
| 117 ws_type[obj->o_which]); | |
| 118 pb = &prbuf[strlen(prbuf)]; | |
| 119 if (ws_know[obj->o_which]) | |
| 120 sprintf(pb, "of %s%s(%s)", ws_magic[obj->o_which].mi_name, | |
| 121 charge_str(obj), ws_made[obj->o_which]); | |
| 122 else if (ws_guess[obj->o_which]) | |
| 123 sprintf(pb, "called %s(%s)", ws_guess[obj->o_which], | |
| 124 ws_made[obj->o_which]); | |
| 125 else | |
| 126 sprintf(pb = &prbuf[1], "%s %s %s", | |
| 127 vowelstr(ws_made[obj->o_which]), ws_made[obj->o_which], | |
| 128 ws_type[obj->o_which]); | |
| 129 when RING: | |
| 130 if (r_know[obj->o_which]) | |
| 131 sprintf(pb, "A%s ring of %s(%s)", ring_num(obj), | |
| 132 r_magic[obj->o_which].mi_name, r_stones[obj->o_which]); | |
| 133 else if (r_guess[obj->o_which]) | |
| 134 sprintf(pb, "A ring called %s(%s)", | |
| 135 r_guess[obj->o_which], r_stones[obj->o_which]); | |
| 136 else | |
| 137 sprintf(pb, "A%s %s ring", vowelstr(r_stones[obj->o_which]), | |
| 138 r_stones[obj->o_which]); | |
| 139 when GOLD: | |
| 140 sprintf(pb, "%d pieces of gold", obj->o_goldval); | |
| 141 #ifdef WIZARD | |
| 142 otherwise: | |
| 143 debug("Picked up something funny %s", unctrol(obj->o_type)); | |
| 144 sprintf(pb, "Something bizarre %s", unctrol(obj->o_type)); | |
| 145 #endif | |
| 146 } | |
| 147 if (obj == cur_armor) | |
| 148 strcat(pb, " (being worn)"); | |
| 149 if (obj == cur_weapon) | |
| 150 strcat(pb, " (weapon in hand)"); | |
| 151 if (obj == cur_ring[LEFT]) | |
| 152 strcat(pb, " (on left hand)"); | |
| 153 else if (obj == cur_ring[RIGHT]) | |
| 154 strcat(pb, " (on right hand)"); | |
| 155 if (drop && isupper(prbuf[0])) | |
| 156 prbuf[0] = tolower(prbuf[0]); | |
| 157 else if (!drop && islower(*prbuf)) | |
| 158 *prbuf = toupper(*prbuf); | |
| 159 return prbuf; | |
| 160 } | |
| 161 | |
| 162 /* | |
| 163 * drop: | |
| 164 * Put something down | |
| 165 */ | |
| 166 drop() | |
| 167 { | |
| 168 register char ch; | |
| 169 register THING *nobj, *op; | |
| 170 | |
| 171 ch = chat(hero.y, hero.x); | |
