Пример #1
0
def item_menu(ctrl):
    smenu = []
    for itm, person, valid in ctrl.items:
        suffix_list = []
        if len(ctrl.persons) > 1:
            suffix_list.append("持有人:%s" %
                               ui.colored(person.name, attrs=["bold"]))
        if "Equip" in itm.tags:
            suffix_list.append("数量:1,耐久度:%s/%s" %
                               (itm.durability_current, itm.durability))
        else:
            suffix_list.append("数量:%s" % person.quantities[itm.tpl_id])
        if ctrl.showmoney and itm.tpl_id != "ITEM_MONEY":
            if ctrl.moneystyle == 0:
                money_num = itm.money
            else:
                money_num = int(itm.money * 0.4)
            suffix_list.append("价值:%s" % ui.byellow(money_num))
        if itm in person.equipment:
            suffix_list.append(ui.colored("装备中", color="green"))
        suffix = "(%s)" % ",".join(suffix_list)
        if not valid:
            mitem = ui.menuitem(itm.name + ui.bgrey(suffix),
                                value=(itm, person),
                                validator=lambda x: False)
        else:
            comments = ui.item(itm)
            mitem = ui.menuitem(ui.rank(itm) + suffix,
                                comments=comments,
                                value=(itm, person),
                                goto=ctrl.select)
        smenu.append(mitem)
    return smenu
Пример #2
0
def create_role(args):
    #xing = ui.read("请输入你的姓氏:",
    #               handler=lambda x: x if len(x.strip()) > 0 else None)
    #ui.echo()
    #ming = ui.read("请输入你的名字:",
    #               handler=lambda x: x if len(x.strip()) > 0 else None)
    #ui.echo()
    #sex = ui.menu(sex_menu, title="请选择你的性别:")
    lead = Person.one("PERSON_PLAYER")
    while True:
        #lead = person.create_player(xing, ming, sex)
        lead.random()
        ui.echo()
        ui.echo(ui.colored("你的初始特质如下", attrs=["bold"]))
        ui.echo()
        ui.echo(person_info(lead))
        ui.echo()
        ui.echo(ui.colored("属性介绍", attrs=["bold"]))
        ui.echo()
        ui.echo(attr_info())
        ui.echo()
        if ui.sure(msg.ACCEPT):
            break
    ui.echo()
    runtime.MODULE.scripts.start()
Пример #3
0
def handler_battle_skill(ac):
    map = ac.battle.map
    if len(ac.objects) == 0:
        ui.echo()
        ui.echo("攻击范围内无目标!")
        ui.read()
    elif ac.critical:
        if not ui.blankline():
            ui.echo()
        criticaltxt = ac.subject.criticaltxt
        if criticaltxt is None:
            criticaltxt = "接我这招!"
        ui.echo(
            ui.colored("%s:%s" % (ac.subject.name, criticaltxt),
                       color="yellow",
                       attrs=["bold"]))
        ui.read()
    for obj in ac.anti_list:
        if not ui.blankline():
            ui.echo()
        antitxt = "可惜,这一招已经被我看破了!"
        ui.echo(
            ui.colored("%s:%s" % (obj.name, antitxt),
                       color="yellow",
                       attrs=["bold"]))
        ui.read()
    ui.echo()
    ui.map(map, entities=battle_person_handler(ac.snapshot, show_events=True))
    ui.echo()
    ui.read("(回车继续)")
Пример #4
0
def skill_equipped(p):
    ret = []
    if p.studying is not None:
        ret.append("【当前修炼】%s:%s(进度:%s/%s)" % (ui.rank(
            p.studying.belongs), ui.rank(p.studying), p.exp, p.studying.exp))
    else:
        ret.append(ui.colored("【当前修炼】无", color="grey", attrs=["bold"]))
    ret.append("")
    if p.running is not None:
        ret.append("【运行心法】%s" % ui.rank(p.running))
        isk_str = ui.inner_skill(p.running, p)
        for isk in isk_str:
            ret.append("            %s" % isk)
    else:
        ret.append(ui.colored("【运行心法】无", color="grey", attrs=["bold"]))
    ret.append("")
    str_list = [
        "一",
        "二",
        "三",
        "四",
        "五",
        "六",
        "七",
        "八",
        "九",
    ]
    asc_idx = 0
    for sk in p.skills_equipped:
        if sk is None:
            ret.append(
                ui.colored("【技能%s】无" % str_list[asc_idx],
                           color="grey",
                           attrs=["bold"]))
        else:
            comments = [ui.skill(sk)]
            for effe in sk.effects:
                comments.append(ui.effect(effe))
            ret.append("【技能%s】%s:%s" %
                       (str_list[asc_idx], ui.rank(sk.belongs), ui.rank(sk)))
            for c in comments:
                ret.append("          %s" % c)
        asc_idx += 1
    ret.append("")
    if p.skill_counter is not None:
        ret.append(
            "【辅助技能】%s:%s" %
            (ui.rank(p.skill_counter.belongs), ui.rank(p.skill_counter)))
        comments = [ui.skill(p.skill_counter)]
        for effe in p.skill_counter.effects:
            comments.append(ui.effect(effe))
        for c in comments:
            ret.append("            %s" % c)
    else:
        ret.append(ui.colored("【辅助技能】无", color="grey", attrs=["bold"]))
    return ret
