Exemple #1
0
 def del_friend(self, username):
     # update data
     other_index = Data.users[Data.users['username'] == username].index[0]
     Data.users.loc[self.index, 'friends'].remove(other_index)
     Data.users.loc[other_index, 'friends'].remove(self.index)
     if Interaction.is_connected(username):
         other_client = Interaction.get_client(username)
         send(other_client.conn, f'delfr|{self.username}')
Exemple #2
0
 def create_env(self, username):
     # check other is conn
     if Interaction.is_connected(username):
         other_client = Interaction.get_client(username)
         self.env = Env((self, other_client),
                        (self.username, other_client.username))
         other_client.env = self.env
         Interaction.inform_inenv(other_client.username)
         other_client.in_env = True
         self.in_env = True
Exemple #3
0
 def check_env_rinv(self, username):
     # check other is conn
     if Interaction.is_connected(username):
         other_client = Interaction.get_client(username)
         # check if other client is already in env
         if other_client.in_env:
             other_client.env.add_client(self)
             self.in_env = True
             self.env = other_client.env
         else:
             self.create_env(username)
         Interaction.inform_inenv(self.username)
Exemple #4
0
 def add_friend(self, username):
     other_index = Data.users[Data.users['username'] == username].index[0]
     # add friend to data
     Data.users.loc[self.index, 'friends'].append(other_index)
     Data.users.loc[other_index, 'friends'].append(self.index)
     # remove other from demands
     Data.users.loc[self.index, 'demands'].remove(other_index)
     store_user_data()
     Interaction.manage_friends(self)
     # if other is connected, update his friends
     if Interaction.is_connected(username):
         other_client = Interaction.get_client(username)
         Interaction.manage_friends(other_client)
Exemple #5
0
 def invite_friend(self, username):
     # check if friend is conn
     if Interaction.is_connected(username):
         other_client = Interaction.get_client(username)
         send(other_client.conn, f'inv|{self.username}')