Esempio n. 1
0
 def 近战鉴定(self, difficult):
     here = self.data['经验']['近战经验'] * 5 + self.data['能力']['近战'] * 10
     game.pl('近战经验*5+近战*10=' + str(here) + '  难度:' + str(difficult))
     if difficult < here:
         return True
     else:
         return False
Esempio n. 2
0
def next_step():
    # 方便调用
    global direction
    map_size = game.data['map']['map_size']
    snake_list = game.data['snake_list']
    mapdata = game.data['mapdata']

    # 判断是否有苹果,没有就创造一个
    if 1 not in mapdata.values():
        create_apple()

    # 记录蛇身体的最后一节的位置
    last_snake_position = snake_list[-1]

    # 更新蛇身
    for i in range(len(snake_list) - 1, 0, -1):
        snake_list[i] = snake_list[i - 1]

    # 更新蛇头位置
    x_head = snake_list[0][0]
    y_head = snake_list[0][1]
    if direction == 'zuo':
        x_head = x_head - 1
    if direction == 'you':
        x_head = x_head + 1
    if direction == 'shang':
        y_head = y_head - 1
    if direction == 'xia':
        y_head = y_head + 1
    snake_list[0] = (x_head, y_head)

    apple_position = (-1, -1)
    # 获得苹果位置
    for k, v in mapdata.items():
        if v == 1:
            apple_position = k
            break
    # 判断是否吃到苹果,如果吃到苹果则加一节身体
    if snake_list[0] == apple_position:
        # 苹果消失,所有地格变为0
        for k in mapdata:
            mapdata[k] = 0
        # 延长蛇身,把动前最后的一个位置添加到蛇身体中
        snake_list.append(last_snake_position)

    # 身体碰撞检测
    if snake_list[0] in snake_list[1::]:
        game.pl('蛇碰到了它的身体,你失败了', style='special')
        open_func()
        return

    # 超出边界检测
    if snake_list[0][0] < 0 or snake_list[0][0] >= map_size or snake_list[0][
            1] < 0 or snake_list[0][1] >= map_size:
        game.pl('蛇碰到了墙壁,你失败了', style='special')
        open_func()
        return

    # 返回主函数
    main_func()
Esempio n. 3
0
def main_play():
    global tgroup, tworld, tscene
    game.clr_cmd()
    game.pline()
    string = game.align('剧情进度:', 14) + lib.value_bar(tworld.当前进度,
                                                     tworld.data['剧情容量'])
    string += game.align('下一剧情:' + tscene.名称, 30, 'right')
    game.pl(string)
    for p in tgroup.所有人物:
        prefix = p.姓名 + '|体力:'
        prefix = game.align(prefix, 14)
        game.pl(prefix + lib.value_bar(p.当前体力, p.体力上限))

    string = '----------------------------------' + '设置剧情 ' + ': ' + tscene.名称 + ' --------------------------------'
    game.pl(string, style='title')
    game.call_event('设置剧情_' + tscene.名称, arg=(tscene.data, ))
    string = '---------------------------------------------------------------------------------------'
    game.pl(string, style='title')

    def begin_scene():
        global tscene
        game.call_event('进行剧情_' + tworld.当前剧情['名称'],
                        arg=(tgroup, tworld, tscene))
        tworld.下一剧情()
        if tworld.当前进度 <= tworld.data['剧情容量']:
            tscene = Target_scene(tworld.当前剧情)
        main_play()

    if tworld.当前进度 <= tworld.data['剧情容量']:
        game.pcmd('[100] 开始剧情', 100, begin_scene)
    else:
        game.p('[100] 开始剧情', style='grey')
    game.pl()
    game.pcmd('[999] 结束试炼', 999, main_func)
Esempio n. 4
0
def group_manager():
    game.clr_cmd()
    game.pline()
    display_group_list()
    game.pcmd('[001]  新建队伍', 1, create_group)
    game.pl()
    game.pcmd('[099]  退出管理', 99, main_func)
    game.askfor_order()
Esempio n. 5
0
def world_manager():
    game.clr_cmd()
    game.pline()
    display_world_list()
    game.pcmd('[001]  创造世界', 1, create_world)
    game.pl()
    game.pcmd('[099]  退出管理', 99, main_func)
    game.askfor_order()
Esempio n. 6
0
def people_manager():
    game.clr_cmd()
    game.pline()
    dispaly_people_list(askfor_order_atend=False)
    game.pcmd('[001]  召唤人物', 1, summon_people)
    game.pl()
    game.pcmd('[099]  退出管理', 99, script.mainflow.main_func)
    game.askfor_order()
