本文整理汇总了Python中tile.Tile.set_face方法的典型用法代码示例。如果您正苦于以下问题:Python Tile.set_face方法的具体用法?Python Tile.set_face怎么用?Python Tile.set_face使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tile.Tile
的用法示例。
在下文中一共展示了Tile.set_face方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tiles_from_string
# 需要导入模块: from tile import Tile [as 别名]
# 或者: from tile.Tile import set_face [as 别名]
def tiles_from_string(cls, word):
"""
Takes a string, with blanks in lowercase and pre-played tiles
in parentheses, and returns a list of two lists of tiles: the
first with all the tiles, and the other with just the played ones
and None where tiles are on the board.
Example: PORt(MANtEAU)X
"""
without_parens = word.replace('()', '') # remove parentheses
all_tiles = []
just_played_tiles = []
for index, tile in enumerate(without_parens):
if tile in '()': # skip over these
continue
first_part = word[:index]
if first_part.count('(') > first_part.count(')'): # on board
if tile.islower(): # a blank
blank = Tile('?')
blank.set_face(tile.upper())
all_tiles.append(blank)
just_played_tiles.append(None) # mark spot
else:
all_tiles.append(Tile(tile))
just_played_tiles.append(None) # mark spot
else: # belongs in both
if tile.islower(): # a blank
blank = Tile('?')
blank.set_face(tile.upper())
just_played_tiles.append(blank)
all_tiles.append(blank)
else:
just_played_tiles.append(Tile(tile))
all_tiles.append(Tile(tile))
return [all_tiles, just_played_tiles]