fill out Map.number()
This commit is contained in:
parent
6aa515aa2d
commit
a99c914e40
24
Map.py
24
Map.py
@ -1,4 +1,7 @@
|
||||
|
||||
import sys
|
||||
import random
|
||||
|
||||
# odd-numbered rows are right-shifted by half a tile width
|
||||
class Map(object):
|
||||
def __init__(self):
|
||||
@ -48,3 +51,24 @@ class Map(object):
|
||||
|
||||
def number(self):
|
||||
self._finalize()
|
||||
red_possibilities = dict(zip(self._list, self._list))
|
||||
to_number = dict(zip(self._list, self._list))
|
||||
if len(red_possibilities) != 19:
|
||||
sys.stderr('Map.number() only supports maps of 19 tiles!')
|
||||
return
|
||||
for red in [6, 6, 8, 8]:
|
||||
rp = red_possibilities.keys()
|
||||
random.shuffle(rp)
|
||||
tile = rp[0]
|
||||
tile.roll_val = red
|
||||
del to_number[tile]
|
||||
del red_possibilities[tile]
|
||||
for t in self._neighbors[tile]:
|
||||
del red_possibilities[tile]
|
||||
tiles = to_number.keys()
|
||||
random.shuffle(tiles)
|
||||
zipped = zip(tiles, [2, 3, 3, 4, 4, 5, 5, 9, 9, 10, 10, 11, 11, 12])
|
||||
def assign_roll_val(tr):
|
||||
tile, rv = tr
|
||||
tile.roll_val = rv
|
||||
map(assign_roll_val, zipped)
|
||||
|
Loading…
x
Reference in New Issue
Block a user