Esempio n. 7
0
def init_play():
    global tgroup, tworld, tscene
    if game.data['试炼设置']['试炼队伍'] == None or game.data['试炼设置']['试炼世界'] == None:
        game.pl('没有指定[试炼队伍]或[试炼世界],请于[试炼设置]中选择', 'notice')
        main_func()
    tgroup = Target_group(game.data['试炼设置']['试炼队伍'])
    tworld = Target_world(game.data['试炼设置']['试炼世界'])
    tscene = Target_scene(tworld.当前剧情)
    main_play()
Esempio n. 8
0
def 进行剧情_赤手蠢贼(tgroup, tworld, tscene):
    game.pl('草丛里蹦出三个蠢贼,赤手空拳的向' + tgroup.data['队伍名称'])
    # game.pl(tgroup.姓名 + '还击')
    # re = tgroup.近战鉴定(tscene.难度 * 10)
    # if re == True:
    #     game.pl('三个贼徒被打跑了')
    #     tgroup.当前体力 -= 10
    # if re == False:
    #     game.pl(tgroup.姓名 + '被打的鼻青脸肿')
    #     tgroup.当前体力 -= 50
Esempio n. 9
0
def _create_world(type_id):
    tpl = copy.deepcopy(game.data['世界'][type_id])
    tpl = game.call_event('生成世界_' + tpl['世界名称'], arg=(tpl,))
    # 是否创建世界
    game.pl("创建世界:" + tpl['世界名称'] + "?","notice")
    ans = lib.yes_or_no()
    game.pl()
    if ans == True:
        tpl['ID'] = lib.get_id()
        game.data['世界列表'].append(tpl)
    world_manager()
Esempio n. 10
0
def change_target_group():
    def change_group(group):
        game.data['试炼设置']['试炼队伍'] = group
        game.pl('试炼队伍已改为:' + group['队伍名称'])
        play_config()

    game.clr_cmd()
    game.pl('请选择试炼队伍:')
    script.group.display_group_list(change_group)
    game.pcmd('[001] 取消', 1, play_config)
    game.askfor_order()
Esempio n. 11
0
def change_target_world():
    def change_world(world):
        game.data['试炼设置']['试炼世界'] = world
        game.pl('试炼世界已改为:' + world['世界名称'])
        play_config()

    game.clr_cmd()
    game.pl('请选择试炼世界:')
    script.world.display_world_list(change_world)
    game.pcmd('[001] 取消', 1, play_config)
    game.askfor_order()
Esempio n. 12
0
def summon_people(people_type='普通人'):
    if not '人物列表' in game.data:
        game.data['人物列表'] = []

    temp_student = _summon_people(people_type)
    display_people(temp_student)
    game.pl('是否接受这个人物?', style='notice')
    ans = lib.yes_or_no()
    game.pl()
    if ans == True:
        game.data['人物列表'].append(temp_student)
    people_manager()
Esempio n. 13
0
def play_config():
    game.clr_cmd()
    game.pline()
    display_traget()
    game.pline('--')

    game.pcmd('[001]  改变试炼队伍', 1, change_target_group)
    game.p('    ')
    game.pcmd('[002]  改变试炼世界', 2, change_target_world)
    game.pl()
    game.pcmd('[099]  退出管理', 99, main_func)
    game.askfor_order()
Esempio n. 14
0
def display_people(people):
    def print_title(title):
        string = '□' + title + '□' + '-------------------------------------------------------------------------------'
        game.pl(string, style='title')

    def print_numattr(node, attrs, display_room, pre_fix=' '):
        string = ''
        for attr in attrs:
            temp = attr + ':' + pre_fix + str(node[attr]) + '  '
            string += game.align(temp, display_room)
        game.pl(string)

    def print_talent(node, attrs, pre_fix=' '):
        for attr in attrs:
            temp_value = ['[' + iter_var + ']' for iter_var in node[attr]]
            temp = attr + ':' + pre_fix + ''.join(temp_value)
            game.pl(temp)

    game.pline()
    game.pl('姓名:' + people['姓名'])

    print_title('属性')
    attrs = ["体力上限", "物资补给", "神秘能源", "认同程度", "因果点数", "因果碎片"]
    print_numattr(people['属性'], attrs, 15)

    print_title('经验')
    attrs = ["近战经验", "远战经验", "科技经验", "神秘经验"]
    print_numattr(people['经验'], attrs, 15)

    print_title('能力')
    attrs = ['见闻', '社交', '科技', '神秘']
    print_numattr(people['能力'], attrs, 15)
    attrs = ['近战', '远战', '基因锁']
    print_numattr(people['能力'], attrs, 15)

    print_title('刻印')
    attrs = people['刻印'].keys()
    print_numattr(people['刻印'], attrs, 15, ' LV')

    print_title('素质')
    attrs = ['性征', '性格', '倾向', '技能', '体质', '天赋']
    print_talent(people['素质'], attrs)

    print_title('背景')
    attrs = ['职业']
    print_talent(people['背景'], attrs)

    print_title('装备')
    attrs = ['装备一', '装备二']
    print_numattr(people['装备'], attrs, 30)
    attrs = ['装备三', '装备四']
    print_numattr(people['装备'], attrs, 30)
