Commit 54fe1d69 authored by Studer Brendan's avatar Studer Brendan
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+166 −0
Original line number Diff line number Diff line
# Created by https://www.toptal.com/developers/gitignore/api/python
# Edit at https://www.toptal.com/developers/gitignore?templates=python

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
#  Usually these files are written by a python script from a template
#  before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
#   For a library or package, you might want to ignore these files since the code is
#   intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
#   According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
#   However, in case of collaboration, if having platform-specific dependencies or dependencies
#   having no cross-platform support, pipenv may install dependencies that don't work, or not
#   install all needed dependencies.
#Pipfile.lock

# poetry
#   Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
#   This is especially recommended for binary packages to ensure reproducibility, and is more
#   commonly ignored for libraries.
#   https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
#   Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
#   pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
#   in version control.
#   https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
#  JetBrains specific template is maintained in a separate JetBrains.gitignore that can
#  be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
#  and can be added to the global gitignore or merged into this file.  For a more nuclear
#  option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# End of https://www.toptal.com/developers/gitignore/api/python

Chapters.json

0 → 100644
+0 −0

File added.

Preview size limit exceeded, changes collapsed.

EOLJsonParser.py

0 → 100644
+113 −0
Original line number Diff line number Diff line
import json
import sys, getopt
import os
import logging
import shutil

logging.basicConfig(format='[%(name)s::%(levelname)s]\t\t%(message)s', level=logging.DEBUG)
_logger = logging.getLogger("EOLJsonParser")

def show_chapters(chapters):
    print("=============== CHAPITRES ===============-")
    for chapter in chapters:
        print(f"Id: \t\t{chapter['Id']}")
        print(f"Nom: \t\t{chapter['Name']}")
        print(f"Scènes({len(chapter['Scenes'])})")
        for scenes in chapter['Scenes']:
            print(f"\t\t\t{scenes['Title']} ({len(scenes['Interactions'])})")
        print("======================================")
        
def normalize_string(text):
    return text.lower().replace(" ","_").replace("é","e").replace("ê","e").replace("è","e").replace("à","a")


def main(argv):
    inputfile = 'Chapters.json'
    outputFolder = 'Output'
    tree = False
    try:
        opts, args = getopt.getopt(argv,"hti:o:",["ifile=","ofile=","tree"])
    except getopt.GetoptError:
        print('EODLJsonParser.py -i <inputfile> -o <outputFolder>')
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print('EODLJsonParser.py -i <inputfile> -o <outputFolder>')
            sys.exit()
        elif opt in ("-i", "--ifile"):
            inputfile = arg
        elif opt in ("-o", "--ofile"):
            outputFolder = arg
        elif opt in ("-t", "--tree"):
            tree = True
            
            
    with open(inputfile, 'r', encoding="utf-8") as j:
        contents = json.loads(j.read())
        
        #If --tree argument exists
        if tree:
            show_chapters(contents["Chapters"])
            sys.exit(0)
        
        #if output folder already exist, we delete it
        if os.path.exists(outputFolder):
            shutil.rmtree(outputFolder)
        
        _logger.debug(f"Creating {outputFolder} folder...")
        os.mkdir(outputFolder)
        
        #Iterate over chapters
        for chapter in contents["Chapters"]:
            chapter_name = normalize_string(chapter["Name"])
            chapter_folder = os.path.join(outputFolder,chapter_name)
            os.mkdir(chapter_folder)
            
            #create intro file
            intro_file_name = chapter_name + "_intro.nani"
            intro_file_path = os.path.join(chapter_folder,intro_file_name)
            with open(intro_file_path, 'w', encoding='utf-8') as f:
                f.write("@back Hospital\n")
                f.write("@spawn Blur wait:false\n")
                f.write("@printer Fullscreen\n")
                f.write(f"{chapter['Name']}\n")
                f.write(f"{chapter['Intro']}\n")
                f.write(f"@goto {normalize_string(chapter['Scenes'][0]['Title'])}")            
            
            for scene in chapter["Scenes"]:
                scene_name = normalize_string(scene["Title"])
                scene_path = os.path.join(chapter_folder,scene_name)
                os.mkdir(scene_path)
                
                #We create and write the scene in a naninovel file
                naninovel_file = scene_name + ".nani"
                naninovel_file_path = os.path.join(scene_path,naninovel_file)

                with open(naninovel_file_path, 'w', encoding='utf-8') as f:
                    
                    #First we create environment and introduction
                    f.write("@back Hospital\n")
                    f.write("@printer Fullscreen\n")
                    f.write(f"{scene['SceneIntroduction']}\n\n")
                    
                    f.write("@printer Dialogue\n")
                    #Iterate over interactions
                    for interaction in scene["Interactions"]:
                        f.write(f"# {interaction['Id']}\n")
                        f.write(f"@char {interaction['Actor']['Name']}\n")
                        f.write(f"{interaction['Actor']['Name']}: {interaction['Text']}\n\n")
                        
                        for choice in interaction['Responses']:
                            f.write(f"@choice \"{choice['Text']}\" goto:.{choice['NextInteractionID']}\n")
                        
                        f.write("@stop\n\n")
        _logger.debug("DONE !")
        
        
        
    

