コード例 #1
0
ファイル: play.py プロジェクト: paunding/Clover-Edition
def newStory(generator, prompt, context):
    story = Story(generator, prompt)
    assert (story.prompt)
    first_result = story.act(context)
    colPrint(prompt, colors['user-text'], end='')
    colPrint(context, colors['user-text'], end='')
    colPrint(first_result[0], colors['ai-text'], end='')
    print("\n\n")
    return story
コード例 #2
0
ファイル: play.py プロジェクト: pirone2/Clover-Edition
def load_story(f, gen):
    with f.open('r', encoding="utf-8") as file:
        try:
            story = Story(gen, "")
            story.savefile = os.path.splitext(file.name.strip())[0]
            story.from_json(file.read())
            return story, story.context, story.actions[-1] if len(
                story.actions) > 0 else ""
        except FileNotFoundError:
            output("Save file not found. ", "error")
        except IOError:
            output("Something went wrong; aborting. ", "error")
    return None, None, None
コード例 #3
0
ファイル: play.py プロジェクト: pirone2/Clover-Edition
def new_story(generator, context, prompt, memory=None, first_result=None):
    if memory is None:
        memory = []
    context = context.strip()
    prompt = prompt.strip()
    story = Story(generator, context, memory)
    if first_result is None:
        story.act(prompt)
    else:
        story.actions.append(prompt)
        story.results.append(first_result)
    story.print_story()
    return story
コード例 #4
0
ファイル: play.py プロジェクト: runrepik/Clover-Edition
def new_story(generator, context, prompt, memory=None, first_result=None):
    if memory is None:
        memory = []
    context = context.strip()
    prompt = prompt.strip()
    erase = 0
    if use_ptoolkit():
        erase = output(context, 'user-text', prompt, 'user-text', sep="\n\n")
    story = Story(generator, context, memory)
    if first_result is None:
        story.act(prompt)
    else:
        story.actions.append(prompt)
        story.results.append(first_result)
    clear_lines(erase)
    story.print_story()
    return story