#!/usr/bin/env python

import yaml

def validate_encounter(encounter):
    match encounter:
        case "items":
            raise ValueError("'items' is not a valid encounter")
        case "exit":
            exit()
        case _:
            run_encounter(encounter)

def run_encounter(encounter):
    print(encounter['scenario'])
    print(encounter['choices'])
    playerChoice = int(input())
    if playerChoice >= 0 and playerChoice <= 9:
        validate_encounter(game[encounter['choices'][playerChoice]])
    else:
        raise ValueError("Input is invalid\n")

if __name__ == '__main__':
    with open("sample.yaml", "r") as file:
        game = yaml.safe_load(file)
    validate_encounter(game['Title Screen'])