From 8b7a24b9084f0c7414c64204c1e0ffab93425c9e Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Sat, 10 Jun 2023 19:11:53 -0500 Subject: [PATCH] get others every 10 ticks --- learn_sql_model/game/game.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/learn_sql_model/game/game.py b/learn_sql_model/game/game.py index bcb63c9..dc09e46 100644 --- a/learn_sql_model/game/game.py +++ b/learn_sql_model/game/game.py @@ -43,7 +43,8 @@ class Client: self.moving_left = False self.moving_right = False - self.others = HeroRead.list() + self.others = [hero for hero in HeroRead.list() if hero.id != self.hero.id] + self.ticks = 0 atexit.register(self.quit) @@ -53,6 +54,7 @@ class Client: self.update() self.render() self.clock.tick(60) + self.ticks += 1 self.quit() def quit(self): @@ -72,7 +74,8 @@ class Client: **{k: v for k, v in self.hero.dict().items() if v is not None} ).update() - self.others = HeroRead.list() + if self.ticks % 10 == 0: + self.others = [hero for hero in HeroRead.list() if hero.id != self.hero.id] def render(self): Console().print(self.hero)