Example #1
0
def cmd_zinstance(ch, cmd, arg):
    '''create an instanced copy of the specified zone.'''
    if arg == "":
        if len(curr_instances) == 0:
            ch.send("No zones currently instanced.")
        else:
            ch.send("{w %-40s %36s " % ("Instance", "Source"))
            ch.send("{b" + display.seperator)
            for pair in curr_instances:
                ch.send("{c %-40s %36s{n" % pair)
        return

    # try creating the instance, and returning the zone key
    instance = do_zinstance(arg)

    if instance != None:
        ch.send(
            "Zone has been instanced with zone key, %s. zinstance for a list of current instances."
            % instance)
    elif sum([(not v in string.ascii_letters + string.digits + "_")
              for v in arg]):
        ch.send("Invalid zone key.")
    elif len(mudsys.list_zone_contents(arg, "rproto")):
        ch.send("Source zone contained no rooms to instance.")
    else:
        ch.send("Zone instance failed for unknown reason.")
Example #2
0
def do_zinstance(zone):
    '''create a new instance of the specified zone.'''
    # sanitize the zone key
    if sum([(not v in string.ascii_letters + string.digits + "_")
            for v in zone]):
        return None
    elif len(zone) == 0:
        return None

    # find all of our room keys
    rnames = mudsys.list_zone_contents(zone, "rproto")
    if len(rnames) == 0:
        return None

    to_instance = []
    for name in rnames:
        key = name + "@" + zone
        if not mudroom.is_abstract(key):
            to_instance.append(name)

    # instantiate and reset all of the relevant rooms
    uid = mudsys.next_uid()
    inszone = zone + str(uid)
    for name in to_instance:
        key = name + "@" + zone
        ins = name + "@" + inszone
        rm = mudroom.instance(key, ins)
        rm.reset()

    # append this to the list of instanced zones
    curr_instances.append((inszone, zone))

    # success
    return inszone
Example #3
0
def do_zinstance(zone):
    '''create a new instance of the specified zone.'''
    # sanitize the zone key
    if sum([(not v in string.ascii_letters+string.digits+"_") for v in zone]):
        return None
    elif len(zone) == 0:
        return None

    # find all of our room keys
    rnames = mudsys.list_zone_contents(zone, "rproto")
    if len(rnames) == 0:
        return None
            
    to_instance = [ ]
    for name in rnames:
        key = name + "@" + zone
        if not mudroom.is_abstract(key):
            to_instance.append(name)

    # instantiate and reset all of the relevant rooms
    uid     = mudsys.next_uid()
    inszone = zone + str(uid)
    for name in to_instance:
        key = name + "@" + zone
        ins = name + "@" + inszone
        rm  = mudroom.instance(key, ins)
        rm.reset()

    # append this to the list of instanced zones
    curr_instances.append((inszone, zone))

    # success
    return inszone
Example #4
0
def cmd_zinstance(ch, cmd, arg):
    '''create an instanced copy of the specified zone.'''
    if arg == "":
        if len(curr_instances) == 0:
            ch.send("No zones currently instanced.")
        else:
            ch.send("{w %-40s %36s " % ("Instance", "Source"))
            ch.send("{b" + display.seperator)
            for pair in curr_instances:
                ch.send("{c %-40s %36s{n" % pair)
        return

    # try creating the instance, and returning the zone key
    instance = do_zinstance(arg)
        
    if instance != None:
        ch.send("Zone has been instanced with zone key, %s. zinstance for a list of current instances." % instance)
    elif sum([(not v in string.ascii_letters+string.digits+"_") for v in arg]):
        ch.send("Invalid zone key.")
    elif len(mudsys.list_zone_contents(arg, "rproto")):
        ch.send("Source zone contained no rooms to instance.")
    else:
        ch.send("Zone instance failed for unknown reason.")