Ejemplo n.º 1
0
def handler_battle_finish_turn(ac):
    map = ac.battle.map
    if not ui.blankline():
        ui.echo()
    ui.map(map, entities=battle_person_handler(ac.snapshot, show_events=True))
    ui.echo()
    ui.read("(回车继续)")
Ejemplo n.º 2
0
def handler_thumbnail_control(ctrl):
    if not ui.blankline():
        ui.echo()
    ui.thumbnail(map=ctrl.scenario, entities=team_info(ctrl))
    ui.echo()
    ui.read("(回车继续)")
    ctrl.close()
Ejemplo n.º 3
0
def handler_person_speak(ctx):
    if not ui.blankline():
        ui.echo()
    if ctx.content is None:
        ui.read("(回车继续)")
        ui.echo()
        return
    if isinstance(ctx.content, list):
        contents = ctx.content
    else:
        contents = [ctx.content]
    for idx, content in enumerate(contents):
        content = content.format(**context.strdict)
        if ctx.talker is None:
            ui.words(content)
        else:
            #print(ctx.talker, content)
            #prefix_str = (ctx.talker.name + ":") if idx == 0 else " "
            prefix_str = ctx.talker.name + ":"
            #prefix = ui.fixed(ui.strwidth(prefix_str), n=(prefix_str if idx == 0 else " "))
            prefix = ui.fixed(10, n=(prefix_str if idx == 0 else " "))
            ui.words("%s%s" % (prefix, content))
        ui.read()
        if idx == len(contents) - 1:
            ui.echo()
Ejemplo n.º 4
0
def handler_person_item_transfer(ctx):
    if not ui.blankline():
        ui.echo()
    ui.echo(
        "%s把%s×%s交给了%s" %
        (ctx.subject.name, ui.rank(ctx.item), ctx.quantity, ctx.object.name))
    ui.read()
Ejemplo n.º 5
0
def handler_show(ctx):
    if not ui.blankline():
        ui.echo()
    if ctx.text is not None:
        ui.echo(ctx.text)
        ui.echo()
    if ctx.wait:
        ui.read("(回车继续)")
Ejemplo n.º 6
0
def handler_map_thumbnail_control(ctrl):
    if not ui.blankline():
        ui.echo()
    ui.echo()
    ui.thumbnail(map=ctrl.map, entities=entity_info(ctrl.map))
    ui.echo()
    ui.read("(回车继续)")
    ctrl.close()
Ejemplo n.º 7
0
def blank_map(arg):
    name = ui.read("请输入你想要建立的地图的名字:")
    ui.echo()
    rt = ui.read("请输入你想要建立的地图大小(第一个数字为宽,第二个为高,中间使用空格分隔):")
    x, y = rt.split()
    x = int(x)
    y = int(y)
    globals.MAP = Map(name=name, width=x, height=y, window_y=7)
Ejemplo n.º 8
0
def handler_battle_item(ac):
    map = ac.battle.map
    if len(ac.objects) == 0:
        ui.echo()
        ui.echo("使用范围内无目标!")
    ui.echo()
    ui.map(map, entities=battle_person_handler(ac.snapshot, show_events=True))
    ui.echo()
    ui.read("(回车继续)")
Ejemplo n.º 9
0
def handler_world_clash(ctx):
    map = ctx.map
    ui.echo()
    ui.map(map, entities=team_info(ctx.map), show_trace=True)
    ui.echo()
    ui.warn("移动过程中发生路径冲突,移动已中断!")
    ui.echo()
    ui.read("(回车继续)")
    ui.menu(world_menu(ctx.subject), title="请选择你的行动方针:", columns=5, width=15)
Ejemplo n.º 10
0
def handler_person_item_acquire(ctx):
    if not ui.blankline():
        ui.echo()
    if ctx.item is not None:
        ui.echo("%s获得了%s×%s" %
                (ctx.subject.name, ui.rank(ctx.item), ctx.quantity))
    else:
        ui.echo("%s一无所获" % ctx.subject.name)
    ui.read()