Пример #5
0
def handler_battle_sequence(ctrl):
    if not ui.blankline():
        ui.echo()
    ret = []
    for p in [ctrl.battle.current] + ctrl.acseq:
        if ctrl.battle.is_friend(ctrl.battle.current, p):
            ret.append(ui.colored(p.name, color="cyan", attrs=["bold"]))
        else:
            ret.append(ui.colored(p.name, color="red", attrs=["bold"]))
    ui.echo("当前行动顺序如下:")
    ui.echo()
    ui.echo("->".join(ret))
    ui.echo()
    ui.read("(回车继续)")
    ctrl.launch()
Пример #6
0
def handler_superskill_control(ctrl):
    if not ui.blankline():
        ui.echo()
    ui.superskill(ctrl.superskill)
    ui.echo()
    for idx, nd in enumerate(ctrl.superskill.nodes):
        comments = [nd.description]
        for nt in nd.tags:
            if nt.startswith("SKILL_"):
                sk = Skill.one(nt)
                if "Neigong" not in sk.style:
                    comments.append("%s" % ui.skill(sk))
                    for effe in sk.effects:
                        comments.append(ui.effect(effe))
                else:
                    for effe in sk.effects:
                        comments.append(ui.effect(effe.exertion))
        ui.echo(ui.colored("【%s】- " % (idx + 1) + nd.name, attrs=["bold"]))
        for c in comments:
            ui.echo("       " + c)
    ret = ui.menu([],
                  title=ctrl.title,
                  shownone=False,
                  goback=True,
                  backmethod=ctrl.close)
    return ret
Пример #7
0
def world_menu(team):
    title = ui.colored("队员一览:%s队" % team.leader.name,
                       color="yellow",
                       attrs=["bold"])
    ret = [
        ui.menuitem("移动", goto=lambda x: WorldMovePositionOrder()),
        ui.menuitem("交谈", goto=lambda x: WorldTalkPositionOrder()),
        ui.menuitem("赠与", goto=lambda x: WorldGivePositionOrder()),
        ui.menuitem("探索", goto=lambda x: WorldExplorePositionOrder()),
        ui.menuitem("建设", goto=lambda x: WorldBuildPositionOrder()),
        ui.menuitem("攻击", goto=lambda x: WorldAttackPositionOrder()),
        ui.menuitem("休息", goto=lambda x: WorldRestOrder()),
        ui.menuitem(
            "队伍",
            goto=lambda x: ui.menu(member_menu(),
                                   title=title,
                                   goback=True,
                                   backmethod=lambda: WorldPlayerOrder())),
        ui.menuitem(
            "系统",
            goto=lambda x: ui.menu(system_menu,
                                   columns=2,
                                   width=15,
                                   goback=True,
                                   backmethod=lambda: WorldPlayerOrder()))
    ]
    return ret
Пример #8
0
def item_menu(persons,
              obj,
              tags=None,
              showmoney=False,
              moneystyle=0,
              show_comments=True,
              filter=None):
    smenu = []
    for person in persons:
        for itm in person.items:
            show_state = 0
            if filter is not None:
                show_state = filter(person, obj, itm, tags)
            if show_state == 2:
                continue
            suffix_list = []
            if len(persons) > 1:
                suffix_list.append("持有人:%s" %
                                   ui.colored(person.name, attrs=["bold"]))
            if "Equip" in itm.tags:
                suffix_list.append("数量:1,耐久度:%s/%s" %
                                   (itm.durability_current, itm.durability))
            else:
                suffix_list.append("数量:%s" % person.quantities[itm.tpl_id])
            if showmoney and itm.tpl_id != "ITEM_MONEY":
                suffix_list.append("价值:%s" % ui.colored(
                    itm.money if moneystyle == 0 else int(itm.money * 0.4),
                    color="yellow",
                    attrs=["bold"]))
            if itm in person.equipment:
                suffix_list.append(ui.colored("装备中", color="green"))
            suffix = "(%s)" % ",".join(suffix_list)
            if show_state == 1:
                mitem = ui.menuitem(
                    ui.rank(itm) +
                    ui.colored(suffix, color="grey", attrs=["bold"]),
                    value=(itm, person),
                    validator=lambda x: False)
            elif show_comments:
                comments = ui.item(itm)
                mitem = ui.menuitem(ui.rank(itm) + suffix,
                                    comments=comments,
                                    value=(itm, person))
            else:
                mitem = ui.menuitem(ui.rank(itm) + suffix, value=(itm, person))
            smenu.append(mitem)
    return smenu
