-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
119 lines (105 loc) · 4.74 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
from django.db import models
from tools import slots
socket_choices=[('red','Red'),
('yellow','Yellow'),
('blue','Blue'),
('meta','Meta'),
('chromatic','Chromatic'),
('none','(No socket)'),
]
slot_choices = [(15,"Weapon"),
(1,"Head"),
(2,"Neck"),
(3,"Shoulder"),
(16,"Cloak"),
(5,"Chest"),
(6,"Waist"),
(7,"Legs"),
(8,"Feet"),
(9,"Wrist"),
(10,"Hands"),
(11,"Finger"),
(12,"Trinket"),
(20,"Chest (gown)")]
quality_choices = [(3,"Superior"),
(4,"Epic"),
(5,"Legendary")]
# Create your models here.
class GearItem(models.Model):
id = models.IntegerField(primary_key=True)
name = models.CharField(max_length=80)
nameDescription = models.CharField(max_length=80,blank=True)
zone = models.CharField(max_length=80)
source = models.CharField(max_length=80)
agility = models.IntegerField(default=0)
crit = models.IntegerField(default=0)
haste = models.IntegerField(default=0)
mastery = models.IntegerField(default=0)
multistrike = models.IntegerField(default=0)
versatility = models.IntegerField(default=0)
weapon_min = models.FloatField(default=0)
weapon_max = models.FloatField(default=0)
weapon_speed = models.FloatField(default=0)
ilvl = models.IntegerField(default=0)
icon = models.CharField(max_length=80,default="inv_misc_questionmark")
slot = models.IntegerField(default=0,choices=slot_choices)
quality = models.IntegerField(default=0,choices=quality_choices)
socket1 = models.CharField(max_length=20,blank=True,
choices=socket_choices,)
socket2 = models.CharField(max_length=20,blank=True,
choices=socket_choices,)
socket3 = models.CharField(max_length=20,blank=True,
choices=socket_choices,)
socket_bonus = models.CharField(max_length=80,blank=True)
def has_savage(self):
return self.id > 999999 and str(self.id).endswith('999')
def clean_id(self):
return (self.id-999)/1000
def slotName(self):
return slots[self.slot]
def maxIlvl(self):
if hasattr(self,'gearcontext_set') and self.gearcontext_set.all():
return self.gearcontext_set.all().aggregate(models.Max('ilvl'))['ilvl__max']
return self.ilvl
def __unicode__(self):
return (self.nameDescription and 'Season' not in self.nameDescription) and self.name + ' (' + (self.nameDescription) + ')' or self.name
class Meta:
ordering = ['-ilvl','name']
class Gem(models.Model):
id = models.IntegerField(primary_key=True)
name = models.CharField(max_length=80)
agility = models.IntegerField(default=0,blank=True)
crit = models.IntegerField(default=0,blank=True)
haste = models.IntegerField(default=0,blank=True)
mastery = models.IntegerField(default=0,blank=True)
multistrike = models.IntegerField(default=0,blank=True)
versatility = models.IntegerField(default=0,blank=True)
def __unicode__(self):
return self.name
class GearContext(models.Model):
gearitem = models.ForeignKey('GearItem')
context = models.CharField(max_length=80)
agility = models.IntegerField(default=0,blank=True)
crit = models.IntegerField(default=0,blank=True)
haste = models.IntegerField(default=0,blank=True)
mastery = models.IntegerField(default=0,blank=True)
multistrike = models.IntegerField(default=0,blank=True)
versatility = models.IntegerField(default=0,blank=True)
weapon_min = models.FloatField(default=0)
weapon_max = models.FloatField(default=0)
weapon_speed = models.FloatField(default=0)
warforged_agility = models.IntegerField(default=0,blank=True)
warforged_crit = models.IntegerField(default=0,blank=True)
warforged_haste = models.IntegerField(default=0,blank=True)
warforged_mastery = models.IntegerField(default=0,blank=True)
warforged_multistrike = models.IntegerField(default=0,blank=True)
warforged_versatility = models.IntegerField(default=0,blank=True)
warforged_weapon_min = models.FloatField(default=0)
warforged_weapon_max = models.FloatField(default=0)
warforged_weapon_speed = models.FloatField(default=0)
ilvl = models.IntegerField(default=0)
warforged_ilvl = models.IntegerField(default=0)
def contextPretty(self):
return u' '.join([cp == 'pvp' and cp.upper() or len(cp)>1 and cp[0].upper()+cp[1:] or cp for cp in self.context.split('-')])
def __unicode__(self):
return '%s - %s' % (self.gearitem.name, self.context)