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))
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))
################################################################################ # 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")
tgt, routine, repeat = mud.parse_args(ch, True, cmd, arg, "ch.room.noself word(py_list) | bool(repeat)") except: return set_routine(tgt, eval(routine), repeat) ch.send("Routine set.") ################################################################################ # initialization ################################################################################ # auxiliary data auxiliary.install("routine_data", RoutineAuxData, "character") # base check. Don't do a routine if we're currently doing an action register_routine_check(lambda ch: ch.isActing()) # commands mudsys.add_cmd("routine", None, cmd_routine, "admin", False) # misc initialization # mud.set_routine = set_routine # # now use: ch.set_routine(routine) # instead of: mud.set_routine(ch, routine) # mudsys.add_char_method("set_routine", set_routine)
try: tgt, routine, repeat = mud.parse_args( ch, True, cmd, arg, "ch.room.noself word(py_list) | bool(repeat)") except: return set_routine(tgt, eval(routine), repeat) ch.send("Routine set.") ################################################################################ # initialization ################################################################################ # auxiliary data auxiliary.install("routine_data", RoutineAuxData, "character") # base check. Don't do a routine if we're currently doing an action register_routine_check(lambda ch: ch.isActing()) # commands mudsys.add_cmd("routine", None, cmd_routine, "admin", False) # misc initialization # mud.set_routine = set_routine # # now use: ch.set_routine(routine) # instead of: mud.set_routine(ch, routine) # mudsys.add_char_method("set_routine", set_routine)
################################################################################ # 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")