Пример #9
0
def team_info(map):

    retlist = []

    for loc, entity in map.loc_entity.items():
        ret = {
            "location": None,
            "contents": ["", "", ""],
            "trace": [],
            "player": False
        }
        ret["location"] = map.entity_loc[entity.id]

        if len(entity.members) == 1:
            title = entity.leader.name
        else:
            title = "%s队" % entity.leader.name
        # 处理标题文本
        #if entity.leader.player and platform.system() == "Linux":
        if entity.leader.player:
            ret["player"] = True
            ret["contents"][0] = ui.colored(title,
                                            color="grey",
                                            on_color="on_cyan")
        #elif entity.leader.player:
        #    ret["player"] = True
        #    ret["contents"][0] = ui.colored(title,
        #                                    on_color="on_cyan",
        #                                    attrs=["bold"])
        else:
            ret["contents"][0] = ui.colored(title,
                                            color="cyan",
                                            attrs=["bold"])
        #ret["contents"][0] += fmt.vaka["direction"][str(entity.direction)]
        if entity.battle is not None:
            ret["contents"][1] += ui.colored("(战斗中)",
                                             color="yellow",
                                             attrs=["bold"])

        # 处理路径
        if entity.last_move + context.duration() > context.timestamp and len(
                entity.path) > 1:
            ret["trace"].extend(entity.path)
        retlist.append(ret)
    last_timestamp = context.timestamp
    return retlist
Пример #10
0
def handler_world_attack_select(ctx):
    ret = ui.menu([ui.menuitem(m.name, value=m) for m in ctx.subject.members],
                  title=ui.colored("请选择需要出战的角色:",
                                   color="yellow",
                                   attrs=["bold"]),
                  multiple=True,
                  multiple_range=[1, ctx.number])
    return ret
Пример #11
0
def team_info(ctrl):

    retlist = []

    map = ctrl.scenario

    for loc, entity in map.loc_entity.items():
        ret = {
            "location": None,
            "contents": ["", "", ""],
            "trace": [],
            "player": False
        }
        ret["location"] = map.entity_loc[entity.id]

        if len(entity.members) == 1:
            title = entity.leader.name
        else:
            title = "%s队" % entity.leader.name
        # 处理标题文本
        if entity.leader.player:
            ret["player"] = True
            ret["contents"][0] = ui.colored(title,
                                            color="grey",
                                            on_color="on_cyan")
        else:
            ret["contents"][0] = ui.colored(title,
                                            color="cyan",
                                            attrs=["bold"])
        if entity.battle is not None:
            ret["contents"][1] += ui.colored("(战斗中)",
                                             color="yellow",
                                             attrs=["bold"])

        # 处理路径
        if entity.last_move + context.duration() > context.timestamp and len(
                entity.path) > 1:
            ret["trace"].extend(entity.path)
        retlist.append(ret)
    last_timestamp = context.timestamp
    return retlist
Пример #12
0
def recipe_menu(subject, persons, recipes, filter=None, sub=False):
    str_list = [
        "一",
        "二",
        "三",
        "四",
        "五",
        "六",
        "七",
        "八",
        "九",
    ]
    rmenu = []
    for idx, recipe in enumerate(recipes):
        if filter is not None and not filter(subject, recipe):
            continue
        enabled = recipe.check(persons)
        if len(recipe.materials) == 0:
            comments = ["无"]
        else:
            comments = [",".join(["任意%s" % ui.tag(k) if isinstance(k, str) else ui.rank(k, grey=not enabled) +
                                   ui.colored("×%s" % v, color=None if enabled else "grey", attrs=None if enabled else ["bold"]) \
                                   for k, v in recipe.materials])]
        showword = ("方案%s" % str_list[idx]) if sub else recipe.name
        if enabled:
            if subject not in persons:
                showword += "(费用:%s)" % ui.colored(
                    str(25 + recipe.tmpdict.get("money", 0)),
                    color="yellow",
                    attrs=["bold"])
            rmenu.append(ui.menuitem(showword, value=recipe,
                                     comments=comments))
        else:
            rmenu.append(ui.menuitem(showword + "(材料不足)", value=recipe, comments=comments, \
                                     validator=lambda x: False))
    return rmenu
Пример #13
0
def member_menu():
    team = context.PLAYER.team
    ret = []
    for m in team.members:
        title = lambda x: ui.colored(
            "当前队员:%s" % x.name, color="yellow", attrs=["bold"])
        ret.append(
            ui.menuitem(m.name,
                        value=m,
                        goto=lambda x: ui.menu(team_menu(x),
                                               title=title(x),
                                               goback=True,
                                               columns=4,
                                               width=15)))
    return ret
Пример #14
0
def handler_battle_item_scope(ac):
    map = ac.battle.map
    if ac.battle.current != ac.subject or not ac.battle.controllable():
        ui.echo()
        ui.map(map,
               entities=battle_person_handler(ac.snapshot),
               coordinates=[{
                   "positions": ac.scope,
                   "color": "yellow"
               }],
               show_trace=False)
        ui.echo()
        fstr = "%s使用了物品" % ac.subject.name
        ui.echo(fstr + ui.colored(ui.rank(ac.item, txt="【%s】" % ac.item.name)))
        ui.echo()
        ui.read("(回车继续)")