Ejemplo n.º 11
0
def handler_battle_new_turn(ac):
    map = ac.battle.map
    map.window_center(ac.snapshot[ac.battle.current.id]["location"])
    if not ui.blankline():
        ui.echo()
    ui.map(map, entities=battle_person_handler(ac.snapshot, show_events=True))
    ui.echo()
    ui.echo("轮到%s行动。" % ac.battle.current.name)
    ui.echo()
    ui.read("(回车继续)")
Ejemplo n.º 12
0
def handler_control_test(ctx):
    if not ui.blankline():
        ui.echo()
    if ctx.text is not None:
        ui.echo(ctx.text)
        ui.echo()
    if ctx.wait:
        ui.read("(回车继续)")
    #th = threading.Thread(target=ctx.control.hook, daemon=True)
    #th.start()
    ctx.hook()
Ejemplo n.º 13
0
def handler_battle_move(ac):
    map = ac.battle.map
    map.window_center(ac.snapshot[ac.battle.current.id]["location"])
    if not ac.motivated or (not ac.battle.controllable() and len(ac.path) > 1):
        ui.echo()
        ui.map(map,
               entities=battle_person_handler(ac.snapshot, show_events=True))
        ui.echo()
        ui.echo("%s移动至%s。" % (ac.subject.name, ac.target))
        ui.echo()
        ui.read("(回车继续)")
Ejemplo n.º 14
0
def handler_battle_start(ac):
    map = ac.battle.map
    if not ui.blankline():
        ui.echo()
    ui.warn("战斗开始!")
    ui.echo()
    ui.read("(回车继续)")
    ui.echo()
    ui.map(map, entities=battle_person_handler(ac.snapshot))
    ui.echo()
    ui.read("(回车继续)")
Ejemplo n.º 15
0
def handler_show_macros(ctrl):
    ui.echo()
    ui.echo("当前可用宏指令:")
    ui.echo()
    ui.echo(ui.fixed(20, n="#macros") + ctrl.macs_desc["#macros"])
    for mac in sorted(list(ctrl.macs_desc.keys())):
        if mac == "#macros":
            continue
        ui.echo(ui.fixed(20, n=mac) + ctrl.macs_desc[mac])
    ui.echo()
    ui.read("(回车继续)")
    ctrl.launch()
Ejemplo n.º 16
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("(回车继续)")
Ejemplo n.º 17
0
def handler_map_person_control(ctrl):
    ui.echo()
    person = ui.read("请输入需要添加人物的模板号:")
    ui.echo()
    if not person.startswith("PERSON"):
        return None
    ui.map(map=ctrl.map,
           coordinates=[{
               "positions": ctrl.map.all()
           }],
           entities=entity_info(ctrl.map))
    ui.echo()
    loc = ui.read("请输入需要添加地形的坐标(x与y用空格分隔,多个坐标用半角逗号分隔):",
                  handler=lambda x: validate_positions(x, ctrl.map))
    ctrl.input((person, loc))
Ejemplo n.º 18
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()
Ejemplo n.º 19
0
def handler_map_element_control(ctrl):
    if not ui.blankline():
        ui.echo()
    ret = ui.read("输入你想要设置的实体名称:")
    ctrl.elename(ret)
    ui.menu(element_menu(ctrl), goback=True, backmethod=ctrl.close)
    ui.echo()
    ui.map(map=ctrl.map,
           coordinates=[{
               "positions": ctrl.map.all()
           }],
           entities=entity_info(ctrl.map))
    ui.echo()
    ret = ui.read("请输入需要添加元素的坐标(x与y用空格分隔,多个坐标用半角逗号分隔):",
                  handler=lambda x: validate_positions(x, ctrl.map))
    ctrl.input(ret)
Ejemplo n.º 20
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("(回车继续)")
Ejemplo n.º 21
0
def new_file(func):
    if not ui.blankline():
        ui.echo()
    ret = ui.read("请输入新建的存档名称:")
    loaddir = options.SAVEFILE_PATH
    apath = loaddir + "/" + ret + ".savefile"
    func(apath)
