[BACK]Return to rings.c CVS log [TXT][DIR] Up to [contributed] / early-roguelike / rogue4

Annotation of early-roguelike/rogue4/rings.c, Revision 1.1

1.1     ! rubenllo    1: /*
        !             2:  * Routines dealing specifically with rings
        !             3:  *
        !             4:  * @(#)rings.c 4.13 (Berkeley) 1/28/82
        !             5:  *
        !             6:  * Rogue: Exploring the Dungeons of Doom
        !             7:  * Copyright (C) 1980, 1981, 1982 Michael Toy, Ken Arnold and Glenn Wichman
        !             8:  * All rights reserved.
        !             9:  *
        !            10:  * See the file LICENSE.TXT for full copyright and licensing information.
        !            11:  */
        !            12:
        !            13: #include <curses.h>
        !            14: #include <string.h>
        !            15: #include "rogue.h"
        !            16:
        !            17: int gethand(void);
        !            18:
        !            19: /*
        !            20:  * ring_on:
        !            21:  *     Put a ring on a hand
        !            22:  */
        !            23: void
        !            24: ring_on(void)
        !            25: {
        !            26:     register THING *obj;
        !            27:     register int ring;
        !            28:
        !            29:     obj = get_item("put on", RING);
        !            30:     /*
        !            31:      * Make certain that it is somethings that we want to wear
        !            32:      */
        !            33:     if (obj == NULL)
        !            34:        return;
        !            35:     if (obj->o_type != RING)
        !            36:     {
        !            37:        if (!terse)
        !            38:            msg("it would be difficult to wrap that around a finger");
        !            39:        else
        !            40:            msg("not a ring");
        !            41:        return;
        !            42:     }
        !            43:
        !            44:     /*
        !            45:      * find out which hand to put it on
        !            46:      */
        !            47:     if (is_current(obj))
        !            48:        return;
        !            49:
        !            50:     if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL)
        !            51:     {
        !            52:        if ((ring = gethand()) < 0)
        !            53:            return;
        !            54:     }
        !            55:     else if (cur_ring[LEFT] == NULL)
        !            56:        ring = LEFT;
        !            57:     else if (cur_ring[RIGHT] == NULL)
        !            58:        ring = RIGHT;
        !            59:     else
        !            60:     {
        !            61:        if (!terse)
        !            62:            msg("you already have a ring on each hand");
        !            63:        else
        !            64:            msg("wearing two");
        !            65:        return;
        !            66:     }
        !            67:     cur_ring[ring] = obj;
        !            68:
        !            69:     /*
        !            70:      * Calculate the effect it has on the poor guy.
        !            71:      */
        !            72:     switch (obj->o_which)
        !            73:     {
        !            74:        case R_ADDSTR:
        !            75:            chg_str(obj->o_ac);
        !            76:            break;
        !            77:        case R_SEEINVIS:
        !            78:            invis_on();
        !            79:            break;
        !            80:        case R_AGGR:
        !            81:            aggravate();
        !            82:            break;
        !            83:     }
        !            84:
        !            85:     if (!terse)
        !            86:        addmsg("you are now wearing ");
        !            87:     msg("%s (%c)", inv_name(obj, TRUE), pack_char(obj));
        !            88: }
        !            89:
        !            90: /*
        !            91:  * ring_off:
        !            92:  *     Take off a ring
        !            93:  */
        !            94: void
        !            95: ring_off(void)
        !            96: {
        !            97:     register int ring;
        !            98:     register THING *obj;
        !            99:     register char packchar;
        !           100:
        !           101:     if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL)
        !           102:     {
        !           103:        if (terse)
        !           104:            msg("no rings");
        !           105:        else
        !           106:            msg("you aren't wearing any rings");
        !           107:        return;
        !           108:     }
        !           109:     else if (cur_ring[LEFT] == NULL)
        !           110:        ring = RIGHT;
        !           111:     else if (cur_ring[RIGHT] == NULL)
        !           112:        ring = LEFT;
        !           113:     else
        !           114:        if ((ring = gethand()) < 0)
        !           115:            return;
        !           116:     mpos = 0;
        !           117:     obj = cur_ring[ring];
        !           118:     if (obj == NULL)
        !           119:     {
        !           120:        msg("not wearing such a ring");
        !           121:        return;
        !           122:     }
        !           123:     packchar = pack_char(obj);
        !           124:     if (dropcheck(obj))
        !           125:        msg("was wearing %s(%c)", inv_name(obj, TRUE), packchar);
        !           126: }
        !           127:
        !           128: /*
        !           129:  * gethand:
        !           130:  *     Which hand is the hero interested in?
        !           131:  */
        !           132: int
        !           133: gethand(void)
        !           134: {
        !           135:     register int c;
        !           136:
        !           137:     for (;;)
        !           138:     {
        !           139:        if (terse)
        !           140:            msg("left or right ring? ");
        !           141:        else
        !           142:            msg("left hand or right hand? ");
        !           143:        if ((c = readchar()) == ESCAPE)
        !           144:            return -1;
        !           145:        mpos = 0;
        !           146:        if (c == 'l' || c == 'L')
        !           147:            return LEFT;
        !           148:        else if (c == 'r' || c == 'R')
        !           149:            return RIGHT;
        !           150:        if (terse)
        !           151:            msg("L or R");
        !           152:        else
        !           153:            msg("please type L or R");
        !           154:     }
        !           155: }
        !           156:
        !           157: /*
        !           158:  * ring_eat:
        !           159:  *     How much food does this ring use up?
        !           160:  */
        !           161: int
        !           162: ring_eat(int hand)
        !           163: {
        !           164:     if (cur_ring[hand] == NULL)
        !           165:        return 0;
        !           166:     switch (cur_ring[hand]->o_which)
        !           167:     {
        !           168:        case R_REGEN:
        !           169:            return 2;
        !           170:        case R_SUSTSTR:
        !           171:        case R_SUSTARM:
        !           172:        case R_PROTECT:
        !           173:        case R_ADDSTR:
        !           174:        case R_STEALTH:
        !           175:            return 1;
        !           176:        case R_SEARCH:
        !           177:        case R_ADDHIT:
        !           178:        case R_ADDDAM:
        !           179:            return (rnd(3) == 0);
        !           180:        case R_DIGEST:
        !           181:            return -rnd(2);
        !           182:        case R_SEEINVIS:
        !           183:            return (rnd(5) == 0);
        !           184:        default:
        !           185:            return 0;
        !           186:     }
        !           187: }
        !           188:
        !           189: /*
        !           190:  * ring_num:
        !           191:  *     Print ring bonuses
        !           192:  */
        !           193: char *
        !           194: ring_num(THING *obj)
        !           195: {
        !           196:     static char buf[5];
        !           197:
        !           198:     if (!(obj->o_flags & ISKNOW))
        !           199:        return "";
        !           200:     switch (obj->o_which)
        !           201:     {
        !           202:        case R_PROTECT:
        !           203:        case R_ADDSTR:
        !           204:        case R_ADDDAM:
        !           205:        case R_ADDHIT:
        !           206:            buf[0] = ' ';
        !           207:            strcpy(&buf[1], num(obj->o_ac, 0, RING));
        !           208:        otherwise:
        !           209:            return "";
        !           210:     }
        !           211:     return buf;
        !           212: }

CVSweb