Пример #15
0
def handler_person_item_choose(ctx):
    showname = "物品一览:%s队" if len(ctx.persons) > 1 else "物品一览:%s"
    if ctx.back:
        ui.popmenu()
    ret = ui.menu(item_menu(ctx.persons,
                            ctx.object,
                            tags=ctx.tags,
                            filter=ctx.filter,
                            showmoney=ctx.showmoney,
                            moneystyle=ctx.moneystyle),
                  title=ui.colored(showname % ctx.subject.name,
                                   color="yellow",
                                   attrs=["bold"]),
                  goback=True,
                  backmethod=ctx.backmethod)
    return ret
Пример #16
0
def handler_effect(ac):
    if ac.effect.name is None:
        return
    effe_details = ac.details
    if effe_details is None:
        effe_details = {}
    for k, v in effe_details.items():
        if "%s_rank" % k in effe_details:
            e_rank = effe_details["%s_rank" % k]
            effe_details[k] = ui.colored("【%s】" % v,
                                         color=ui.rankcolor(e_rank),
                                         attrs=["bold"])
    if not ui.blankline():
        ui.echo()
    ui.echo("%s发动了" % ac.subject.name + \
            ui.effectname(ac.effect, txt="【%s】" % ac.effect.name) + "效果,%s。" % \
            ac.effect.text.format(**effe_details))
    ui.read()
Пример #17
0
def recipe_menu(ctrl):
    str_list = [
        "一",
        "二",
        "三",
        "四",
        "五",
        "六",
        "七",
        "八",
        "九",
    ]
    rmenu = []
    for idx, ownerrecipe in enumerate(ctrl.recipes):
        owner, recipe = ownerrecipe
        enabled = recipe.check(ctrl.persons)
        if len(recipe.materials) == 0:
            comments = ["无"]
        else:
            comments = [",".join(["任意%s" % ui.tag(k) if isinstance(k, str) else ui.rank(k, grey=not enabled) +
                                   ui.colored("×%s" % v, color=None if enabled else "grey", attrs=None if enabled else ["bold"]) \
                                   for k, v in recipe.materials])]
        showword = ("方案%s" % str_list[idx]) if ctrl.sub else recipe.name
        suffix = []
        if enabled:
            if not ctrl.sub:
                suffix.append("持有人:%s" % owner.name)
            if owner not in ctrl.persons:
                suffix.append(
                    "费用:%s" %
                    ui.byellow(str(25 + recipe.tmpdict.get("money", 0))))
            if len(suffix) > 0:
                showword += "(%s)" % ",".join(suffix)
            mitem = ui.menuitem(showword,
                                value=(owner, recipe),
                                comments=comments,
                                goto=ctrl.select)
        else:
            mitem = ui.menuitem(showword + "(材料不足)",
                                comments=comments,
                                validator=lambda x: False)
        rmenu.append(mitem)
    return rmenu
Пример #18
0
def handler_person_equipment(ctx):
    panel = [
        "",
        ui.colored("装备一览:%s" % ctx.subject.name,
                   color="yellow",
                   attrs=["bold"]), ""
    ]
    panel.extend(equipment(ctx.subject))
    if ctx.fromoff:
        ui.popmenu()
    elif ctx.fromon:
        ui.popmenu()
        ui.popmenu()
    ui.menu(equip_menu(ctx.subject),
            title="请选择你要进行的操作:",
            uppanel=panel,
            goback=True,
            columns=2,
            width=19)
Пример #19
0
def handler_person_skill(ctx):
    panel = [
        "",
        ui.colored("技能一览:%s" % ctx.subject.name,
                   color="yellow",
                   attrs=["bold"]), ""
    ]
    panel.extend(skill_equipped(ctx.subject))
    if ctx.fromoff:
        ui.popmenu()
    elif ctx.fromon:
        ui.popmenu()
        ui.popmenu()
    ui.menu(skill_equip_menu(ctx.subject),
            title="请选择你要进行的操作:",
            uppanel=panel,
            goback=True,
            pagesize=8,
            columns=2,
            width=23)
Пример #20
0
def entity_info(map):
    retlist = []

    for loc, entity in map.loc_entity.items():
        ret = {
            "location": None,
            "contents": ["", "", ""],
            "trace": [],
            "player": False
        }
        ret["location"] = loc

        if len(entity.members) == 1:
            name_str = entity.leader.name
        else:
            name_str = "%s队" % entity.leader.name
        ret["contents"][0] = ui.colored(name_str, color="cyan", attrs=["bold"])
        #ret["contents"][0] += fmt.vaka["direction"][str(entity.direction)]
        retlist.append(ret)
    return retlist
