예제 #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
파일: lobby.py 프로젝트: feisuzhu/thbattle
    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))))