Beispiel #1
0
def cmd_quit(ch, argument):
    if ch.is_npc():
        return

    if ch.position == merc.POS_FIGHTING:
        ch.send("No way! You are fighting.\n")
        return

    if ch.position < merc.POS_SLEEPING:
        ch.send("You're not DEAD yet.\n")
        return

    mount = ch.mount
    if mount:
        ch.cmd_dismount("")

    # After extract_char the ch is no longer valid!
    for item_id in ch.equipped.values():
        if not item_id:
            continue

        item = instance.items[item_id]

        if not ch.is_npc() and (item.chobj and not item.chobj.is_npc() and item.chobj.obj_vnum != 0) or item.item_type == merc.ITEM_KEY:
            ch.unequip(item.equipped_to, silent=True, forced=True)

    ch.save(logout=True, force=True)

    if ch.obj_vnum != 0:
        handler_game.act("$n slowly fades out of existance.", ch, None, None, merc.TO_ROOM)
    else:
        handler_game.act("$n has left the game.", ch, None, None, merc.TO_ROOM)

    comm.notify("{} has quit.".format(ch.name), merc.CONSOLE_INFO)
    if ch.obj_vnum == 0:
        comm.info("{} has left the God Wars.".format(ch.name))

    if ch.chobj:
        ch.chobj.extract()

    ch.send("\n           I'm a lean dog, a keen dog, a wild dog, and lone;\n"
            "           I'm a rough dog, a tough dog, hunting on my own;\n"
            "           I'm a bad dog, a mad dog, teasing silly sheep;\n"
            "           I love to sit and bay the moon, to keep fat souls from sleep.\n\n")

    d = ch.desc
    pid = ch.id
    ch.extract(True)

    if d:
        comm.close_socket(d)

    # toast evil cheating bastards
    for d in instance.descriptor_list[:]:
        tch = handler_ch.ch_desc(d)
        if tch and tch.id == pid:
            tch.extract(True)
            comm.close_socket(d)
def cmd_reboot(ch, argument):
    ch.cmd_echo("Reboot by {}.".format(ch.name))
    comm.down = True

    for d in instance.descriptor_list[:]:
        vch = handler_ch.ch_desc(d)
        if vch:
            vch.save(logout=True, force=True)
            comm.close_socket(d)
Beispiel #3
0
def cmd_shutdown(ch, argument):
    buf = "Shutdown by {}.".format(ch.name)
    ch.cmd_echo(buf)
    game_utils.append_file(ch, settings.SHUTDOWN_FILE, buf)
    comm.done = True

    for d in instance.descriptor_list[:]:
        vch = handler_ch.ch_desc(d)
        if vch:
            vch.save(logout=True, force=True)
            comm.close_socket(d)

    if pywars.server:
        pywars.server.stop()