Esempio n. 15
0
def create_world():
    game.clr_cmd()
    string = '----------------------------------' + '可选世界' + '---------------------------------------------'
    game.pl(string, style='title')
    string = game.align('创造编号', 15) + game.align('世界类型', 15) + game.align('剧情容量', 15) + game.align('构建点数', 15)
    game.pl(string)

    numid = 0
    for w in game.data['世界']:
        id = '[{:0>3}]'.format(numid)
        string = game.align(id, 15) + game.align(w['世界名称'], 15) + game.align(w['剧情容量'], 15) + game.align(w['构建点数'], 15)
        game.pcmd(string + '\n', numid, _create_world, arg=(numid,))
        numid += 1
    game.askfor_order()
Esempio n. 16
0
def save_func(return_func=None):
    game.clr_cmd()
    if return_func == None:
        return_func = script.mainflow.main_func
    game.pline()
    game.pl('游戏存储目录:' + game.savedir)
    game.pl()

    def savehere(save_file_name):
        game.pl('save: ' + save_file_path)
        game.save(save_file_name)
        save_func(return_func)

    for i in range(0, 11):
        save_file_name = 'save' + str(i)
        save_file_path = game.savedir + '\\' + save_file_name + '.save'

        # 此处修改显示信息
        if os.path.exists(save_file_path):
            file_str = '[{:0>2}]'.format(i) + "  " + save_file_path
        else:
            file_str = '[{:0>2}]'.format(i) + "  ----"
        game.pcmd(file_str, i, savehere, arg=(save_file_name, ))
        game.pl()
    game.pl()
    game.pcmd('[99] 返回', 99, return_func)
    game.askfor_order()
Esempio n. 17
0
def main_func():
    game.clr_cmd()
    game.pl()
    game.pline()
    game.pl('主神名称:' + game.data['主神名称'])
    import script.play_cfg
    script.play_cfg.display_traget()
    game.pline('--')

    import script.play
    game.pcmd('[101]  开始试炼', 101, script.play.init_play)
    game.p('    ')
    import script.play_cfg
    game.pcmd('[102]  试炼设置', 102, script.play_cfg.play_config)
    game.pl()
    import script.people
    game.pcmd('[103]  人物管理', 103, script.people.people_manager)
    game.p('    ')
    import script.group
    game.pcmd('[104]  队伍管理', 104, script.group.group_manager)
    game.p('    ')
    import script.world
    game.pcmd('[105]  世界管理', 105, script.world.world_manager)
    game.pl()
    game.pcmd('[111]  保存游戏', 111, lib.save_func, arg=(main_func, ))
    game.p('    ')
    game.pcmd('[112]  读取游戏', 112, lib.load_func, arg=(main_func, main_func))
Esempio n. 18
0
def open_func(*args):
    game.pline()
    game.pl('pyera 启动中,准备游戏')
    game.def_style('notice', foreground='#DCE441')
    game.def_style('title', foreground='#E1FFFF')
    if not '人物列表' in game.data:
        game.data['人物列表'] = []
    if not '世界列表' in game.data:
        game.data['世界列表'] = []
    if not '队伍列表' in game.data:
        game.data['队伍列表'] = []
    import script.play_cfg
    script.play_cfg.init()
    game.pl(f'pyera 启动中,准备完成')
    test()
    open_menu()
Esempio n. 19
0
def display_traget():
    target_group = game.data['试炼设置']['试炼队伍']
    target_world = game.data['试炼设置']['试炼世界']
    string = '试炼队伍:'
    if target_group == None:
        string = string + game.align('未设定', 12)
    else:
        string = string + game.align(
            target_group['队伍名称'] + '(编号:{})'.format(target_group['ID']), 30)
    string = string + '试炼世界:'
    if target_world == None:
        string = string + game.align('未设定', 12)
    else:
        string = string + target_world['世界名称'] + '(编号:{})'.format(
            target_world['ID'])

    game.pl(string)