if __name__ == "__main__":
    main(sys.argv[1:])
    
 No newline at end of file
+132 −0
Original line number Diff line number Diff line
@back Hospital
@printer Fullscreen
Deux jours plus tard, Agathe a bénéficié d’un traitement morphinique selon le standard qui réduit fortement sa sensation d’étouffement. En plus de l’oxygénothérapie, l’équipe infirmière a mis en place des soins de bouche aux deux heures, ainsi qu’un humidificateur et un ventilateur pour réduire encore sa sensation d’étouffement. Agathe a renoncé à Exit. Avec l’aide de Claude, elle a rédigé un formulaire de directives anticipées qui précisent qu’elle ne veut pas être réanimée, qu’elle ne veut pas de traitement visant à prolonger sa vie et que l’on soigne activement les symptômes tels que la douleur, la peur, la détresse respiratoire et les nausées. Elle refuse d’être alimentée et hydratée si la situation se péjorait et qu’elle serait incapable de discernement.
Agathe sonne. Claude se rend à son chevet. Claude frappe et entre.

@printer Dialogue
# 1
@char Claude
Claude: Claude frappe et entre

@choice "Vous avez sonné Agathe. Qu’est-ce que je peux faire pour vous ?" goto:.2
@stop

# 2
@char Agathe
Agathe: Agathe est alitée. Elle parle lentement à voix basse. Elle a de la peine à respirer et à articuler. Son regard est encore vif. Ses yeux brillent.

@choice "On vous a forcé à boire ?" goto:.3
@stop

# 3
@char Agathe
Agathe: Charlotte, ce matin. Elle a insisté ! Je ne voulais pas.

@choice "Vous n’arrivez plus à avaler ?" goto:.4
@stop

# 4
@char Agathe
Agathe: Je m’étrangle ! J’ai plus envie de boire.

@choice "Ça devient trop difficile pour vous ?" goto:.5
@stop

# 5
@char Agathe
Agathe: J’en peux plus.

@choice "C’est important de boire." goto:.6
@stop

# 6
@char Agathe
Agathe: Arrêtez ça !

@choice "Ce n’est plus supportable pour vous." goto:.7
@stop

# 7
@char Agathe
Agathe: Oui, arrêtez ça.

@choice "Vous souhaitez qu’on arrête de vous donner à boire ?" goto:.8
@stop

# 8
@char Agathe
Agathe: Oui.

@choice "Si j’ai bien compris votre demande, pour vous l’important maintenant c’est de ne pas être contrainte de boire." goto:.9
@stop

# 9
@char Agathe
Agathe: Oui, on l’a écrit sur un papier.

@choice "Je vais transmettre votre volonté à l’équipe." goto:.10
@stop

# 10
@char Agathe
Agathe: Merci !

@choice "Votre décision me touche. Je suis triste. Vous comptez beaucoup pour moi. Et nous savons tous les deux que sans liquide, vous n’allez plus vivre très longtemps." goto:.11
@stop

# 11
@char Agathe
Agathe: C’est ma décision ! Merci de me respecter.

@choice "Long silence. Claude prend la main d’Agathe. Elle la regarde. " goto:.12
@stop

# 12
@char Agathe
Agathe: N’en parlez pas à mes enfants.

@choice "Quand ma grand-maman est morte, j’étais à ses côtés. Elle m’a fait un magnifique cadeau. Nous avons pu encore ensemble partager son dernier moment de vie. Qu’en penserait votre fille ?" goto:.13
@stop

# 13
@char Agathe
Agathe: Ma fille me forcera à boire.

@choice "Et si votre fille aussi respectait votre choix de ne plus boire. Qu’est-ce que ça changerait pour vous ?" goto:.14
@stop

# 14
@char Agathe
Agathe: Ça changerait tout.

@choice "Ce qui est important pour vous, c’est que vos enfants respectent votre choix." goto:.15
@stop

# 15
@char Agathe
Agathe: Oui.

@choice "J’ai l’impression qu’il est aussi important pour vous de revoir vos enfants avant de mourir." goto:.16
@stop

# 16
@char Agathe
Agathe: Des larmes coulent sur les joues d’Agathe. Claude se rapproche d’elle. Long silence.

@choice "Ça vous rend triste. Je peux vous aider, si vous voulez, à partager tout cela avec vos enfants." goto:.17
@stop

# 17
@char Agathe
Agathe: Je veux mourir seule.

@choice "Long silence. Je vous entends. Et je n’en parlerai pas à vos enfants. Est-ce que je peux faire encore quelque chose pour vous maintenant ?" goto:.18
@stop

# 18
@char Agathe
Agathe: Non. Laissez-moi reposer en paix.

@choice "Claude sort en silence.Trois jours plus tard, selon ses volontés, Agathe est décédée seule dans sa chambre. Il est très diffcile pour Claude d’accepter sa mort. Elle a, en peu de temps, noué des liens très forts avec Agathe et s’est beaucoup investie dans cette relation." goto:.19
@stop
+7 −0
Original line number Diff line number Diff line
@back Hospital
@spawn Blur wait:false
@printer Fullscreen
La fin de vie
Troisième chapitre, représentations individuelles et collectives de la fin de vie
@goto les_dernieres_volontes
 No newline at end of file