blob: 8dd9b372f5a41bb9e45a3a2c2a58b7a6df6f9e70 (
plain) (
blame)
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
|
from typing import Optional
from sqlalchemy import ForeignKey, String
from sqlalchemy.orm import Mapped, mapped_column
from .dao import BaseDAO
class ItemType(BaseDAO):
filename = "ItemTypes.txt"
__tablename__ = "item_type"
Id: Mapped[int] = mapped_column(primary_key=True)
Code: Mapped[str] = mapped_column(String(4)) # referred to by other tables
ItemType: Mapped[Optional[str]] # internal human readable name
Equiv1 = mapped_column(ForeignKey("item_type.Code"))
Equiv2 = mapped_column(ForeignKey("item_type.Code"))
# what does Rarity do here? fileguide description is unclear
def is_valid(self):
return is_int(self.Id) and self.Code not in (None, '')
def is_int(obj):
try:
int(obj)
except ValueError:
return False
else:
return True
|