get others every 10 ticks

This commit is contained in:
Waylon Walker 2023-06-10 19:11:53 -05:00
parent 010709a500
commit 8b7a24b908
No known key found for this signature in database
GPG key ID: 66E2BF2B4190EFE4

View file

@ -43,7 +43,8 @@ class Client:
self.moving_left = False self.moving_left = False
self.moving_right = 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) atexit.register(self.quit)
@ -53,6 +54,7 @@ class Client:
self.update() self.update()
self.render() self.render()
self.clock.tick(60) self.clock.tick(60)
self.ticks += 1
self.quit() self.quit()
def quit(self): def quit(self):
@ -72,7 +74,8 @@ class Client:
**{k: v for k, v in self.hero.dict().items() if v is not None} **{k: v for k, v in self.hero.dict().items() if v is not None}
).update() ).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): def render(self):
Console().print(self.hero) Console().print(self.hero)