예제 #1
0
def cmd_time(ch, argument):
    day = handler_game.time_info.day + 1

    if day in merc.irange(5, 19):
        suf = "th"
    elif day % 10 == 1:
        suf = "st"
    elif day % 10 == 2:
        suf = "nd"
    elif day % 10 == 3:
        suf = "rd"
    else:
        suf = "th"

    ch.send("It is {} o'clock {}, Day of {}, {}{} the Month of {}.\n".format(
        12 if (handler_game.time_info.hour % 12 == 0) else handler_game.time_info.hour % 12,
        "pm" if handler_game.time_info.hour >= 12 else "am",
        day_name[day % 7], day, suf, month_name[handler_game.time_info.month]))
    ch.send("God Wars started up at {}\n".format(sys_utils.systimestamp(merc.boot_time)))
    ch.send("The system time is {}\n".format(sys_utils.systimestamp(merc.current_time)))
예제 #2
0
def cmd_note(ch, argument):
    argument, arg = game_utils.read_word(argument)

    if ch.is_npc():
        return

    if game_utils.str_cmp(arg, "list"):
        if not instance.note_list:
            ch.send("There are no notes.\n")
            return

        buf = []
        vnum = 0
        for note in instance.note_list:
            if is_note_to(ch, note):
                buf += "[{:>3}] {}: {}\n".format(vnum, note.sender,
                                                 note.subject)
                vnum += 1
        ch.send("".join(buf))
        return

    if game_utils.str_cmp(arg, "read"):
        if game_utils.str_cmp(argument, "all"):
            fall = True
            anum = 0
        elif argument.isdigit():
            fall = False
            anum = int(argument)
        else:
            ch.send("Note read which number?\n")
            return

        vnum = 0
        for note in instance.note_list:
            if is_note_to(ch, note) and (vnum == anum or fall):
                buf = [
                    "[{:>3}] {}: {}\n{}\nTo: {}\n\n".format(
                        vnum, note.sender, note.subject, note.date,
                        note.to_list)
                ]
                buf += note.text + "\n"
                ch.send("".join(buf))
                return

            vnum += 1
        ch.send("No such note.\n")
        return

    if game_utils.str_cmp(arg, "+"):
        note_attach(ch)
        buf = ch.pnote.text

        if len(buf) + len(argument) >= settings.MAX_STRING_LENGTH - 4:
            ch.send("Note too long.\n")
            return

        ch.pnote.text = buf + "\n" if buf else "" + argument
        ch.send("Ok.\n")
        return

    if game_utils.str_cmp(arg, "subject"):
        note_attach(ch)
        ch.pnote.subject = argument
        ch.send("Ok.\n")
        return

    if game_utils.str_cmp(arg, "to"):
        note_attach(ch)
        ch.pnote.to_list = argument
        ch.send("Ok.\n")
        return

    if game_utils.str_cmp(arg, "clear"):
        if ch.pnote:
            del ch.pnote
            ch.pnote = None
        ch.send("Ok.\n")
        return

    if game_utils.str_cmp(arg, "show"):
        if not ch.pnote:
            ch.send("You have no note in progress.\n")
            return

        ch.send("{}: {}\n"
                "To: {}\n".format(ch.pnote.sender, ch.pnote.subject,
                                  ch.pnote.to_list))
        ch.send(ch.pnote.text)
        return

    if game_utils.str_cmp(arg, "post"):
        if not ch.pnote:
            ch.send("You have no note in progress.\n")
            return

        if not ch.extra.is_set(merc.EXTRA_NOTE_TRUST):
            ch.send("Due to abuse you must now get note trusted.\n")
            return

        ch.pnote.date = sys_utils.systimestamp(merc.current_time)
        instance.note_list.append(ch.pnote)
        del ch.pnote
        ch.pnote = None
        world_classes.Note.save()
        ch.send("Ok.\n")
        return

    if game_utils.str_cmp(arg, "remove"):
        if not argument.isdigit():
            ch.send("Note remove which number?\n")
            return

        anum = int(argument)
        vnum = 0
        for note in instance.note_list:
            if is_note_to(ch, note) and vnum == anum:
                note_remove(ch, note)
                ch.send("Ok.\n")
                return

            vnum += 1

        ch.send("No such note.\n")
        return

    ch.send("Huh?  Type 'help note' for usage.\n")
