write -- applying a magic marker */
| 71 | |
| 72 | /* write -- applying a magic marker */ |
| 73 | int |
| 74 | dowrite(struct obj *pen) |
| 75 | { |
| 76 | struct obj *paper; |
| 77 | char namebuf[BUFSZ] = DUMMY, *nm, *bp; |
| 78 | struct obj *new_obj; |
| 79 | int basecost, actualcost; |
| 80 | int curseval; |
| 81 | char qbuf[QBUFSZ]; |
| 82 | int first, last, i, deferred, deferralchance, real; |
| 83 | boolean by_descr = FALSE; |
| 84 | const char *typeword; |
| 85 | int spell_knowledge; |
| 86 | |
| 87 | if (nohands(gy.youmonst.data)) { |
| 88 | You("need hands to be able to write!"); |
| 89 | return ECMD_OK; |
| 90 | } else if (Glib) { |
| 91 | pline("%s from your %s.", Tobjnam(pen, "slip"), |
| 92 | fingers_or_gloves(FALSE)); |
| 93 | dropx(pen); |
| 94 | return ECMD_TIME; |
| 95 | } |
| 96 | |
| 97 | /* get paper to write on */ |
| 98 | paper = getobj("write on", write_ok, GETOBJ_NOFLAGS); |
| 99 | if (!paper) |
| 100 | return ECMD_CANCEL; |
| 101 | /* can't write on a novel (unless/until it's been converted into a blank |
| 102 | spellbook), but we want messages saying so to avoid "spellbook" */ |
| 103 | typeword = (paper->otyp == SPE_NOVEL) ? "book" |
| 104 | : (paper->oclass == SPBOOK_CLASS) ? "spellbook" |
| 105 | : "scroll"; |
| 106 | if (Blind) { |
| 107 | if (!paper->dknown) { |
| 108 | You("don't know whether that %s is blank or not.", typeword); |
| 109 | return ECMD_OK; |
| 110 | } else if (paper->oclass == SPBOOK_CLASS) { |
| 111 | /* can't write a magic book while blind */ |
| 112 | pline("%s can't create braille text.", |
| 113 | upstart(ysimple_name(pen))); |
| 114 | return ECMD_OK; |
| 115 | } |
| 116 | } |
| 117 | observe_object(paper); |
| 118 | if (paper->otyp != SCR_BLANK_PAPER && paper->otyp != SPE_BLANK_PAPER) { |
| 119 | pline("That %s is not blank!", typeword); |
| 120 | exercise(A_WIS, FALSE); |
| 121 | return ECMD_TIME; |
| 122 | } |
| 123 | makeknown(SCR_BLANK_PAPER); |
| 124 | |
| 125 | /* what to write */ |
| 126 | Sprintf(qbuf, "What type of %s do you want to write?", typeword); |
| 127 | getlin(qbuf, namebuf); |
| 128 | (void) mungspaces(namebuf); /* remove any excess whitespace */ |
| 129 | if (namebuf[0] == '\033' || !namebuf[0]) |
| 130 | return ECMD_TIME; |
no test coverage detected