import json
import random
import pygame
from pathlib import Path
from typing import List
from Rooms import Room


background_colour = (0, 76, 153)
screen = pygame.display.set_mode((400, 300))
pygame.display.set_caption('Dice Rolling') 
screen.fill(background_colour)                            
pygame.display.flip()
running = True

dice = ["1", "2",]
sides = ["4", "6", "8", "10", "12", "20"]

def parse_input(input_string: str, my_list: List):
    if input_string.strip() in my_list:
        return int(input_string)
    else:
        show_list = ""
        for element in my_list:
            show_list += f"{element},"
        show_list = show_list[:-1]
        print(f"Please enter a number from [{show_list}].")
        raise SystemExit(1) 

def roll_dice(num_dice: int, num_sides: int = 6):
    roll_results = []
    for _ in range(num_dice):
        roll = random.randint(1, num_sides)
        roll_results.append(roll)
    return roll_results

#User Inout on howmany dice to roll
num_dice_input = input(f"How many dice do you want to roll? [{dice[0]}-{dice[-1]}] ")
num_dice = parse_input(num_dice_input, dice)
print(num_dice)

my_list = ""
for sided in sides:
    my_list += f"{sided},"
my_list = my_list[:-1]
num_sides_input = input(f"How many sides from [{my_list}] ")
num_sides = parse_input(num_sides_input, sides)
print(num_sides)

#Results of ice roll

num_dice_input = roll_dice(num_dice, num_sides)

print(num_dice_input)