예제 #3
0
    def years_old(self):
        total = 0
        yy = 17
        oday2 = 0
        omonth2 = 0
        oyear2 = 0
        argument = sys_utils.systimestamp(self.createtime)
        omonth = argument[4:7]
        oday0 = argument[8]
        oday1 = argument[9]
        ohour = argument[11:13]
        omin = argument[14:16]
        oyear = argument[20:24]

        if game_utils.str_cmp(
                omonth, ["Dec", "Oct", "Aug", "Jul", "May", "Mar", "Jan"]):
            omonth2 += 31
        elif game_utils.str_cmp(omonth, ["Nov", "Sep", "Jun", "Apr"]):
            omonth2 += 30
        elif game_utils.str_cmp(omonth, "Feb"):
            omonth2 += 28
        else:
            return yy

        cday2 = 0
        cmonth2 = 0
        cyear2 = 0
        current = sys_utils.systimestamp(merc.current_time)
        cmonth = current[4:7]
        cday0 = current[8]
        cday1 = current[9]
        chour = current[11:13]
        cmin = current[14:16]
        cyear = current[20:24]

        if game_utils.str_cmp(
                cmonth, ["Dec", "Oct", "Aug", "Jul", "May", "Mar", "Jan"]):
            cmonth2 += 31
        elif game_utils.str_cmp(cmonth, ["Nov", "Sep", "Jun", "Apr"]):
            cmonth2 += 30
        elif game_utils.str_cmp(cmonth, "Feb"):
            cmonth2 += 28
        else:
            return yy

        oyear2 += int(oyear) if oyear.isdigit() else 0
        cyear2 += int(cyear) if cyear.isdigit() else 0
        oday2 += (int(oday0) * 10) if oday0.isdigit() else 0
        oday2 += int(oday1) if oday1.isdigit() else 0
        cday2 += (int(cday0) * 10) if cday0.isdigit() else 0
        cday2 += int(cday1) if cday1.isdigit() else 0

        total += (cyear2 - oyear2) * 365
        total += cmonth2 - omonth2
        total += cday2 - oday2
        total *= 24  # Total playing time is now in hours

        if chour.isdigit() and ohour.isdigit():
            total += int(chour) - int(ohour)
        total *= 60  # Total now in minutes

        if cmin.isdigit() and omin.isdigit():
            total += int(cmin) - int(omin)

        if total < 1:
            total = 0
        else:
            total //= 12  # Time now in game days

        while total >= 365:
            total -= 365
            yy += 1
        return yy
예제 #4
0
    def other_age(self, is_self=False):
        total = 0
        yy = 17
        mm = 0
        dd = 0
        oday2 = 0
        omonth2 = 0
        oyear2 = 0
        argument = sys_utils.systimestamp(self.createtime)
        omonth = argument[4:7]
        oday0 = argument[8]
        oday1 = argument[9]
        ohour = argument[11:13]
        omin = argument[14:16]
        oyear = argument[20:24]

        if game_utils.str_cmp(
                omonth, ["Dec", "Oct", "Aug", "Jul", "May", "Mar", "Jan"]):
            omonth2 += 31
        elif game_utils.str_cmp(omonth, ["Nov", "Sep", "Jun", "Apr"]):
            omonth2 += 30
        elif game_utils.str_cmp(omonth, "Feb"):
            omonth2 += 28
        else:
            return "Error! Please inform an Immortal.\n"

        cday2 = 0
        cmonth2 = 0
        cyear2 = 0
        current = sys_utils.systimestamp(merc.current_time)
        cmonth = current[4:7]
        cday0 = current[8]
        cday1 = current[9]
        chour = current[11:13]
        cmin = current[14:16]
        cyear = current[20:24]

        if game_utils.str_cmp(
                cmonth, ["Dec", "Oct", "Aug", "Jul", "May", "Mar", "Jan"]):
            cmonth2 += 31
        elif game_utils.str_cmp(cmonth, ["Nov", "Sep", "Jun", "Apr"]):
            cmonth2 += 30
        elif game_utils.str_cmp(cmonth, "Feb"):
            cmonth2 += 28
        else:
            return "Error! Please inform an Immortal.\n"

        oyear2 += int(oyear) if oyear.isdigit() else 0
        cyear2 += int(cyear) if cyear.isdigit() else 0
        oday2 += (int(oday0) * 10) if oday0.isdigit() else 0
        oday2 += int(oday1) if oday1.isdigit() else 0
        cday2 += (int(cday0) * 10) if cday0.isdigit() else 0
        cday2 += int(cday1) if cday1.isdigit() else 0

        total += (cyear2 - oyear2) * 365
        total += cmonth2 - omonth2
        total += cday2 - oday2
        total *= 24  # Total playing time is now in hours

        if chour.isdigit() and ohour.isdigit():
            total += int(chour) - int(ohour)
        total *= 60  # Total now in minutes

        if cmin.isdigit() and omin.isdigit():
            total += int(cmin) - int(omin)

        if total < 1:
            total = 0
        else:
            total //= 12  # Time now in game days

        while True:
            if total >= 365:
                total -= 365
                yy += 1
            elif total >= 30:
                total -= 30
                mm += 1
            else:
                dd += total
                break

        if is_self:
            buf = "You are {} years, {} month{} and {} day{} old.\n".format(
                yy, mm, "" if mm == 1 else "s", dd, "" if dd == 1 else "s")
        else:
            buf = "Age: {} years, {} month{} and {} day{} old.\n".format(
                yy, mm, "" if mm == 1 else "s", dd, "" if dd == 1 else "s")
        return buf
