tweaks for server using serialization

This commit is contained in:
2026-01-26 10:11:44 +01:00
parent 6e14cb65c3
commit 0504e90754
8 changed files with 90 additions and 43 deletions

14
dice.py
View File

@@ -1,15 +1,13 @@
import random as rd
class Dice():
def __init__(self):
raise TypeError("Un dé ne peut pas être instanciée!")
@staticmethod
def roll(self, num_faces=20):
return rd.randrange(start=1, stop=num_faces+1, step=1)
def __init__(self, num_faces:int=20):
self.num_faces = num_faces
@staticmethod
def head_or_tails():
def roll(self):
return rd.randrange(start=1, stop=self.num_faces+1, step=1)
def head_or_tails(self):
result = rd.randint(0,1)
if result: # true
return "head" # face