From a665e1e31c4622c7677620bc63a10c241da07a10 Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Sat, 1 Jul 2023 13:57:46 -0500 Subject: [PATCH] don't dupe player on rename --- learn_sql_model/game/player.py | 5 ++--- learn_sql_model/models/hero.py | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/learn_sql_model/game/player.py b/learn_sql_model/game/player.py index a6041a5..508c75a 100644 --- a/learn_sql_model/game/player.py +++ b/learn_sql_model/game/player.py @@ -51,16 +51,15 @@ class Player: self.joysticks = {} def rename_hero(self): - old_hero = self.hero hero = HeroFactory().build( size=self.hero.size, x=self.hero.x, y=self.hero.y, - id=old_hero.id, + id=self.hero.id, flashlight_strength=self.hero.flashlight_strength, lanturn_strength=self.hero.lanturn_strength, ) - self.hero = HeroCreate(**hero.dict()).post() + self.hero = HeroUpdate(**hero.dict()).update() def quit(self): try: diff --git a/learn_sql_model/models/hero.py b/learn_sql_model/models/hero.py index 04ff72f..9b23250 100644 --- a/learn_sql_model/models/hero.py +++ b/learn_sql_model/models/hero.py @@ -89,6 +89,7 @@ class HeroUpdate(HeroBase): ) if r.status_code != 200: raise RuntimeError(f"{r.status_code}:\n {r.text}") + return Hero.parse_obj(r.json()) class HeroDelete(BaseModel):