Esempio n. 20
0
def draw_map():
    map_size = game.data['map']['map_size']
    snake_list = game.data['snake_list']
    mapdata = game.data['mapdata']
    for y in range(0, map_size):
        for x in range(0, map_size):
            pos = (x, y)
            if pos in snake_list:
                game.p('❖', style='special')
                continue
            if mapdata[pos] == 1:
                game.p('❁')
                continue
            if mapdata[pos] == 0:
                game.p('﹒')
                continue
        game.pl()
Esempio n. 21
0
def open_menu():
    # game.pline()
    # game.pcmd('[001]  开始游戏', 1, newgame_func)
    # game.pl()
    # game.pcmd('[002]  读取游戏', 2, saveload.load_func, arg=(open_menu,))
    # game.askfor_order()
    game.clr_cmd()
    game.pline()
    game.pcmd('[001]  开始游戏', 1)
    game.pl()
    game.pcmd('[002]  读取游戏', 2)

    @game.set_deal_cmd_func_deco
    def deal_func(order):
        if order == 1:
            newgame_func()
        if order == 2:
            lib.load_func(open_menu, main_func)
Esempio n. 22
0
def newgame_func():
    game.pl()
    game.pline()
    game.pl('请输入主神名称:')
    name = game.askfor_str()
    game.data['主神名称'] = name
    game.pl('主神名称为:' + str(name))
    game.pl('是否接受?')
    ans = lib.yes_or_no()
    if ans == True:
        main_func()
    if ans == False:
        newgame_func()
Esempio n. 23
0
def load_func(return_func, next_func):
    game.clr_cmd()
    game.pl('读取游戏:' + game.savedir)
    game.pline()

    def loadhere(load_file_name):
        game.pl('load: ' + load_file_name)
        game.load(load_file_name)
        next_func()

    def loadnodata(load_file_name):
        game.pl(load_file_name + ": 没有数据")

    for i in range(0, 11):
        load_file_name = 'save' + str(i)
        load_file_path = game.savedir + '\\' + load_file_name + '.save'

        # 此处修改显示信息
        if os.path.exists(load_file_path):
            file_str = '[{:0>2}]'.format(i) + "  " + load_file_path
            game.pcmd(file_str, i, loadhere, arg=(load_file_name, ))
        else:
            file_str = '[{:0>2}]'.format(i) + "  ----"
            game.pcmd(file_str, i, loadnodata, arg=(load_file_name, ))
        game.pl()
    game.pl()
    game.pcmd('[99] 返回', 99, return_func)
Esempio n. 24
0
def main_func():
    # 新界面准备
    game.clr_cmd()
    game.pline()

    # 画图
    draw_map()

    def create_func(direction_name):
        def func():
            global direction
            direction = direction_name
            next_step()

        return func

    # 状态显示
    game.pline('--')
    game.pl('分数:')

    # 绘制命令按钮
    game.pline('--')
    game.pcmd('[1] 左  ', 1, create_func('zuo'))
    game.pcmd('[2] 上  ', 2, create_func('shang'))
    game.pcmd('[3] 右  ', 3, create_func('you'))
    game.pl()
    game.p('        ')
    game.pcmd('[4] 下  ', 4, create_func('xia'))
    game.pl('\n')
    game.pcmd('[5] 存储游戏  ', 5, lib.save_func, arg=main_func)
    game.pcmd('[6] 读取游戏  ', 6, lib.load_func, arg=(main_func, main_func))
Esempio n. 25
0
def dispaly_people_list(func=None, askfor_order_atend=True):
    def display_people_here(people):
        display_people(people)
        game.plwait()
        people_manager()

    if func == None:
        func = display_people_here

    string = '----------------------------------' + '人物列表' + '---------------------------------------------'
    game.pl(string, style='title')
    string = game.align('ID', 4) + game.align('姓名', 15) + game.align('体力上限', 8) + '/  ' + \
             game.align('物资补给', 8) + '/  ' + game.align('神秘能源', 8)
    game.pl(string)

    for stu in game.data['人物列表']:
        string = game.align('[' + str(stu['ID']) + ']', 4) + game.align(stu['姓名'], 15) + \
                 game.align(stu['属性']['体力上限'], 8, just='right') + '/  ' + \
                 game.align(stu['属性']['物资补给'], 8, just='right') + '/  ' + \
                 game.align(stu['属性']['神秘能源'], 8, just='right') + '\n'
        game.pcmd(string, stu['ID'], func, arg=(stu, ))

    string = '---------------------------------------------------------------------------------------'
    game.pl(string, style='title')
    if askfor_order_atend == True:
        game.askfor_order()
