コード例 #1
0
def test_characters():
    # sem is used to reduce number of running instances of mugen
    sem = asyncio.Semaphore(max_parallel_matches)
    characters_path = Match.mugen_folder + 'chars\\'
    working_path = normpath(join(characters_path, '..\\working_chars\\'))
    characters_list = get_characters(characters_path)
    running_tasks = set()

    try:
        os.mkdir(working_path)
    except FileExistsError:
        pass

    def done_cb(f):
        sem.release()
        running_tasks.remove(f)
        match = f.result()
        if match:
            move_character(match.player1, working_path)

    for player in list(characters_list):
        yield from sem
        match = Match(player1=player)
        task = asyncio.Task(match_in_thread(match))
        task.add_done_callback(done_cb)
        running_tasks.add(task)

        # this sleep is required to ensure the window gets focus.
        # without gaining focus, the game will never start
        yield from asyncio.sleep(1.5)

    # wait for all all processes to complete or be killed
    yield from asyncio.wait(running_tasks)
コード例 #2
0
 def test_get_characters(self):
     characters_path = self.mugen_folder + 'chars\\'
     for char in get_characters(characters_path):
         pass
コード例 #3
0
    print(empty_space, file=fp)


def guess_character_space(line):
    return len(line) > 1


if __name__ == "__main__":
    import os
    from os.path import join

    root = 'z:\\Leif\\Dropbox\\mugen\\testing-build\\'
    os.chdir(root)

    new_select = open(join(root, 'data', 'select.def'), 'w')
    characters = get_characters(char_dir)
    current_section = None
    exhausted_characters = False
    written_characters = False
    skip_section = False

    # fill in the characters
    with open(join(root, 'data', 'template.def')) as fp:
        for line in fp:
            line = line.strip()

            match = header_regex.match(line)
            if match:
                skip_section = False
                header = match.group('header').lower()
                current_section = '[' + header + ']'