예제 #5
0
def cmd_finger(ch, argument):
    if not argument:
        ch.send("Usage: finger <victim>\n")
        return

    if not nanny.check_parse_name(argument):
        ch.send("Thats an illegal name.\n")
        return

    ch_dummy = nanny.CharDummy()
    ch_dummy.stub = handler_pc.Pc.load_stub(argument, silent=True)
    if not ch_dummy.stub:
        ch.send("That player doesn't exist.\n")
        del ch_dummy
        return

    buf = [
        "--------------------------------------------------------------------------------\n"
    ]
    buf += "{}{}.\n".format(ch_dummy.stub["name"], ch_dummy.stub["title"])
    buf += "--------------------------------------------------------------------------------\n"

    if ch.is_immortal():
        buf += "Last connected from {} at {}.\n".format(
            ch_dummy.stub["last_host"],
            sys_utils.systimestamp(ch_dummy.stub["last_time"]))
    else:
        buf += "Last connected from ***.***.***.*** at {}.\n".format(
            sys_utils.systimestamp(ch_dummy.stub["last_time"]))

    buf += "--------------------------------------------------------------------------------\n"
    buf += "Sex: {}. ".format(
        tables.sex_table[ch_dummy.stub["sex"]].capitalize())
    buf += ch.other_age(is_self=False)

    if ch_dummy.stub["level"] >= merc.LEVEL_IMMORTAL:
        level_list = [(merc.LEVEL_HIGHJUDGE, " High Judge"),
                      (merc.LEVEL_JUDGE, " Judge"),
                      (merc.LEVEL_ENFORCER, "n Enforcer"),
                      (merc.LEVEL_QUESTMAKER, " Quest Maker"),
                      (merc.LEVEL_BUILDER, " Builder")]
        for (aa, bb) in level_list:
            if ch_dummy.stub["level"] == aa:
                buf += "They are a{}, ".format(bb)
                break
        else:
            buf += "They are an Implementor, "
    else:
        level_list = [(1, "n Avatar"), (5, "n Immortal"), (10, " Godling"),
                      (15, " Demigod"), (20, " Lesser God"),
                      (25, " Greater God")]
        for (aa, bb) in level_list:
            if ch_dummy.stub["race"] < aa:
                buf += "They are a{}, ".format(bb)
                break
        else:
            buf += "They are a Supreme God, "

    played = ch_dummy.stub["played"]
    played = (2 * (played // 7200)) if played > 0 else 0
    buf += "and have been playing for {} hours.\n".format(played)

    if ch_dummy.stub["marriage"]:
        buf += "They are {} to {}.\n".format(
            "married" if state_checks.is_set(
                ch_dummy.stub["extra"], merc.EXTRA_MARRIED) else "engaged",
            ch_dummy.stub["marriage"])

    buf += "Player kills: {}, Player Deaths: {}.\n".format(
        ch_dummy.stub["pkills"], ch_dummy.stub["pdeaths"])
    buf += "Mob kills: {}, Mob Deaths: {}.\n".format(ch_dummy.stub["mkills"],
                                                     ch_dummy.stub["mdeaths"])
    buf += "--------------------------------------------------------------------------------\n"

    if ch_dummy.stub["email"]:
        buf += "Email: {}\n".format(ch_dummy.stub["email"])
        buf += "--------------------------------------------------------------------------------\n"
    ch.send("".join(buf))
    del ch_dummy