Пример #21
0
def person_info(p):
    pf = []
    pf.append("  " + "姓名:" + p.name)
    pf.append("  " + "性别:男")
    pf.append("")
    pf.append("  " + ui.fixed(18, n="灵动:" + ui.colored("%s%%" % (50 + p.dongjing))) + \
                     ui.fixed(18, n="沉静:" + ui.colored("%s%%" % (50 - p.dongjing))))
    pf.append("  " + ui.fixed(18, n="刚猛:" + ui.colored("%s%%" % (50 + p.gangrou))) + \
                     ui.fixed(18, n="柔易:" + ui.colored("%s%%" % (50 - p.gangrou))))
    pf.append("  " + ui.fixed(18, n="颖悟:" + ui.colored("%s%%" % (50 + p.zhipu))) + \
                     ui.fixed(18, n="朴拙:" + ui.colored("%s%%" % (50 - p.zhipu))))
    pf.append("")
    pf.append("  " + ui.fixed(18, n="内力阴性:" + ui.colored("%s%%" % (50 - p.yinyang), color="cyan")) + \
                     ui.fixed(18, n="内力阳性:" + ui.colored("%s%%" % (50 + p.yinyang), color="yellow")))
    pf.append("")
    pf.append("  " + ui.fixed(18, n="内功:%s" % p.neigong))
    pf.append("  " + ui.fixed(18, n="搏击:%s" % p.boji) +
              ui.fixed(15, n="剑法:%s" % p.jianfa))
    pf.append("  " + ui.fixed(18, n="刀法:%s" % p.daofa) +
              ui.fixed(15, n="长兵:%s" % p.changbing))
    pf.append("  " + ui.fixed(18, n="暗器:%s" % p.anqi) +
              ui.fixed(15, n="奇门:%s" % p.qimen))
    return pf
Пример #22
0
def handler_person_recipe_choose(ctx):
    if ctx.title is None:
        showname = ui.colored("配方一览:%s" %
                              "、".join([p.name for p in ctx.candidates]),
                              color="yellow",
                              attrs=["bold"])
    else:
        showname = ctx.title
    if ctx.recipes is not None:
        recipes = ctx.recipes
    else:
        recipes = []
        for p in ctx.candidates:
            recipes.extend(p.recipes)
    ret = ui.menu(recipe_menu(ctx.subject,
                              persons=ctx.persons,
                              recipes=recipes,
                              sub=ctx.sub,
                              filter=ctx.filter),
                  title=showname,
                  goback=True)
    return ret
Пример #23
0
def profile(p):
    pf = []
    pf.append("【基本情况】")
    pf.append("")
    pf.append("  " + ui.fixed(18, n="气血:%s/%s" % (p.hp, p.hp_limit)))
    pf.append("  " + ui.fixed(18, n="内力:%s/%s" % (p.mp, p.mp_limit)))
    pf.append("")
    pf.append("  " + ui.fixed(18, n="外伤:" + ui.colored(str(p.injury), color=None if p.injury == 0 else "red")) + \
                     ui.fixed(18, n="内伤:" + ui.colored(str(p.wound), color=None if p.wound == 0 else "red")))
    pf.append("  " + ui.fixed(18, n="风毒:%s" % p.poison_hp) + \
                     ui.fixed(18, n="瘀毒:%s" % p.poison_mp))
    pf.append("  " + ui.fixed(18, n="饥饿:%s" % p.hunger) + \
                     ui.fixed(18, n="疲劳:%s" % p.fatigue))
    pf.append("")
    pf.append("")
    pf.append("【人物特质】")
    pf.append("")
    pf.append("  " + ui.fixed(18, n="灵动:" + ui.colored("%s%%" % (50 + p.dongjing), color=digitcolor(p.dongjing))) + \
                     ui.fixed(18, n="沉静:" + ui.colored("%s%%" % (50 - p.dongjing), color=digitcolor(-1 * p.dongjing))))
    pf.append("  " + ui.fixed(18, n="刚猛:" + ui.colored("%s%%" % (50 + p.gangrou), color=digitcolor(p.gangrou))) + \
                     ui.fixed(18, n="柔易:" + ui.colored("%s%%" % (50 - p.gangrou), color=digitcolor(-1 * p.gangrou))))
    pf.append("  " + ui.fixed(18, n="颖悟:" + ui.colored("%s%%" % (50 + p.zhipu), color=digitcolor(p.zhipu))) + \
                     ui.fixed(18, n="朴拙:" + ui.colored("%s%%" % (50 - p.zhipu), color=digitcolor(-1 * p.zhipu))))
    pf.append("")
    pf.append("  " + ui.fixed(18, n="内功阴性:" + ui.colored("%s%%" % (50 - p.yinyang), color="cyan")) + \
                     ui.fixed(18, n="内功阳性:" + ui.colored("%s%%" % (50 + p.yinyang), color="yellow")))
    pf.append("")
    pf.append("【武学能力】")
    pf.append("")
    pf.append("  " + ui.fixed(18, n="内功:%s" % p.neigong))
    pf.append("  " + ui.fixed(18, n="搏击:%s" % p.boji) +
              ui.fixed(15, n="剑法:%s" % p.jianfa))
    pf.append("  " + ui.fixed(18, n="刀法:%s" % p.daofa) +
              ui.fixed(15, n="长兵:%s" % p.changbing))
    pf.append("  " + ui.fixed(18, n="暗器:%s" % p.anqi) +
              ui.fixed(15, n="奇门:%s" % p.qimen))
    pf.append("")
    pf.append("【战斗数据】")
    pf.append("")
    pf.append("  " + ui.fixed(18, n="攻击力:%s" % p.attack) +
              ui.fixed(15, n="防御力:%s" % p.defense))
    pf.append("  " + ui.fixed(18, n="移动力:%s" % p.motion) +
              ui.fixed(15, n="速度:%s" % p.speed))
    pf.append("  " + ui.fixed(18, n="时序值:%s" % p.process))
    pf.append("")
    pf.append("  " + ui.fixed(18, n="命中率:" + ui.colored("%s%%" % int(p.hit_rate * 100), color=attrcolor(p, "hit_rate"))) + \
                     ui.fixed(18, n="闪避率:" + ui.colored("%s%%" % int(p.dodge_rate * 100), color=attrcolor(p, "dodge_rate"))))
    pf.append("  " + ui.fixed(18, n="暴击率:" + ui.colored("%s%%" % int(p.critical_rate * 100), color=attrcolor(p, "critical_rate"))) + \
                     ui.fixed(18, n="暴伤率:" + ui.colored("%s%%" % int(p.critical_damage * 100), color=attrcolor(p, "critical_damage"))))
    pf.append("  " + ui.fixed(18, n="拆招率:" + ui.colored("%s%%" % int(p.anti_damage_rate * 100), color=attrcolor(p, "anti_damage_rate"))) + \
                     ui.fixed(18, n="减伤率:" + ui.colored("%s%%" % int((1 - p.anti_damage) * 100), color=attrcolor(p, "anti_damage"))))
    pf.append("  " + ui.fixed(18,
                              n="反击率:" +
                              ui.colored("%s%%" % int(p.counter_rate * 100),
                                         color=attrcolor(p, "counter_rate"))))
    pf.append("")

    af = []
    af.append("【当前装备】")
    af.append("")
    af.extend(equipment(p))
    af.append("")
    af.append("【当前状态】")
    af.append("")
    sts_count = 0
    for sts in p.status:
        if sts.name is not None:
            #print(sts.name)
            af.append("  " + ui.status(sts))
            sts_count += 1
    if sts_count == 0:
        af.append("  无")
    af.append("")
    af.extend(skills(p))
    af.append("")
    ui.pages([pf, af],
             title=ui.colored("%s %s%s" % (p.title, p.firstname, p.lastname),
                              color="yellow",
                              attrs=["bold"]),
             goback=True)
