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("(回车继续)")
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()
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)
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()
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
def new_file(func): if not ui.blankline(): ui.echo() ret = ui.read("请输入新建的存档名称:") loaddir = options.SAVEFILE_PATH apath = loaddir + "/" + ret + ".savefile" func(apath)
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("(回车继续)")
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()
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()
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("(回车继续)")
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)
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()
def handler_world_player(ctx): map = ctx.map ui.cleanmenu() recenter(ctx.subject) if not ui.blankline(): ui.echo() ui.echo("当前回合:%s" % context.timestamp) ui.echo() ui.map(map, entities=team_info(ctx.map), show_trace=True) ui.menu(world_menu(ctx.subject), title="请选择你的行动方针:", columns=5, width=15)
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("(回车继续)")
def handler_battle_control(ctrl): map = ctrl.battle.map if not ui.blankline(): ui.echo() ui.map(map, entities=battle_person_handler(ctrl.snapshot)) ui.cleanmenu() ui.menu(battle_menu(ctrl), title="请选择%s的行动方针:" % ctrl.battle.current.name, macros=ctrl.macs, columns=2, width=15)
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("(回车继续)")
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()
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()
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)
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()
def handler_map_editor_control(ctrl): if not ui.blankline(): ui.echo() if ctrl.show_coordinates: ui.map(map=ctrl.map, coordinates=[{ "positions": ctrl.map.all(), "real": ctrl.real_coordinates }], entities=entity_info(ctrl.map)) else: ui.map(map=ctrl.map, entities=entity_info(ctrl.map)) if ctrl.real_coordinates: ctrl.real_coordinates = False ctrl.show_coordinates = False ui.echo() ret = ui.menu(editor_menu(ctrl), title="请选择你要进行的操作:", columns=2, width=15) return ret
def handler_scenario_control(ctrl): scenario = ctrl.scenario ui.cleanmenu() recenter(ctrl.team) if not ui.blankline(): ui.echo() ui.echo("当前回合:%s" % context.timestamp) ui.echo() ui.map(scenario, entities=team_info(ctrl), coordinates=[{ "positions": context.guide, "color": "yellow" }], show_trace=True) ui.menu(world_menu(ctrl), title="请选择你的行动方针:", macros=ctrl.macs, columns=4, width=15)
def hander_action_finish(ctx): if not ui.blankline(): ui.echo() ui.read("(回车继续)")
def handler_person_item_lost(ctx): if not ui.blankline(): ui.echo() ui.echo("%s失去了%s×%s" % (ctx.subject.name, ui.rank(ctx.item), ctx.quantity)) ui.read()
def handler_game_fail(ctx): if not ui.blankline(): ui.echo() ui.warn("休命。") ui.read() sys.exit(0)
def handler_battle_map(ac): map = ac.battle.map if not ui.blankline(): ui.echo() ui.map(map, entities=battle_person_handler(ac.snapshot))
def handler_person_item_equip(ctx): if not ui.blankline(): ui.echo() ui.echo("%s装备了【%s】" % (ctx.subject.name, ui.rank(ctx.item))) ui.read()
def handler_battle_finish_silent(ac): if not ui.blankline(): ui.echo() ui.warn("传闻:在一场对决中,%s被%s击败了。" % (ac.teamloser.leader.name, ac.teamwinner.leader.name)) ui.read()
def handler_battle_map_control(ctrl): map = ctrl.battle.map if not ui.blankline(): ui.echo() ui.map(map, entities=battle_person_handler(ctrl.snapshot))
def handler_halt(ctx): if not ui.blankline(): ui.echo() ui.read()