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):