Пример #24
0
def superskill(superskill, subject=None):
    layers, connections = to_layers(superskill)
    ui.echo()
    ui.echo("当前武学:%s" % ui.rank(superskill))
    ui.echo()
    dires = set()
    for i in range(len(layers)):
        layer = layers[i]
        last = layers[i - 1]
        connection = connections[i - 1]
        #maxgap = max(3, len(last) + len(dires) + 2)
        maxgap = max(3, len(connection) + len(dires) + 2)
        epts = set()
        spts = []
        for j in range(len(last)):
            bst = (GAP + WIDTH + 2) * j + WIDTH // 2 + 1
            spts.append(bst)
        for bst in dires:
            spts.append(bst)
        dires.clear()
        if i != 0:
            for j_raw in range(-1, maxgap):
                tmpstr = []
                tmpepts = set()
                if j_raw >= 0 and j_raw < len(connection):
                    j = sorted(connection.keys())[j_raw]
                    tmppts = set()
                    bst = spts[j]
                    tmppts.add(bst)
                    for cy in connection[j]:
                        ly, nd = cy
                        if ly >= i + 1:
                            nd = len(connection)
                            if nd not in connections[i]:
                                connections[i][nd] = []
                            connections[i][nd].append(cy)
                        #ben = (GAP + WIDTH + 2) * nd + WIDTH // 2 + 1 - len(last) + 2 * j
                        #ben = (GAP + WIDTH + 2) * nd + WIDTH // 2 + 1 - (2 * j // 2 if j % 2 == 0 else -2 * (j // 2 + 1))
                        if nd == j:
                            ben = (GAP + WIDTH + 2) * nd + WIDTH // 2 + 1
                        elif j > nd:
                            ben = (GAP + WIDTH +
                                   2) * nd + WIDTH // 2 + 1 + 2 * (
                                       (j - nd) // 2 + 1)
                        else:
                            ben = (GAP + WIDTH +
                                   2) * nd + WIDTH // 2 + 1 - 2 * (
                                       (nd - j) // 2 + 1)
                        epts.add(ben)
                        tmppts.add(ben)
                        tmpepts.add(ben)
                        if ly >= i + 1:
                            dires.add(ben)
                    horst, horen = min(tmppts), max(tmppts)
                    tmpstr = [" "] * horst + [HOR] * (horen - horst + 1)
                    for tmppt in tmppts:
                        if tmppt == horst and tmppt == horen:
                            tmpstr[tmppt] = VER
                        elif tmppt == bst:
                            if tmppt in tmpepts:
                                if tmppt == horst:
                                    tmpstr[tmppt] = BTR
                                elif tmppt == horen:
                                    tmpstr[tmppt] = BTL
                                else:
                                    tmpstr[tmppt] = BTC
                            else:
                                if tmppt == horst:
                                    tmpstr[tmppt] = LB
                                elif tmppt == horen:
                                    tmpstr[tmppt] = RB
                                else:
                                    tmpstr[tmppt] = BTT
                        else:
                            if tmppt == horst:
                                tmpstr[tmppt] = LT
                            elif tmppt == horen:
                                tmpstr[tmppt] = RT
                            else:
                                tmpstr[tmppt] = BTB
                # 分支后竖线
                for ept in sorted(epts):
                    if ept >= len(tmpstr):
                        tmpstr += [" "] * (ept - ui.strwidth("".join(tmpstr))) + \
                                  [VER if j_raw != maxgap - 1 or ept in dires else DLT]
                    elif tmpstr[ept] == " ":
                        tmpstr[
                            ept] = VER if j_raw != maxgap - 1 or ept in dires else DLT
                # 分支前竖线
                for k in sorted(connection.keys()):
                    if j_raw > k:
                        continue
                    vpt = spts[k]
                    if vpt >= len(tmpstr):
                        tmpstr += [" "] * (vpt - len(tmpstr)) + [VER]
                    elif tmpstr[vpt] == " ":
                        tmpstr[vpt] = VER
                ui.echo("".join(tmpstr))
        tmpstr = [LT] + [HOR] * WIDTH + [
            RT
        ] + ([" "] * GAP + [LT] + [HOR] * WIDTH + [RT]) * (len(layer) - 1)
        for ept in dires:
            if ept >= len(tmpstr):
                tmpstr += [" "] * (ept - len(tmpstr)) + [VER]
            elif tmpstr[ept] == " ":
                tmpstr[ept] = [VER]
        ui.echo("".join(tmpstr))
        for j in range(HEIGHT):
            strlist = []
            for lyt in layer:
                if j == 0:
                    ctstr = "【%s】" % (lyt + 1) + superskill.nodes[lyt].name
                #elif j == 1:
                #    ctstr = ui.nodecond(superskill.nodes[lyt])
                elif j == HEIGHT - 1 and subject is not None:
                    learn_st = superskill.learn_status(subject, lyt)
                    if learn_st == 0:
                        ctstr = ui.colored("(已习得)", color="yellow")
                    elif learn_st == -1:
                        ctstr = ui.colored("(条件不足)", color="red")
                    elif subject.studying != superskill.nodes[lyt]:
                        ctstr = ui.colored("(可学习)", color="green")
                    else:
                        ctstr = "经验:%s/%s" % (subject.exp,
                                              superskill.nodes[lyt].exp)
                else:
                    ctstr = ""
                strlist.append(VER + grid(ctstr) + VER)
            strlist = (" " * GAP).join(strlist)
            tmpstr = []
            strlen = ui.strwidth(strlist)
            for ept in dires:
                if ept >= strlen:
                    tmpstr += [" "] * (ept - strlen) + [VER]
                elif tmpstr[ept] == " ":
                    tmpstr[ept - strlen] = [VER]
            ui.echo(strlist + "".join(tmpstr))
        strlist = (" " * GAP).join([LB + HOR * WIDTH + RB] * len(layer))
        tmpstr = []
        strlen = ui.strwidth(strlist)
        for ept in dires:
            if ept >= strlen:
                tmpstr += [" "] * (ept - strlen) + [VER]
            elif tmpstr[ept] == " ":
                tmpstr[ept - strlen] = [VER]
        ui.echo(strlist + "".join(tmpstr))
