Exemple #1
0
    def send_enter_game(self, opp_client, team):
        '''
        Send to client that he's entering in a game.  
        team specify the starting position of the ship.
        '''
        # send script
        script = DataBase.get_script(self.username)
        self._send_script(script)
        self.send(Message('sc', None), pickling=True)

        # send opp ship grid
        arr = DataBase.get_ship(opp_client.username)
        self.send(Message('igsh', arr), pickling=True)

        # send own ship grid
        arr = DataBase.get_ship(self.username)
        self.send(Message('sh', arr), pickling=True)

        # notify in game | opponent username, the position id of the ship
        self.send(Message('ign', [opp_client.username, team]), pickling=True)
Exemple #2
0
    def _send_ship(self):
        '''
        Send the ship grid and ship status
        '''
        # ship grid
        arr = DataBase.get_ship(self.username)
        self.send(Message('sh', arr), pickling=True)

        # ship status
        self.send(Message('shst', DataBase.get_ship_status(self.username)),
                  pickling=True)
Exemple #3
0
    def profil_demand(self, username):
        '''
        Get the stats of a user,  
        send stats to user
        '''
        wins = DataBase.get_wins(username)
        loss = DataBase.get_loss(username)
        ship = DataBase.get_ship(username)
        friends = DataBase.get_friends(username)
        grid = DataBase.get_ship(username)

        if self.username in friends:
            friends.remove(self.username)

        msg = Message(
            'rpd', {
                'username': username,
                'wins': wins,
                'loss': loss,
                'friends': friends,
                'grid': grid
            })

        self.send(msg, pickling=True)