32 lines
708 B
Python
32 lines
708 B
Python
# File: Dice.py
|
|
# Description: Dice Class
|
|
# Author: ZiTing Wang
|
|
# Student ID: 2218040103
|
|
# This is my own work as defined by
|
|
# the University's Academic Misconduct Policy.
|
|
#
|
|
import random
|
|
|
|
class Dice:
|
|
diceStrings = {
|
|
1: '⚀',
|
|
2: '⚁',
|
|
3: '⚂',
|
|
4: '⚃',
|
|
5: '⚄',
|
|
6: '⚅'
|
|
}
|
|
|
|
def __init__(self):
|
|
self.point = 0
|
|
|
|
def roll(self):
|
|
self.point = random.randint(1, 7)
|
|
|
|
def getPointOfDice(self, power: int) -> tuple[int | int, str]:
|
|
self.roll()
|
|
currentPoint = self.point + power
|
|
if currentPoint > 6:
|
|
currentPoint = currentPoint % 6
|
|
return currentPoint, self.diceStrings[currentPoint]
|