Пример #25
0
def main_title():
    if len(runtime.MODULE.info.MOD_SHOW_NAME) > 0:
        title_str = "《摸鱼群侠传:%s》" % runtime.MODULE.info.MOD_SHOW_NAME
    else:
        title_str = "《摸鱼群侠传》"
    return ui.colored(title_str, color="red", attrs=["bold"])
Пример #26
0
    ui.echo()
    ui.echo("【主运心法】")
    ui.echo()
    ui.echo("【习得武学】")
    ui.echo()
    for sk in p.skills:
        ui.echo("  %s:%s" % (sk.belongs.name, sk.name))


if __name__ == "__main__":
    pa = Person.one("PERSON_ZHAO_SHENJI")
    pb = Person.one("PERSON_TIAN_WEI")
    #profile(pb)

    ui.echo()
    ui.echo(" " + ui.colored(" Ω ", attrs=["underline"]) + " " + "   " +
            ui.colored("  ^  ", attrs=["underline"]))
    ui.echo(" " + "├_┤" + " " + "   " + "║" + "║║║" + "║")
    ui.echo("q" + ui.colored("¯V¯", attrs=["underline"]) + "p" + "   " + "q" +
            ui.colored("¯Y¯", attrs=["underline"]) + "p")
    ui.echo(" U U " + "   " + " U U ")

    ui.echo()
    ui.echo(" " + ui.colored("-Π-", attrs=["underline"]) + " " + "   " + " " +
            ui.colored("\\V/", attrs=["underline"]) + " ")
    ui.echo(" " + "├_┤" + " " + "   " + "/" + "├_┤" + "\\")
    ui.echo("q" + ui.colored("¯Ÿ¯", attrs=["underline"]) + "p" + "   " + "q" +
            ui.colored("¯¯¯", attrs=["underline"]) + "p")
    ui.echo(
        ui.colored("/", attrs=["underline"]) + "_" +
        ui.colored(" ", attrs=["underline"]) + "_" +
Пример #27
0
def handler_world_attack_ensure(ctx):
    ret = ui.sure(
        ui.colored("动手之前要想清楚,是否进行攻击?(若中途参与NPC间的战斗,己方人物的初始位置将是随机的)",
                   color="yellow",
                   attrs=["bold"]))
    return ret
Пример #28
0
def battle_person_handler(snapshot, show_events=False):

    retlist = []

    for p in snapshot.values():
        if not p["visible"]:
            continue
        ret = {"location": None, "contents": [None, None, None], "trace": None}
        ret["location"] = p["location"]

        # 处理标题文本
        #if "current" in p and platform.system() == "Linux":
        if "current" in p:
            ret["contents"][0] = ui.colored(p["name"],
                                            color="grey",
                                            on_color="on_%s" %
                                            ui.GROUP_COLOR[p["group"]])
        #elif "current" in p:
        #    ret["contents"][0] = ui.colored(p["name"],
        #                                    on_color="on_%s" % ui.GROUP_COLOR[p["group"]],
        #                                    attrs=["bold"])
        else:
            ret["contents"][0] = ui.colored(p["name"],
                                            color=ui.GROUP_COLOR[p["group"]],
                                            attrs=["bold"])
        ret["contents"][0] += fmt.vaka["direction"][str(p["direction"])]

        # 处理HP文本
        if BattleEvent.HPChanged in p["events"]:
            hp_delta = p["events"][BattleEvent.HPChanged]["value"]
        else:
            hp_delta = 0
        if not show_events and hp_delta != 0:
            qcolor = "green" if p["poison_hp"] > 0 else None
            ret["contents"][1] = "%s:%s" % (fmt.aka["hp"],
                                            ui.colored(str(p["hp"] - hp_delta),
                                                       color=qcolor))
            #ret["contents"][1] = str(p["hp"] - hp_delta)
        else:
            qcolor = "green" if p["poison_hp"] > 0 else None
            ret["contents"][1] = "%s:%s" % (
                fmt.aka["hp"], ui.colored(str(p["hp"]), color=qcolor))
            #ret["contents"][1] = str(p["hp"])
        if show_events and hp_delta != 0:
            qcolor = "red" if hp_delta < 0 else "green"
            showstr = hp_delta if hp_delta < 0 else "+%s" % hp_delta
            ret["contents"][1] += ui.colored("(%s)" % showstr,
                                             color=qcolor,
                                             attrs=["bold"])
        elif show_events and BattleEvent.ACTMissed in p["events"]:
            ret["contents"][1] += ui.colored("(miss)",
                                             color="yellow",
                                             attrs=["bold"])
        else:
            qcolor = "red" if p["injury"] > 0 else None
            ret["contents"][1] += "/" + ui.colored(str(p["hp_limit"]),
                                                   color=qcolor)

        # 处理MP文本
        if BattleEvent.MPChanged in p["events"]:
            mp_delta = p["events"][BattleEvent.MPChanged]["value"]
        else:
            mp_delta = 0
        if not show_events and mp_delta != 0:
            ncolor = "green" if p["poison_mp"] > 0 else None
            ret["contents"][2] = "%s:%s" % (fmt.aka["mp"],
                                            ui.colored(str(p["mp"] - mp_delta),
                                                       color=ncolor))
            #ret["contents"][2] = str(p["mp"] + mp_delta)
        else:
            ncolor = "green" if p["poison_mp"] > 0 else None
            ret["contents"][2] = "%s:%s" % (
                fmt.aka["mp"], ui.colored(str(p["mp"]), color=ncolor))
            #ret["contents"][2] = str(p["mp"])
        if show_events and mp_delta != 0:
            showstr = mp_delta if mp_delta < 0 else "+%s" % mp_delta
            ret["contents"][2] += ui.colored("(%s)" % showstr,
                                             color="blue",
                                             attrs=["bold"])
        else:
            ncolor = "red" if p["wound"] > 0 else None
            ret["contents"][2] += "/" + ui.colored(str(p["mp_limit"]),
                                                   color=ncolor)

        # 处理路径
        if BattleEvent.PositionMoved in p["events"]:
            ret["trace"] = p["events"][BattleEvent.PositionMoved]["trace"]
        retlist.append(ret)
    return retlist