import random
dice = [1,2,3,4,5]
pointName = ['Jedynki', 'Dwójki', 'Trójki', 'Czwórki','Piątki', 'Szóstki' ]
points = ['','','','','','']
def rollDices(diceNumber: str):
    for i in diceNumber:
        index = int(i) - 1
        dice[index] = random.randint(1,6)

def printResults():
    toprint = ""
    for i in range(len(dice)):
        current = dice[i]
        if i == 0:
            toprint += "roll result:"
            toprint += f" {current},"
        elif i == len(dice) - 1 :
            toprint += f" {current}"
        else:
            toprint += f" {current},"

    print(toprint)

def checkIfPlaying():
    continuee = input("do you want to roll again? type 'y' if yes and 'n' if no")
    if continuee == "y":
        return  True
    else:
        return  False
    
def showTable():
    print('_______________________________________')
    for i in range(len(points)):
        print(f'{i+1}.{pointName[i]}\t{points[i]}')
    print('_______________________________________')

rollDices("12345")
showTable()
printResults()



playing = True

for i in range(2):
    ifreset =  checkIfPlaying()
    if ifreset:
        diceToThrow = input('Pick the dices you want to roll (exp. typing "124" will roll 1st 2nd and 4th dice)')
        rollDices(diceToThrow)
        printResults()
    else:
        break

def insertInNum(num):
    PointAmount = 0
    for dices in dice:
        if dices == num:
            PointAmount += dices
    points[num - 1] = PointAmount

def insertPoints():
    area = int(input('where do you want to place your points?'))
    if points[area - 1] == '':
        if 1 <= area <= 6:
            insertInNum(area)
    else:
        print("the area where the points will be inserted has been chosen")
        insertPoints()


showTable()
printResults()
insertPoints()
showTable()

    