def load(self, game): """load the tiles according to game.ruleset""" for tile in self.tiles: tile.setBoard(None) self.tiles = [] self.allSelectorTiles = list(Tile(x) for x in elements.all(game.ruleset)) self.refill()
def startGame(self, requests): """if all players said ready, start the game""" mayStart = True for msg in requests: if msg.answer == Message.NO or len(requests) < 4: # this player answered "I am not ready", exclude her from table # a player might already have logged of from the table. So if we # are not 4 anymore, all players must leave the table self.server.leaveTable(msg.player.remote, self.tableid) # TODO: the other players are still asked for game start - table should be reset instead self.preparedGame = None mayStart = False if not mayStart: return self.game = self.preparedGame elementIter = iter(elements.all(self.game.ruleset)) for tile in self.game.wall.tiles: tile.element = elementIter.next() tile.element = tile.upper() assert isinstance(self.game, RemoteGame), self.game self.status = m18ncE('table status', 'Running') self.preparedGame = None # if the players on this table also reserved seats on other tables, # clear them for user in self.users: for tableid in self.server.tables.keys()[:]: if tableid != self.tableid: self.server.leaveTable(user, tableid) # tell other users not involved in this table that it is now running for user in self.server.users: if user not in self.users: self.server.callRemote(user, 'replaceTable', self.msg()) self.sendVoiceIds()
def load(self, game): """load the tiles according to game.ruleset""" for tile in self.tiles: tile.setBoard(None) self.tiles = [] self.allSelectorTiles = list(UITile(x) for x in elements.all(game.ruleset)) self.refill()