fixed hero api lookup

This commit is contained in:
Alexander Karpov 2022-07-02 23:51:15 +03:00
parent f2c741bb7f
commit 9d4871296a
2 changed files with 3 additions and 15 deletions

View File

@ -22,9 +22,7 @@ class GetHeroSerializer(serializers.ModelSerializer):
fields = (
"added",
"type",
"idle_img",
"attack_img",
"die_img",
"model",
"health",
"attack",
"speed",
@ -37,9 +35,7 @@ class ListHeroSerializer(serializers.ModelSerializer):
fields = (
"uuid",
"type",
"idle_img",
"attack_img",
"die_img",
"model",
"health",
"attack",
"speed",

View File

@ -117,15 +117,7 @@ class Hero(models.Model):
def save(
self, force_insert=False, force_update=False, using=None, update_fields=None
):
self.idle_img_f = random.choice(
[x for x in HeroModelSet.objects.filter(hero_type=self.type)]
)
self.attack_img_f = random.choice(
[x for x in HeroModelSet.objects.filter(hero_type=self.type)]
)
self.die_img_f = random.choice(
[x for x in HeroModelSet.objects.filter(hero_type=self.type)]
)
self.model_f = random.choice(HeroModelSet.objects.filter(hero_type=self.type))
super(Hero, self).save()
class Meta: