learn or refresh spell otyp, if feasible; return casting letter or '\0' */
| 2388 | |
| 2389 | /* learn or refresh spell otyp, if feasible; return casting letter or '\0' */ |
| 2390 | char |
| 2391 | force_learn_spell(short otyp) |
| 2392 | { |
| 2393 | int i; |
| 2394 | |
| 2395 | if (otyp == SPE_BLANK_PAPER || otyp == SPE_BOOK_OF_THE_DEAD |
| 2396 | || known_spell(otyp) == spe_Fresh) |
| 2397 | return '\0'; |
| 2398 | |
| 2399 | for (i = 0; i < MAXSPELL; i++) |
| 2400 | if (spellid(i) == NO_SPELL || spellid(i) == otyp) |
| 2401 | break; |
| 2402 | if (i == MAXSPELL) { |
| 2403 | impossible("Too many spells memorized"); |
| 2404 | return '\0'; |
| 2405 | } |
| 2406 | /* for a going-stale or forgotten spell the sp_id and sp_lev assignments |
| 2407 | are redundant but harmless; for an unknown spell, they're essential */ |
| 2408 | svs.spl_book[i].sp_id = otyp; |
| 2409 | svs.spl_book[i].sp_lev = objects[otyp].oc_level; |
| 2410 | incrnknow(i, 0); /* set spl_book[i].sp_know to KEEN; unlike when learning |
| 2411 | * a spell by reading its book, we don't need to add 1 */ |
| 2412 | return spellet(i); |
| 2413 | } |
| 2414 | |
| 2415 | /* number of spells hero knows */ |
| 2416 | int |
no test coverage detected