Ejemplo n.º 1
0
    """Turns a currency object into actual currency when received.
    """
    ch, recv, obj = hooks.parse_info(info)
    # if obj.hasBit("currency"):
    if utils.is_keyword(obj.bits, "currency"):
        recv.worth += obj.worth
        mud.extract(obj)



################################################################################
# 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")
Ejemplo n.º 2
0
       specified, instead delete a key.'''
    try:
        key, val = mud.parse_args(ch, True, cmd, arg,
                                  "word(key) | string(val)")
    except:
        return

    # are we trying to delete a key?
    if val == None:
        if key in ch.aux("example_aux").pairs:
            del ch.aux("example_aux").pairs[key]
        ch.send("Key deleted.")
    else:
        ch.aux("example_aux").pairs[key] = val
        ch.send("Key '%s' set to '%s'." % (key, val))


################################################################################
# initialization
################################################################################

# install our auxiliary data on characters when this module is loaded.
# auxiliary data can also be installed onto rooms and objects. You can install
# auxiliary data onto more than one type of thing by comma-separating them in
# the third argument of this method.
auxiliary.install("example_aux", ExampleAux, "character")

# add in our two commands
mudsys.add_cmd("getaux", None, cmd_getaux, "admin", False)
mudsys.add_cmd("setaux", None, cmd_setaux, "admin", False)
Ejemplo n.º 3
0
    # returns a storage set representation of the auxiliary data
    def store(self):
        set = storage.StorageSet()
        set.storeString("val", self.val)
        return set


# allows people to peek at the value stored in their ExampleAux data
def cmd_getaux(ch, cmd, arg):
    aux = ch.account.getAuxiliary("example_aux")
    ch.send("The val is " + aux.val)


# allows people to set the value stored in their ExampleAux data
def cmd_setaux(ch, cmd, arg):
    aux = ch.account.getAuxiliary("example_aux")
    aux.val = arg
    ch.send("val set to " + arg)


# install our auxiliary data on characters when this module is loaded.
# auxiliary data can also be installed onto rooms and objects. You can install
# auxiliary data onto more than one type of thing by comma-separating them in
# the third argument of this method.
auxiliary.install("example_aux", ExampleAux, "account")

# add in our two commands
add_cmd("getaux", None, cmd_getaux, "admin", False)
add_cmd("setaux", None, cmd_setaux, "admin", False)
Ejemplo n.º 4
0
    '''allows people to set a value stored in their aux data. If no value is
       specified, instead delete a key.'''
    try:
        key, val = mud.parse_args(ch, True, cmd, arg, "word(key) | string(val)")
    except: return

    # are we trying to delete a key?
    if val == None:
        if key in ch.aux("example_aux").pairs:
            del ch.aux("example_aux").pairs[key]
        ch.send("Key deleted.")
    else:
        ch.aux("example_aux").pairs[key] = val
        ch.send("Key '%s' set to '%s'." % (key, val))



################################################################################
# initialization
################################################################################

# install our auxiliary data on characters when this module is loaded.
# auxiliary data can also be installed onto rooms and objects. You can install
# auxiliary data onto more than one type of thing by comma-separating them in
# the third argument of this method.
auxiliary.install("example_aux", ExampleAux, "character")

# add in our two commands
mudsys.add_cmd("getaux", None, cmd_getaux, "admin", False)
mudsys.add_cmd("setaux", None, cmd_setaux, "admin", False)
Ejemplo n.º 5
0
        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)
Ejemplo n.º 6
0
    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)
Ejemplo n.º 7
0
def give_currency_hook(info):
    """Turns a currency object into actual currency when received.
    """
    ch, recv, obj = hooks.parse_info(info)
    # if obj.hasBit("currency"):
    if utils.is_keyword(obj.bits, "currency"):
        recv.worth += obj.worth
        mud.extract(obj)


################################################################################
# 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
Ejemplo n.º 8
0
    # returns a storage set representation of the auxiliary data
    def store(self):
        set = storage.StorageSet()
        set.storeString("val", self.val)
        return set


# allows people to peek at the value stored in their ExampleAux data
def cmd_getaux(ch, cmd, arg):
    aux = ch.account.getAuxiliary("example_aux")
    ch.send("The val is " + aux.val)


# allows people to set the value stored in their ExampleAux data
def cmd_setaux(ch, cmd, arg):
    aux = ch.account.getAuxiliary("example_aux")
    aux.val = arg
    ch.send("val set to " + arg)


# install our auxiliary data on characters when this module is loaded.
# auxiliary data can also be installed onto rooms and objects. You can install
# auxiliary data onto more than one type of thing by comma-separating them in
# the third argument of this method.
auxiliary.install("example_aux", ExampleAux, "account")

# add in our two commands
add_cmd("getaux", None, cmd_getaux, "admin", False)
add_cmd("setaux", None, cmd_setaux, "admin", False)