1
0
mirror of https://github.com/creyD/asiimov.git synced 2026-06-11 16:42:23 +02:00

Moved wear to itemtype

This commit is contained in:
2020-01-24 07:33:50 +01:00
parent 0c080fdfdb
commit 0471e8031f
4 changed files with 36 additions and 7 deletions

View File

@@ -5,7 +5,7 @@ from .models import ItemType, ItemInstance, Badge, Gamer
# Register your models here.
@admin.register(ItemType)
class ItemTypeAdmin(admin.ModelAdmin):
list_display = ('paint_index', 'name', 'type', 'rarity', 'min_float', 'max_float', 'tradable')
list_display = ('paint_index', 'wear', 'name', 'type', 'rarity', 'min_float', 'max_float', 'tradable')
list_editable = ()
@@ -16,7 +16,7 @@ class GamerAdmin(admin.ModelAdmin):
@admin.register(ItemInstance)
class ItemInstanceAdmin(admin.ModelAdmin):
list_display = ('item_class', 'instanceid', 'market_tradable_restriction', 'inspect_link', 'wear', 'float', 'paintseed', 'killeatervalue', 'customname')
list_display = ('item_class', 'instanceid', 'market_tradable_restriction', 'inspect_link', 'float', 'paintseed', 'killeatervalue', 'customname')
@admin.register(Badge)

View File

@@ -0,0 +1,28 @@
# Generated by Django 3.0.2 on 2020-01-24 05:56
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0007_remove_gamer_api_key'),
]
operations = [
migrations.RemoveField(
model_name='iteminstance',
name='wear',
),
migrations.AddField(
model_name='itemtype',
name='wear',
field=models.CharField(default='Factory-New', max_length=100),
preserve_default=False,
),
migrations.AlterField(
model_name='offer',
name='items_want',
field=models.ManyToManyField(related_name='WantedItems', to='core.ItemType'),
),
]

View File

@@ -19,6 +19,7 @@ BADGE_RARITIES = [
# Storing the classes of items for quick selection in some menues
class ItemType(models.Model):
paint_index = models.IntegerField(primary_key=True, unique=True) # Skin
wear = models.CharField(max_length=100) # tags > category = exterior > localized_tag_name
classid = models.IntegerField() # Weapon Class
appid = models.IntegerField() # The appid which items of this type belong to
@@ -45,10 +46,10 @@ class ItemInstance(models.Model):
instanceid = models.IntegerField(primary_key=True, unique=True) # 0 for something like cases, which will be excluded here
market_tradable_restriction = models.CharField(max_length=1, null=True) # How long the item will be trade locked | null is not tradelocked
inspect_link = models.URLField(max_length=512)
wear = models.CharField(max_length=100) # tags > category = exterior > localized_tag_name
float = models.FloatField() # Float of the object
paintseed = models.IntegerField() # Pattern ID
killeatervalue = models.IntegerField(null=True) # StatTrack | null is no StatTrack
paintseed = models.IntegerField() # Pattern ID | Migrate to type?
killeatervalue = models.IntegerField(null=True) # StatTrack | null is no StatTrack | Migrate to type?
customname = models.CharField(max_length=128, null=True) # Nametag | null is no Nametag
stickers = models.ManyToManyField(Stickers)
@@ -103,7 +104,7 @@ class Gamer(models.Model):
class Offer(models.Model):
offeror = models.ForeignKey(Gamer, on_delete=models.CASCADE)
items_give = models.ManyToManyField(ItemInstance, related_name='OfferedItems')
items_want = models.ManyToManyField(ItemInstance, related_name='WantedItems')
items_want = models.ManyToManyField(ItemType, related_name='WantedItems')
created_at = models.DateTimeField(auto_now_add=True)

View File

@@ -61,6 +61,7 @@ def updateInventory(steamID, GAME_ID=730):
break
item_class = ItemType.objects.get_or_create(
paint_index=item_infos['iteminfo']['paintindex'],
wear=item_infos['iteminfo']['wear_name'],
classid=item['classid'],
appid=item['appid'],
tradable=(True if item['marketable'] == 1 else False),
@@ -78,7 +79,6 @@ def updateInventory(steamID, GAME_ID=730):
market_tradable_restriction=(item['owner_descriptions'][1]['value']
if 'owner_descriptions' in item else None),
inspect_link=instance_data['actions'][0]['link'],
wear=item_infos['iteminfo']['wear_name'],
float=item_infos['iteminfo']['floatvalue'],
paintseed=item_infos['iteminfo']['paintseed'],
killeatervalue=(item_infos['iteminfo']['killeatervalue'] if 'killeatervalue' in item_infos['iteminfo'] else None),