Пример #1
0
        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)
Пример #2
0
        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)
Пример #3
0
    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)
Пример #4
0
    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
Пример #5
0
    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
Пример #6
0
    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)
Пример #7
0
    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
Пример #8
0
    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
Пример #9
0
 def record_user_gamedata(self, user, tag, data):
     idx = self.users.index(user)
     self.usergdhistory.append((idx, tag, Client.decode(Client.encode(data))))
Пример #10
0
 def record_user_gamedata(self, user, tag, data):
     idx = self.users.index(user)
     self.usergdhistory.append(
         (idx, tag, Client.decode(Client.encode(data))))