mirror of
https://github.com/evgen-app/chess_rpg_backend.git
synced 2024-11-10 19:57:12 +03:00
updated hero model, add hero model fixture
This commit is contained in:
parent
b0b64f66fa
commit
f2c741bb7f
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,6 +1,6 @@
|
||||||
.idea
|
.idea
|
||||||
static/
|
static/
|
||||||
media/
|
media/uploads/
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
|
|
@ -11,6 +11,7 @@ DEV branch for backend for chess rpg game
|
||||||
### installation
|
### installation
|
||||||
```shell
|
```shell
|
||||||
$ python3 manage.py makemigrations & python3 manage.py migrate
|
$ python3 manage.py makemigrations & python3 manage.py migrate
|
||||||
|
$ python3 manage.py loaddata media/dump_data/hero_model_fixture.json
|
||||||
$ docker run -p 6379:6379 -d redis:5
|
$ docker run -p 6379:6379 -d redis:5
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ class Hero(models.Model):
|
||||||
added = models.DateTimeField(auto_now_add=True)
|
added = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
type = models.CharField(blank=False, choices=HeroTypes.choices, max_length=7)
|
type = models.CharField(blank=False, choices=HeroTypes.choices, max_length=7)
|
||||||
model = models.ForeignKey("HeroModelSet", on_delete=models.CASCADE)
|
model_f = models.ForeignKey("HeroModelSet", on_delete=models.CASCADE)
|
||||||
health = models.IntegerField(
|
health = models.IntegerField(
|
||||||
validators=[MinValueValidator(1), MaxValueValidator(10)], blank=False
|
validators=[MinValueValidator(1), MaxValueValidator(10)], blank=False
|
||||||
)
|
)
|
||||||
|
@ -108,14 +108,8 @@ class Hero(models.Model):
|
||||||
validators=[MinValueValidator(1), MaxValueValidator(10)], blank=False
|
validators=[MinValueValidator(1), MaxValueValidator(10)], blank=False
|
||||||
)
|
)
|
||||||
|
|
||||||
def idle_img(self):
|
def model(self):
|
||||||
return self.idle_img_f.image.url
|
return self.model_f.model.url
|
||||||
|
|
||||||
def attack_img(self):
|
|
||||||
return self.attack_img_f.image.url
|
|
||||||
|
|
||||||
def die_img(self):
|
|
||||||
return self.die_img_f.image.url
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.type} {self.player.name}"
|
return f"{self.type} {self.player.name}"
|
||||||
|
@ -145,7 +139,7 @@ class Hero(models.Model):
|
||||||
|
|
||||||
class HeroModelSet(models.Model):
|
class HeroModelSet(models.Model):
|
||||||
hero_type = models.CharField(blank=False, choices=HeroTypes.choices, max_length=7)
|
hero_type = models.CharField(blank=False, choices=HeroTypes.choices, max_length=7)
|
||||||
model = models.ImageField(upload_to="uploads/")
|
model = models.FileField(upload_to="uploads/")
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.hero_type} model file"
|
return f"{self.hero_type} model file"
|
||||||
|
|
BIN
media/dump_data/dump.jpg
Normal file
BIN
media/dump_data/dump.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 145 KiB |
BIN
media/dump_data/dump_1P13Svy.jpg
Normal file
BIN
media/dump_data/dump_1P13Svy.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 145 KiB |
BIN
media/dump_data/dump_d6lH7IJ.jpg
Normal file
BIN
media/dump_data/dump_d6lH7IJ.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 145 KiB |
BIN
media/dump_data/dump_mx4zxHq.jpg
Normal file
BIN
media/dump_data/dump_mx4zxHq.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 145 KiB |
34
media/dump_data/hero_model_fixture.json
Normal file
34
media/dump_data/hero_model_fixture.json
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"model": "game.heromodelset",
|
||||||
|
"pk": 1,
|
||||||
|
"fields": {
|
||||||
|
"hero_type": "KING",
|
||||||
|
"model": "dump_data/dump.jpg"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "game.heromodelset",
|
||||||
|
"pk": 2,
|
||||||
|
"fields": {
|
||||||
|
"hero_type": "WARRIOR",
|
||||||
|
"model": "dump_data/dump_mx4zxHq.jpg"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "game.heromodelset",
|
||||||
|
"pk": 3,
|
||||||
|
"fields": {
|
||||||
|
"hero_type": "ARCHER",
|
||||||
|
"model": "dump_data/dump_d6lH7IJ.jpg"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "game.heromodelset",
|
||||||
|
"pk": 4,
|
||||||
|
"fields": {
|
||||||
|
"hero_type": "WIZARD",
|
||||||
|
"model": "dump_data/dump_1P13Svy.jpg"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user