python-archieve-projects/M3101/2/Dice.py

34 lines
685 B
Python

# File: Dice.py
# Description: Dice Class
# Author: Yirui Guo
# Student ID: 2218040201
# This is my own work as defined by
# the University's Academic Misconduct Policy.
#
import random
from typing import Tuple
class Dice:
symbols = {
1: '',
2: '',
3: '',
4: '',
5: '',
6: ''
}
def __init__(self):
self.point = 0
def roll(self):
self.point = random.randint(1, 7)
def get_point_of_dice(self, power: int) -> tuple[int | int, str]:
self.roll()
point = self.point + power
if point > 6:
point = point % 6
return point, self.symbols[point]