describe staircase 'sway' based on whether hero knows the destination */
| 184 | |
| 185 | /* describe staircase 'sway' based on whether hero knows the destination */ |
| 186 | char * |
| 187 | stairs_description( |
| 188 | stairway *sway, /* stairs/ladder to describe */ |
| 189 | char *outbuf, /* result buffer */ |
| 190 | boolean stcase) /* True: "staircase" or "ladder", always singular; |
| 191 | * False: "stairs" or "ladder"; caller needs to deal |
| 192 | * with singular vs plural when forming a sentence */ |
| 193 | { |
| 194 | d_level tolev; |
| 195 | const char *stairs, *updown; |
| 196 | |
| 197 | tolev = sway->tolev; |
| 198 | stairs = sway->isladder ? "ladder" : stcase ? "staircase" : "stairs"; |
| 199 | updown = sway->up ? "up" : "down"; |
| 200 | |
| 201 | if (!known_branch_stairs(sway)) { |
| 202 | /* ordinary stairs or branch stairs to not-yet-visited branch */ |
| 203 | Sprintf(outbuf, "%s %s", stairs, updown); |
| 204 | if (sway->u_traversed) { |
| 205 | boolean specialdepth = (tolev.dnum == quest_dnum |
| 206 | || single_level_branch(&tolev)); /* knox */ |
| 207 | int to_dlev = specialdepth ? dunlev(&tolev) : depth(&tolev); |
| 208 | |
| 209 | Sprintf(eos(outbuf), " to level %d", to_dlev); |
| 210 | } |
| 211 | } else if (u.uz.dnum == 0 && u.uz.dlevel == 1 && sway->up) { |
| 212 | /* stairs up from level one are a special case; they are marked |
| 213 | as having been traversed because the hero obviously started |
| 214 | the game by coming down them, but the remote side varies |
| 215 | depending on whether the Amulet is being carried */ |
| 216 | Sprintf(outbuf, "%s%s %s %s", |
| 217 | !u.uhave.amulet ? "" : "branch ", |
| 218 | stairs, updown, |
| 219 | !u.uhave.amulet ? "out of the dungeon" |
| 220 | /* minimize our expectations about what comes next */ |
| 221 | : (on_level(&tolev, &earth_level) |
| 222 | || on_level(&tolev, &air_level) |
| 223 | || on_level(&tolev, &fire_level) |
| 224 | || on_level(&tolev, &water_level)) |
| 225 | ? "to the Elemental Planes" |
| 226 | : "to the end game"); |
| 227 | } else { |
| 228 | /* known branch stairs; tacking on destination level is too verbose */ |
| 229 | Sprintf(outbuf, "branch %s %s to %s", |
| 230 | stairs, updown, svd.dungeons[tolev.dnum].dname); |
| 231 | /* dungeons[].dname is capitalized; undo that for "The <Branch>" */ |
| 232 | (void) strsubst(outbuf, "The ", "the "); |
| 233 | } |
| 234 | return outbuf; |
| 235 | } |
| 236 | |
| 237 | /*stairs.c*/ |
no test coverage detected