Esempio n. 26
0
def display_group_list(func=None):
    if func == None:
        func = group_control
    string = '----------------------------------' + '队伍列表' + '---------------------------------------------'
    game.pl(string, style='title')
    string = game.align('队伍编号', 15) + game.align('队伍名称', 15) + game.align(
        '队伍队员', 15)
    game.pl(string)

    def display_memebr_of_groups(agroup):
        string = ''
        for i in range(0, 6):
            if agroup['队伍队员'][i] != {}:
                string = string + agroup['队伍队员'][i]['姓名'] + '|'
        if string == '':
            string = '暂无队员'
        return string

    numid = 101
    for g in game.data['队伍列表']:
        id = '[{:0>3}]'.format(numid)
        string = game.align(id, 15) + game.align(
            g['队伍名称'], 15) + display_memebr_of_groups(g)
        game.pcmd(string + '\n', numid, func, arg=(g, ))
        numid += 1

    string = '---------------------------------------------------------------------------------------'
    game.pl(string, style='title')
Esempio n. 27
0
def load_func(return_func=None):
    game.clr_cmd()
    if return_func == None:
        return_func = script.mainflow.main_func
    game.pl('读取游戏:' + game.savedir)
    game.pline()

    def loadhere(load_file_name):
        game.pl('load: ' + load_file_name)
        game.load(load_file_name)
        script.mainflow.main_func()

    def loadnodata(load_file_name):
        game.pl(load_file_name + ": 没有数据")
        game.askfor_order(print_order=False)

    for i in range(0, 11):
        load_file_name = 'save' + str(i)
        load_file_path = game.savedir + '\\' + load_file_name + '.save'

        # 此处修改显示信息
        if os.path.exists(load_file_path):
            file_str = '[{:0>2}]'.format(i) + "  " + load_file_path
            game.pcmd(file_str, i, loadhere, arg=(load_file_name, ))
        else:
            file_str = '[{:0>2}]'.format(i) + "  ----"
            game.pcmd(file_str, i, loadnodata, arg=(load_file_name, ))
        game.pl()
    game.pl()
    game.pcmd('[99] 返回', 99, return_func)
    game.askfor_order()
Esempio n. 28
0
def group_control(g):
    import script.people
    game.clr_cmd()
    game.pline()
    string = '----------------------------------' + '队伍配置' + '---------------------------------------------'
    game.pl(string, style='title')
    string = '队伍名称:  ' + g['队伍名称']
    game.pl(string)
    for i in range(0, 6):

        def add_people_here(people, i=i):
            clean_people(people)
            add_people_to_group(g, people, i)
            group_control(g)

        def cancel_people_here(i=i):
            g['队伍队员'][i] = {}
            group_control(g)

        num_cmd = (i + 1) * 10

        game.pcmd('[0' + str(i + 1) + '1]设置',
                  num_cmd + 1,
                  script.people.dispaly_people_list,
                  arg=add_people_here)
        game.p('   ')
        game.pcmd('[0' + str(i + 1) + '2]清空', num_cmd + 2, cancel_people_here)
        string = '     队员 ' + str(i + 1) + ':  '
        if g['队伍队员'][i] == {}:
            string += '无'
        else:
            string += g['队伍队员'][i]['姓名']
        game.p(string + '\n')
    string = '---------------------------------------------------------------------------------------'
    game.pl(string, style='title')

    def add_people(people):
        clean_people(people)
        add_people_to_group(g, people)
        group_control(g)

    game.pcmd('[001]  添加队员',
              1,
              script.people.dispaly_people_list,
              arg=add_people)
    game.pl()
    game.pcmd('[099]  返回列表', 99, group_manager)
    game.askfor_order()
Esempio n. 29
0
def event_func_生成世界_基础世界(tpl):
    game.pl('生成世界_基础世界:' + tpl['世界名称'], style='notice')
    tpl['剧情列表'] = []
    tpl['剧情配置'] = []
    for i in range(0, tpl['剧情容量']):
        tpl['剧情列表'].append(game.call_event('生成剧情_赤手蠢贼'))
    game.pl('剧情列表:', 'notice')
    game.pl(tpl['剧情列表'])
    return tpl
Esempio n. 30
0
def open_func():
    game.pl('pyera贪吃蛇游戏加载中')
    map_size = game.data['map']['map_size']
    game.pl('地图大小设置为 ' + str(map_size))
    game.pline()

    game.pcmd('[001]  读取游戏', 1, lib.load_func, arg=(open_func, main_func))
    game.pl()
    game.pcmd('[002]  开始游戏', 2, newgame_func)