def notify(): from server.core.game_server import Player pl = self.game.players if self.game_started else map(Player, self.users) s = Client.encode(['player_change', pl]) for cl in self.users: cl.raw_write(s) cl.observers and cl.observers.raw_write(s)
def notify(): from server.core.game_server import Player pl = self.game.players if self.game_started else map( Player, self.users) s = Client.encode(['player_change', pl]) for cl in self.users: cl.raw_write(s) cl.observers and cl.observers.raw_write(s)
def send_lobbyinfo(self, ul): d = Client.encode([ ['current_games', self.games.values()], ['current_users', self.users.values()], ], Client.FMT_BULK_COMPRESSED) p = Pool(6) @p.spawn def send(): for u in ul: @p.spawn def send_single(u=u): u.raw_write(d) self.send_account_info(u)
def kick_user(self, user, other): if user.state not in ('inroomwait', 'ready'): return cl = self.users bl = self.banlist[other] bl.add(user) s = Client.encode(['kick_request', [user, other, len(bl)]]) for cl in self.users: cl.raw_write(s) cl.observers and cl.observers.raw_write(s) return len(bl) >= len(self.users) // 2
def kick_observer(self, user, other): if user not in self.users: return False if GameManager.get_by_user(other) is not self: return False if other.state != 'observing': return False bl = self.ob_banlist[other] bl.add(user) s = Client.encode(['ob_kick_request', [user, other, len(bl)]]) for cl in self.users: cl.raw_write(s) cl.observers and cl.observers.raw_write(s) return len(bl) >= len(self.users) // 2
def record_user_gamedata(self, user, tag, data): idx = self.users.index(user) self.usergdhistory.append((idx, tag, Client.decode(Client.encode(data))))
def record_user_gamedata(self, user, tag, data): idx = self.users.index(user) self.usergdhistory.append( (idx, tag, Client.decode(Client.encode(data))))