items.c

foundation2_fluffos_v1/lib/lib/items.c · 1.5 KB

From the archive foundation2_fluffos_v1.zip

Download the archive   « Back to the archive contents

/*    /lib/items.c
 *    from the Foundation II LPC Library
 *    allows player to create dummy items for the room
 *    created by Descartes of Borg 930616
 *    modified for the new inheritance and object structure 950208
 */

#include <config.h>
#include "items.h"

private mapping Items;

static void create() {
    Items = ([]);
}

int id(string str) { return (str && Items[str]); }

/*********     /lib/exits.c data manipulation functions     **********/

string *GetId() { return keys(Items); }

mapping SetItems(mapping items) {
    mixed *cles;
    int i;

    i = sizeof(cles = keys(items));
    while(i--) {
        if(pointerp(cles[i])) {
	    int j;

	    j = sizeof(cles[i]);
	    while(j--) items[cles[i][j]] = items[cles[i]];
	    map_delete(items, cles[i]);
	}
    }
    return (Items = items);
}

mixed AddItem(string item, mixed val) {
    if( functionp(val) || stringp(val) ) Items[item] = val;
    else error("Bad argument 2 to AddItem().\n");
    return (Items[item]);
}

mapping RemoveItem(string item) { 
    map_delete(Items, item); 
    return Items;
}

mixed GetItemDescription(string item) {
    if( functionp(Items[item]) ) return evaluate(Items[item], item);
    else return Items[item];
}

varargs string GetLong(string item) {
    int x;

    if( functionp(Items[item]) ) {
	string tmp;
	
	if( !(tmp = (string)evaluate(Items[item], item)) ) 
	  return DEFAULT_ITEM_MESSAGE;
	else return tmp;
    }
    else if( stringp(Items[item]) ) return Items[item];
    else return DEFAULT_ITEM_MESSAGE;
}

Site Stats

Snippets: 1791
Codebases: 571