示例#1
0
def task_execute():
    w = World()
    for current in w.populators:
        if not w.denizens.has_key(current.instance):
            denizen = Denizen(current.denizen)
            current.instance = denizen.id
            w.denizens[denizen.id] = denizen
            libsigma.enter_room(denizen, current.target)

    for current in w.placements:
        if not current.instance in [i.id for i in current.target.contents]:
            item = Item(current.item)
            item.quantity = current.quantity
            current.instance = item.id
            w.items[item.id] = item
            current.target.contents.append(item)
示例#2
0
def task_execute():
    w = World()
    for current in w.populators:
        if not w.denizens.has_key(current.instance):
            denizen = Denizen(current.denizen)
            current.instance = denizen.id
            w.denizens[denizen.id] = denizen
            libsigma.enter_room(denizen, current.target)

    for current in w.placements:
        if not current.instance in [i.id for i in current.target.contents]:
            item = Item(current.item)
            item.quantity = current.quantity
            current.instance = item.id
            w.items[item.id] = item
            current.target.contents.append(item)
示例#3
0
def task_execute():
    w = World()
    for current in w.populators:
        if w.denizens.has_key(current.instance) and 'mobile' in current.flags:
            active_denizen = w.denizens[current.instance]

            choices = [None]
            choices.extend(libsigma.open_exits(active_denizen.location))

            selection = random.choice(choices)
            if active_denizen.engaged:
                selection=None

            if (selection != None):
                if active_denizen.location.altmsg[selection]!=None:
                    libsigma.report(libsigma.ROOM, "$actor just went " + active_denizen.location.altmsg[selection] + ".", active_denizen )
                elif (libsigma.dir2txt(selection) =='leave'):
                    libsigma.report(libsigma.ROOM, "$actor just went out.", active_denizen)
                elif (libsigma.dir2txt(selection) == 'enter'):
                    libsigma.report(libsigma.ROOM, "$actor just went in.", active_denizen)
                else:
                    libsigma.report(libsigma.ROOM, "$actor just went " + libsigma.dir2txt(selection) + ".", active_denizen)
                libsigma.enter_room(active_denizen, active_denizen.location.exits[selection])
                libsigma.report(libsigma.ROOM, "$actor has entered the room.", active_denizen)
示例#4
0
def process_commands():
    while len(command_queue) > 0:
        speaker, message = command_queue.pop(0)
        prompt = True

        if speaker.state == STATE_NAME:
            if message.lower() == "new":
                speaker.state = STATE_CONFIG_NAME
            else:
                a = Archive()
                name = message.strip()
                if a.load(name, speaker):
                    speaker.state = STATE_PASSWORD
                else:
                    speaker.send_line("I do not know that name.", 2)

        elif speaker.state == STATE_PASSWORD:
            password = encrypt_password(message)

            if password == speaker.password:
                # Do a dupe check to ensure no double logins
                # before entering STATE_PLAYING
                w = World()
                dupe = False
                for p in w.players:
                    if p.name == speaker.name:
                        dupe = True
                        speaker.send_line("That name is already active.", 2)
                        speaker.reset()
                        speaker.state = STATE_NAME
                        break

                if not dupe:
                    log("LOGIN", "User <%s> logged in at %s" % (speaker.name, time_string()))
                    speaker.state = STATE_PLAYING

                    # Add player to master players list
                    w.players.append(speaker)

                    # Insert player into default start room and "look"
                    libsigma.enter_room(speaker, w.rooms[options["default_start"]])
                    libsigma.report(libsigma.ROOM, "$actor has entered the game.", speaker)
                    speaker.send_line("", 2)
                    libsigma.queue_command(speaker, "look")
                    prompt = False

            else:
                speaker.send_line("Incorrect password.", 2)
                speaker.reset()
                speaker.state = STATE_NAME

        elif speaker.state == STATE_CONFIG_NAME:
            name = message.strip()
            a = Archive()
            if a.find(name):
                speaker.send_line("That name is already taken. Please choose another.", breaks=2)
            elif not valid_name(name):
                speaker.send_line("You cannot go by that name here.", breaks=2)
            else:
                speaker.name=name
                speaker.state=STATE_CONFIG_PASSWORD

        elif speaker.state == STATE_CONFIG_PASSWORD:
            if not valid_password(message):
                speaker.send_line("Please make your password at least five simple characters.", breaks=2)
            else:
                speaker.password = encrypt_password(message)
                speaker.state=STATE_CONFIG_CHAR
                creation.send_options(speaker)

        elif speaker.state == STATE_CONFIG_CHAR:
            if not creation.check_choice(speaker, message.lstrip()):
                speaker.send_line("Please make a valid choice.")
            if creation.is_configured(speaker):
                for stat in stats:
                    if speaker.stats[stat]==DEFAULT_STAT:
                        speaker.stats[stat]=3
                libsigma.add_points(speaker,5)

                speaker.state = STATE_PLAYING
                w = World()
                w.players.append(speaker)
                libsigma.enter_room(speaker, w.rooms[options["default_start"]])
                libsigma.report(libsigma.ROOM, "$actor has entered the game.", speaker)
                speaker.send_line("", 2)
                libsigma.queue_command(speaker, "look")
                speaker.HP=speaker.max_HP
            else:
                creation.send_options(speaker)

        elif speaker.state == STATE_PLAYING:
            if not run_command(speaker, message):
                speaker.send_line("What?")

        if speaker.socket and prompt:
            speaker.send_prompt()
