def update_other_players(self, player_list: List): for p in player_list: mem = self.get_player_by_name(p.name) if mem is None: memid = PlayerNode.create(self, p) else: memid = mem.memid self.other_players[memid] = p
def get_mem_by_id(self, memid: str, table: str = None) -> "MemoryNode": if table is None: table = self.get_memid_table(memid) def dummy_s(g): # sorry :( return lambda s, y: g(y) if table is None: return from_id = { "InstSeg": lambda s, memid: InstSegNode(s, memid), "BlockObjects": dummy_s(self.get_object_by_id), "ComponentObjects": dummy_s(self.get_component_object_by_id), "Schematics": dummy_s(self.get_schematic_by_id), "Chats": dummy_s(self.get_chat_by_id), "Mobs": dummy_s(self.get_mob_by_id), "Tasks": dummy_s(self.get_task_by_id), "Players": lambda s, memid: PlayerNode(s, memid), "Self": lambda s, memid: MemoryNode(s, memid), "Triples": lambda s, memid: MemoryNode(s, memid), "Locations": lambda s, memid: MemoryNode(s, memid), "Dances": lambda s, memid: MemoryNode(s, memid), } return from_id[table](self, memid)
def get_player_by_id(self, memid) -> "PlayerNode": return PlayerNode(self, memid)
def get_player_by_name(self, name) -> Optional["PlayerNode"]: r = self._db_read_one("SELECT uuid FROM Players WHERE name=?", name) if r: return PlayerNode(self, r[0]) else: return None