Files
GDMC-2024/utils/functions.py
2024-05-26 01:37:06 +02:00

6 lines
296 B
Python

from enum import Enum
import random as rd
def select_random(rdata : dict, enum : Enum) -> Enum:
# select a random value of the dict according to his coef and return the corresponding value in the enum
return enum[rd.choice([elt for elt,num in rdata.items() for _ in range(num)]).upper()]