don't dupe player on rename
This commit is contained in:
parent
85be664107
commit
a665e1e31c
2 changed files with 3 additions and 3 deletions
|
|
@ -51,16 +51,15 @@ class Player:
|
||||||
self.joysticks = {}
|
self.joysticks = {}
|
||||||
|
|
||||||
def rename_hero(self):
|
def rename_hero(self):
|
||||||
old_hero = self.hero
|
|
||||||
hero = HeroFactory().build(
|
hero = HeroFactory().build(
|
||||||
size=self.hero.size,
|
size=self.hero.size,
|
||||||
x=self.hero.x,
|
x=self.hero.x,
|
||||||
y=self.hero.y,
|
y=self.hero.y,
|
||||||
id=old_hero.id,
|
id=self.hero.id,
|
||||||
flashlight_strength=self.hero.flashlight_strength,
|
flashlight_strength=self.hero.flashlight_strength,
|
||||||
lanturn_strength=self.hero.lanturn_strength,
|
lanturn_strength=self.hero.lanturn_strength,
|
||||||
)
|
)
|
||||||
self.hero = HeroCreate(**hero.dict()).post()
|
self.hero = HeroUpdate(**hero.dict()).update()
|
||||||
|
|
||||||
def quit(self):
|
def quit(self):
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,7 @@ class HeroUpdate(HeroBase):
|
||||||
)
|
)
|
||||||
if r.status_code != 200:
|
if r.status_code != 200:
|
||||||
raise RuntimeError(f"{r.status_code}:\n {r.text}")
|
raise RuntimeError(f"{r.status_code}:\n {r.text}")
|
||||||
|
return Hero.parse_obj(r.json())
|
||||||
|
|
||||||
|
|
||||||
class HeroDelete(BaseModel):
|
class HeroDelete(BaseModel):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue