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_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
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 new_file(func): if not ui.blankline(): ui.echo() ret = ui.read("请输入新建的存档名称:") loaddir = options.SAVEFILE_PATH apath = loaddir + "/" + ret + ".savefile" func(apath)
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 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)
def handler_world_scenario_change_ensure(ctx): target = ctx.team.scenario.transport_locs[ctx.team.location] target = Map.one(target).name map = ctx.team.scenario ui.map(map, entities=team_info(map), show_trace=True) ui.echo() ret = ui.sure("当前地块可通往%s,是否前往?" % target) return ret
def handler_skill_node_select_control(ctrl): ui.echo() ui.superskill(ctrl.superskill, ctrl.person) ui.echo() ret = ui.menu(superskill_menu(ctrl), title="请选择你要学习的节点:", goback=True, backmethod=ctrl.close)
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_study_skill(ctx): ui.echo() ui.superskill(ctx.superskill, ctx.subject) ui.echo() ret = ui.menu(superskill_menu(ctx.superskill, ctx.subject), title="请选择你要学习的节点:", goback=True, backmethod=ctx.backmethod) return ret
def handler_battle_player(ac): map = ac.battle.map if ac.back: ui.echo() ui.map(map, entities=battle_person_handler(ac.snapshot)) ui.cleanmenu() ui.menu(battle_menu(), title="请选择%s的行动方针:" % ac.battle.current.name, columns=2, width=15)
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_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)
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)
def handler_person_dialog_branch(ctx): menulist = [] ui.echo("%s:" % ctx.subject.name) for b in ctx.branches: bold = ctx.name not in context.script_status or \ b not in context.script_status[ctx.name] menulist.append( ui.menuitem(ctx.conversation[b]["content"], value=b, bold=bold)) ret = ui.menu(menulist) ui.echo() return ret
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
def list_modules(arg, map_func, newbuild=False): ret = [] if newbuild: ret.append(ui.menuitem("新建地图组", goto=lambda x: new_module(x, map_func))) for file in os.listdir("%s/../../data/maps" % os.path.dirname(__file__)): if not file.endswith(".py") or file.startswith("__init__.py"): continue ret.append( ui.menuitem(file[:-3], goto=lambda x: list_maps(x, map_func, newbuild))) ui.echo() ui.menu(ret, title="请选择目标地图组:", goback=True)
def handler_battle_scope_control(ctrl): map = ctrl.battle.map ui.echo() ui.map(map, entities=battle_person_handler(ctrl.snapshot), coordinates=[{ "positions": ctrl.scope, "color": "yellow" }], show_trace=False) ui.echo() rt = ui.sure("黄色为作用范围,是否确认") ctrl.input(rt)
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 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 list_maps(arg, map_func, newbuild=False): ret = [] if newbuild: ret.append(ui.menuitem("新建地图", goto=lambda x: new_map(x, map_func))) nomod = False try: globals.MAP_MODULE = importlib.import_module("proj.data.maps.%s" % arg) except Exception as e: nomod = True if not nomod: for m in dir(globals.MAP_MODULE): if not m.startswith("MAP_"): continue ret.append(ui.menuitem(m, value=m, goto=lambda x: map_func(x))) ui.echo() ui.menu(ret, title="请选择目标地图:", goback=True)
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("(回车继续)")
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
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_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_session_branch(ctx): menulist = [] ui.echo("%s:" % ctx.subject.name) for b in ctx.branches: label_idx = ctx.labels[b["label"]] if "content" in b: content = b["content"] elif "content" in ctx.script[label_idx]: content = ctx.script[label_idx]["content"] elif "scripts" in ctx.script[label_idx] and "content" in ctx.script[ label_idx]["script"][0]: content = ctx.script[label_idx]["script"][0]["content"] bold = ctx.name not in context.script_status or \ b["label"] not in context.script_status[ctx.name] menulist.append(ui.menuitem(content, value=label_idx, bold=bold)) ret = ui.menu(menulist) ui.echo() return ret
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_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_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("(回车继续)")