money.c

tmi2_fluffos_v2/lib/std/living/money.c · 796 B

From the archive tmi2_fluffos_v2.zip

Download the archive   « Back to the archive contents

/* File:    money.c
// Creator: Grendel@tmi-2
// When:    07-15-93

// This file provides a mechanism for a player to be credited and
// debited with money.  Calling set or add bypasses certain checks
// and does not account for encumbrance.
*/

mixed query(string what);
varargs int add(string what, mixed amt, int security);

int credit(string type, int amount)
{
    if(!type || !stringp(type) || !amount || !intp(amount))
	return 0;
    if(query("capacity") < amount)
	return 0;
    add("capacity",-amount);
    add("wealth/"+type,amount);
    return 1;
}

int debit(string type, int amount)
{
    if(!type || !stringp(type) || !amount || !intp(amount))
	return 0;
    if(query("wealth/"+type) < amount)
	return 0;
    add("capacity",amount);
    add("wealth/"+type,-amount);
    return 1;
}

Site Stats

Snippets: 1791
Codebases: 571