Beispiel #4
0
def cmd_who(ch, argument):
    ilevellower = 0
    ilevelupper = merc.MAX_LEVEL
    fclassrestrict = False
    fimmortalonly = False
    nmatch = 0

    # Parse arguments.
    while True:
        argument, arg = game_utils.read_word(argument)
        if not arg:
            break

        if arg.isdigit():
            ch.send("Enter 'Avatar' for level 3's, or 'God' for level 4's and 5's.\n")
            return

        if game_utils.str_cmp(arg, ["imm", "immortal", "ava", "avatar"]):
            fclassrestrict = True
        elif game_utils.str_cmp(arg, ["god", "imp"]):
            fimmortalonly = True
        else:
            ch.send("Enter 'Avatar' for level 3's, or 'God' for level 4's and 5's.\n")
            return

    class_str = ""

    # Now show matching chars.
    for d in instance.descriptor_list:
        # Check for match against restrictions.
        # Don't use trust as that exposes trusted mortals.
        if not d.is_connected(nanny.con_playing) or not ch.can_see(d.character):
            continue

        wch = handler_ch.ch_desc(d)
        if wch.level < ilevellower or wch.level > ilevelupper or \
                (fimmortalonly and wch.level < merc.LEVEL_IMMORTAL) or \
                (fclassrestrict and wch.level != merc.LEVEL_HERO):
            continue

        nmatch += 1

        # Figure out what to print for class.
        if (wch.head.is_set(merc.LOST_HEAD) or wch.extra.is_set(merc.EXTRA_OSWITCH)) and wch.chobj:
            if wch.chobj.vnum == merc.OBJ_VNUM_SEVERED_HEAD:
                title = "A Head       "
            elif wch.chobj.vnum == merc.OBJ_VNUM_QUIVERING_BRAIN:
                title = "A Brain      "
            else:
                title = "An Object    "
        else:
            if wch.level == merc.MAX_LEVEL - 0:
                title = "Implementor  "
            elif wch.level == merc.MAX_LEVEL - 1:
                title = "High Judge   "
            elif wch.level == merc.MAX_LEVEL - 2:
                title = "Judge        "
            elif wch.level == merc.MAX_LEVEL - 3:
                title = "Enforcer     "
            elif wch.level == merc.MAX_LEVEL - 4:
                title = "Quest Maker  "
            elif wch.level == merc.MAX_LEVEL - 5:
                title = "Builder      "
            elif wch.level in [merc.MAX_LEVEL - 6, merc.MAX_LEVEL - 7, merc.MAX_LEVEL - 8,
                               merc.MAX_LEVEL - 9]:
                if wch.race <= 0:
                    title = "Avatar       "
                elif wch.race <= 4:
                    title = "Immortal     "
                elif wch.race <= 9:
                    title = "Godling      "
                elif wch.race <= 14:
                    title = "Demigod      "
                elif wch.race <= 19:
                    title = "Lesser God   "
                elif wch.race <= 24:
                    title = "Greater God  "
                else:
                    title = "Supreme God  "
            elif wch.level in [merc.MAX_LEVEL - 10, merc.MAX_LEVEL - 11, merc.MAX_LEVEL - 12]:
                title = "Mortal       "
            else:
                title = "Bugged       "

        if wch.is_vampire():
            openb = "<"
            closeb = ">"
        elif wch.is_werewolf():
            openb = "("
            closeb = ")"
        elif wch.is_demon():
            openb = "["
            closeb = "]"
        elif wch.is_mage():
            openb = "{"
            closeb = "}"
        else:
            openb = "["
            closeb = "]"

        if game_utils.str_cmp(wch.ch_class.name, "demon"):
            if wch.special.is_set(merc.SPC_DEMON_LORD):
                kav = ". {}Demon Lord{}".format(openb, closeb)
            else:
                if wch.special.is_set(merc.SPC_PRINCE):
                    kav = ". {}Demon Prince{}{}".format(openb, "ss" if wch.sex == merc.SEX_FEMALE else "",
                                                        closeb)
                elif wch.special.is_set(merc.SPC_SIRE):
                    kav = ". {}Demon{}".format(openb, closeb)
                else:
                    kav = ". {}Champion of {}{}".format(openb, wch.lord, closeb)
        elif game_utils.str_cmp(wch.ch_class.name, "vampire"):
            if wch.powers[merc.UNI_GEN] == 1:
                kav = ". {}Master Vampire{}".format(openb, closeb)
            elif wch.powers[merc.UNI_GEN] == 2:
                kav = ". {}Founder of {}{}".format(openb, wch.clan, closeb)
            elif wch.special.is_set(merc.SPC_PRINCE):
                kav = ". {}{} Prince{}{}".format(openb, wch.clan,
                                                 "ss" if wch.sex == merc.SEX_FEMALE else "", closeb)
            else:
                if wch.special.is_set(merc.SPC_INCONNU):
                    clanname = "Inconnu"
                elif wch.special.is_set(merc.SPC_ANARCH):
                    clanname = "Anarch"
                elif not wch.clan:
                    clanname = "Caitiff"
                else:
                    clanname = wch.clan

                if wch.powers[merc.UNI_GEN] == 2:
                    kav = ". {}{} Antediluvian{}".format(openb, clanname, closeb)
                else:
                    rank_list = [(merc.AGE_NEONATE, "Neonate"), (merc.AGE_ANCILLA, "Ancilla"), (merc.AGE_ELDER, "Elder"),
                                 (merc.AGE_METHUSELAH, "Methuselah")]
                    for (aa, bb) in rank_list:
                        if wch.rank == aa:
                            kav = ". {}{} {}{}".format(openb, clanname, bb, closeb)
                            break
                    else:
                        kav = ". {}{} Childe{}".format(openb, clanname, closeb)
        elif game_utils.str_cmp(wch.name, "werewolf"):
            if wch.powers[merc.UNI_GEN] == 1:
                kav = ". {}Master Werewolf{}".format(openb, closeb)
            elif wch.clan:
                if wch.powers[merc.UNI_GEN] == 2:
                    kav = ". {}{} Chief{}".format(openb, wch.clan, closeb)
                elif wch.special.is_set(merc.SPC_PRINCE):
                    kav = ". {}{} Shaman{}".format(openb, wch.clan, closeb)
                else:
                    kav = ". {}{}{}".format(openb, wch.clan, closeb)
            else:
                kav = ". {}Ronin{}".format(openb, closeb)
        elif game_utils.str_cmp(wch.ch_class.name, "mage"):
            mage_list = [(merc.RED_MAGIC, "Red"), (merc.BLUE_MAGIC, "Blue"), (merc.GREEN_MAGIC, "Green"), (merc.YELLOW_MAGIC, "Yellow")]
            for (aa, bb) in mage_list:
                if wch.powers[merc.MPOWER_RUNE0] == aa:
                    mage_col = bb
                    break
            else:
                mage_col = "Purple"

            if wch.level == merc.LEVEL_APPRENTICE:
                kav = ". {}{} Apprentice{}".format(openb, mage_col, closeb)
            elif wch.level == merc.LEVEL_MAGE:
                kav = ". {}{} Mage{}".format(openb, mage_col, closeb)
            else:
                kav = ". {}{} Archmage{}".format(openb, mage_col, closeb)
        elif game_utils.str_cmp(wch.ch_class.name, "highlander"):
            kav = ". {}Highlander{}".format(openb, closeb)
        else:
            kav = "."

        class_str += "{} {}{}{}\n".format(title, wch.name, wch.title, kav)

    buf = ["--------------------------------------------------------------------------------\n"]
    buf += class_str
    buf += "--------------------------------------------------------------------------------\n"

    if nmatch == 1:
        buf += "You are the only visible player connected!\n"
    else:
        buf += "There are a total of {} visible players connected.\n".format(nmatch)

    buf += "--------------------------------------------------------------------------------\n"
    ch.send("".join(buf))
def substitute_alias(d, argument):
    ch = handler_ch.ch_desc(d)
    stop_idling(ch)
    ch.interpret(argument)