23 lines
No EOL
551 B
Python
23 lines
No EOL
551 B
Python
from __future__ import annotations
|
|
from .tile import *
|
|
from .hand import *
|
|
|
|
import random as rd
|
|
|
|
class Wall:
|
|
def __init__(self):
|
|
self.tiles = Tile.generateAll()
|
|
self.shuffle()
|
|
|
|
def shuffle(self):
|
|
rd.shuffle(self.tiles)
|
|
|
|
def draw(self) -> Tile:
|
|
if len(self.tiles) == 0:
|
|
raise Exception("No more tiles in the wall")
|
|
return self.tiles.pop()
|
|
|
|
def draw_hand(self) -> Hand:
|
|
hand_tiles = [self.draw() for _ in range(13)]
|
|
hand_tiles.sort()
|
|
return Hand(hand_tiles) |