示例#5
0
def process_commands():
    while len(command_queue) > 0:
        speaker, message = command_queue.pop(0)
        prompt = True

        if speaker.state == STATE_NAME:
            if message.lower() == "new":
                speaker.state = STATE_CONFIG_NAME
            else:
                a = Archive()
                name = message.strip()
                if a.load(name, speaker):
                    speaker.state = STATE_PASSWORD
                else:
                    speaker.send_line("I do not know that name.", 2)

        elif speaker.state == STATE_PASSWORD:
            password = encrypt_password(message)

            if password == speaker.password:
                # Do a dupe check to ensure no double logins
                # before entering STATE_PLAYING
                w = World()
                dupe = False
                for p in w.players:
                    if p.name == speaker.name:
                        dupe = True
                        speaker.send_line("That name is already active.", 2)
                        speaker.reset()
                        speaker.state = STATE_NAME
                        break

                if not dupe:
                    log(
                        "LOGIN", "User <%s> logged in at %s" %
                        (speaker.name, time_string()))
                    speaker.state = STATE_PLAYING

                    # Add player to master players list
                    w.players.append(speaker)

                    # Insert player into default start room and "look"
                    libsigma.enter_room(speaker,
                                        w.rooms[options["default_start"]])
                    libsigma.report(libsigma.ROOM,
                                    "$actor has entered the game.", speaker)
                    speaker.send_line("", 2)
                    libsigma.queue_command(speaker, "look")
                    prompt = False

            else:
                speaker.send_line("Incorrect password.", 2)
                speaker.reset()
                speaker.state = STATE_NAME

        elif speaker.state == STATE_CONFIG_NAME:
            name = message.strip()
            a = Archive()
            if a.find(name):
                speaker.send_line(
                    "That name is already taken. Please choose another.",
                    breaks=2)
            elif not valid_name(name):
                speaker.send_line("You cannot go by that name here.", breaks=2)
            else:
                speaker.name = name
                speaker.state = STATE_CONFIG_PASSWORD

        elif speaker.state == STATE_CONFIG_PASSWORD:
            if not valid_password(message):
                speaker.send_line(
                    "Please make your password at least five simple characters.",
                    breaks=2)
            else:
                speaker.password = encrypt_password(message)
                speaker.state = STATE_CONFIG_CHAR
                creation.send_options(speaker)

        elif speaker.state == STATE_CONFIG_CHAR:
            if not creation.check_choice(speaker, message.lstrip()):
                speaker.send_line("Please make a valid choice.")
            if creation.is_configured(speaker):
                for stat in stats:
                    if speaker.stats[stat] == DEFAULT_STAT:
                        speaker.stats[stat] = 3
                libsigma.add_points(speaker, 5)

                speaker.state = STATE_PLAYING
                w = World()
                w.players.append(speaker)
                libsigma.enter_room(speaker, w.rooms[options["default_start"]])
                libsigma.report(libsigma.ROOM, "$actor has entered the game.",
                                speaker)
                speaker.send_line("", 2)
                libsigma.queue_command(speaker, "look")
                speaker.HP = speaker.max_HP
            else:
                creation.send_options(speaker)

        elif speaker.state == STATE_PLAYING:
            if not run_command(speaker, message):
                speaker.send_line("What?")

        if speaker.socket and prompt:
            speaker.send_prompt()