def candidate_list(self, level_diff=FRIEND_CANDIDATE_LEVEL_DIFF): # 候选人列表 # 先从最近活跃用户找,如果没有再通找 ap = ActivePlayers() ap_list = ap.get_list() random.shuffle(ap_list) char_ids = [] for c in ap_list: if c == self.char_id: continue if self.is_general_friend(c): continue char_ids.append(c) if len(char_ids) >= FRIEND_CANDIDATE_LIST_AMOUNT: break if len(char_ids) >= FRIEND_CANDIDATE_LIST_AMOUNT: return char_ids # 数量不够,补充 level = self.char.mc.level supply_char_ids = get_char_ids_by_level_range( level - level_diff, level + level_diff, exclude_char_ids=[self.char_id]) for c in supply_char_ids: if self.is_general_friend(c): continue if c in char_ids: continue char_ids.append(c) if len(char_ids) >= FRIEND_CANDIDATE_LIST_AMOUNT: break return char_ids
def candidate_list(self, level_diff=FRIEND_CANDIDATE_LEVEL_DIFF): # 候选人列表 # 先从最近活跃用户找,如果没有再通找 ap = ActivePlayers() ap_list = ap.get_list() random.shuffle(ap_list) char_ids = [] for c in ap_list: if c == self.char_id: continue if self.is_general_friend(c): continue char_ids.append(c) if len(char_ids) >= FRIEND_CANDIDATE_LIST_AMOUNT: break if len(char_ids) >= FRIEND_CANDIDATE_LIST_AMOUNT: return char_ids # 数量不够,补充 level = self.char.mc.level supply_char_ids = get_char_ids_by_level_range(level-level_diff, level+level_diff, exclude_char_ids=[self.char_id]) for c in supply_char_ids: if self.is_general_friend(c): continue if c in char_ids: continue char_ids.append(c) if len(char_ids) >= FRIEND_CANDIDATE_LIST_AMOUNT: break return char_ids
def to_server(self, text): self.check(text) ap = ActivePlayers(self.server_id) active_list = ap.get_list() for cid in active_list: self.to_char(cid, text)
def to_server(self, text): self.check(text) ap = ActivePlayers() active_list = ap.get_list() for cid in active_list: self.to_char(cid, text, check=False)