Example #1
0
def register_denomination(name, currency, value = 1, shorthand = None):
    """Create a new denomination for a specified type of currency. For example,
       'gold' for 'money'. If the currency is not yet created, create it. Each
       denomination has a value. For example, copper may be 1, silver may
       be 10, gold may be 100, and platinum may be 1000.
    """
    den = Denomination(name, currency, value, shorthand)
    denominations[name] = den
    if not currency in currency_denominations:
        currency_denominations[currency] = [ ]
    currency_denominations[currency].append(denominations[name])

    if value == 1:
        currency_base[currency] = den

    # add mobile and object properties for setting and getting
    g = lambda s   : get_denomination(s, name)
    s = lambda s, v: set_denomination(s, name, v)
    sh = shorthand
    if sh == None:
        sh = name
    mudsys.add_char_method(sh,property(g, s, doc = "The character's %s" % name))
    mudsys.add_obj_method(sh, property(g, s, doc = "The object's %s" % name))
Example #2
0
def register_denomination(name, currency, value=1, shorthand=None):
    """Create a new denomination for a specified type of currency. For example,
       'gold' for 'money'. If the currency is not yet created, create it. Each
       denomination has a value. For example, copper may be 1, silver may
       be 10, gold may be 100, and platinum may be 1000.
    """
    den = Denomination(name, currency, value, shorthand)
    denominations[name] = den
    if not currency in currency_denominations:
        currency_denominations[currency] = []
    currency_denominations[currency].append(denominations[name])

    if value == 1:
        currency_base[currency] = den

    # add mobile and object properties for setting and getting
    g = lambda s: get_denomination(s, name)
    s = lambda s, v: set_denomination(s, name, v)
    sh = shorthand
    if sh == None:
        sh = name
    mudsys.add_char_method(sh, property(g, s, doc="The character's %s" % name))
    mudsys.add_obj_method(sh, property(g, s, doc="The object's %s" % name))
Example #3
0
################################################################################
# initialization
################################################################################

# install currency aux data and item types
auxiliary.install("currency_data", CurrencyAuxData, "character, object")

# add hooks
hooks.add("get",  get_currency_hook)
hooks.add("give", give_currency_hook)

# add our character and object properties
mudsys.add_char_method("worth",
                       property(__getWorth__, __setWorth__,
                                doc="The character's accumulated wealth"))
mudsys.add_obj_method("worth",
                      property(__getWorth__, __setWorth__,
                               doc="The object's value"))

# items that have the currency bit will be transformed into worth when received
mudsys.create_bit("obj_bits", "currency")

# register default currency and denominations
## register_denomination("copper",   "money",     1, shorthand="cp")
## register_denomination("silver",   "money",    10, shorthand="sp")
## register_denomination("gold",     "money",   100, shorthand="gp")
## register_denomination("platinum", "money",  1000, shorthand="pp")

## register_denomination("questpoints", "questpoints", shorthand="qp")
## register_denomination("experience",  "experience",  shorthand="exp")
Example #4
0
# initialization
################################################################################

# install currency aux data and item types
auxiliary.install("currency_data", CurrencyAuxData, "character, object")

# add hooks
hooks.add("get", get_currency_hook)
hooks.add("give", give_currency_hook)

# add our character and object properties
mudsys.add_char_method(
    "worth",
    property(__getWorth__,
             __setWorth__,
             doc="The character's accumulated wealth"))
mudsys.add_obj_method(
    "worth", property(__getWorth__, __setWorth__, doc="The object's value"))

# items that have the currency bit will be transformed into worth when received
mudsys.create_bit("obj_bits", "currency")

# register default currency and denominations
## register_denomination("copper",   "money",     1, shorthand="cp")
## register_denomination("silver",   "money",    10, shorthand="sp")
## register_denomination("gold",     "money",   100, shorthand="gp")
## register_denomination("platinum", "money",  1000, shorthand="pp")

## register_denomination("questpoints", "questpoints", shorthand="qp")
## register_denomination("experience",  "experience",  shorthand="exp")