Ejemplo n.º 22
0
def handler_person_item_quantity(ctx):
    ui.echo()
    qrange = ctx.qrange(ctx.subject, ctx.object, ctx.item)
    rt = ui.read("请输入你要%s的数目(%s~%s):" % (ctx.action, qrange[0], qrange[1]),
                 handler=lambda x: int(x) if x.isdigit() and ctx.filter(
                     ctx.subject, ctx.object, ctx.item, int(x)) else None)
    return rt
Ejemplo n.º 23
0
def handler_battle_finish(ac):
    ui.echo()
    result = "胜利" if ac.result else "失败"
    ui.warn("战斗%s!" % result)
    ui.echo()
    for p, exp in ac.explist:
        ui.echo("%s获得了%s点经验。" % (p.name, exp))
        ui.echo()
    for p, node in ac.nodelist:
        ui.echo("%s已经习得了技能%s:%s。" %
                (p.name, ui.rank(node.belongs), ui.rank(node)))
        ui.echo()
    for p, item, quantity in ac.itemlist:
        ui.echo("%s获得了%s×%s。" % (p.name, ui.rank(item), quantity))
        ui.echo()
    ui.read("(回车继续)")
Ejemplo n.º 24
0
def handler_map_resize_control(ctrl):
    if not ui.blankline():
        ui.echo()
    ui.menu(resize_menu(ctrl), goback=True, backmethod=ctrl.close)
    ui.echo()
    ret = ui.read("请输入需要扩展或剪裁的值):")
    ctrl.input(ret)
Ejemplo n.º 25
0
def handler_world_give_object(ctx):
    map = ctx.map
    if ctx.pos not in map.loc_entity:
        ui.warn("该坐标下无可赠予对象!")
        ui.echo()
        ui.read("(回车继续)")
        return None
    ui.echo()
    pmenu = person_menu(ctx.pos, map)
    if len(pmenu) > 1:
        rt = ui.menu(pmenu,
                     title="请选择你要赠予的角色:",
                     goback=True,
                     backmethod=lambda: None)
    else:
        rt = pmenu[0].value
    return rt
Ejemplo n.º 26
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()
Ejemplo n.º 27
0
def handler_item_quantity_select_control(ctrl):
    if ctrl.range[0] == 1 and ctrl.range[1] == 1:
        ctrl.select(1)
        return
    if not ui.blankline():
        ui.echo()
    rt = ui.read("%s(%s~%s):" % (ctrl.text, ctrl.range[0], ctrl.range[1]),
                 handler=lambda x: int(x) if ctrl.validator(x) else None)
    ctrl.select(rt)
Ejemplo n.º 28
0
def handler_map_erase_control(ctrl):
    ui.echo()
    ui.map(map=ctrl.map,
           coordinates=[{
               "positions": ctrl.map.all()
           }],
           entities=entity_info(ctrl.map))
    ui.echo()
    ret = ui.read("请输入需要添加地形的坐标(x与y用空格分隔,多个坐标用半角逗号分隔):",
                  handler=lambda x: validate_positions(x, ctrl.map))
    ctrl.input(ret)
Ejemplo n.º 29
0
def handler_map_camera_control(ctrl):
    ui.echo()
    ui.map(map=ctrl.map,
           coordinates=[{
               "positions": ctrl.map.all()
           }],
           entities=entity_info(ctrl.map))
    ui.echo()
    ret = ui.read("请输入镜头需要移动至的坐标(x与y用空格分隔):",
                  handler=lambda x: validate_position(x, ctrl.map))
    ctrl.input(ret)
Ejemplo n.º 30
0
def handler_world_build_position(ctx):
    map = ctx.map
    ui.echo()
    ui.map(map,
           entities=team_info(ctx.map),
           coordinates=ctx.positions,
           coordinate_color="green",
           show_trace=False)
    ui.echo()
    rt = ui.read("请输入你想要建设的格子(绿色表示可建设范围,坐标用空格分隔,输入#back可返回):",
                 handler=lambda x: validate_position(x, ctx.positions, True))
    return rt