about summary refs log tree commit diff
path: root/dropcalc/mxl_types/base.py
blob: cd7e8be8c7385c093cfa6854831934d42f820d44 (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
33
34
from sqlalchemy import ForeignKey, String
from sqlalchemy.orm import Mapped, mapped_column

from .dao import BaseDAO


class BaseItem(BaseDAO):
	__tablename__ = "base"

	code: Mapped[str] = mapped_column(String(4), primary_key=True)
	name: Mapped[str]                                    # internal name only, game actually looks up `code` in strings
	type = mapped_column(ForeignKey("item_type.Code"))   # can have two item_type... and all their parents
	type2 = mapped_column(ForeignKey("item_type.Code"))  # should really figure out a better way to store them
	rarity: Mapped[int]
	level: Mapped[int]                                   # variously referred to as ilvl or qlvl
	spawnable: Mapped[int]                               # items with spawnable=0 *can* be dropped directly from TCs, but shouldn't randomly drop
	category: Mapped[str]

	__mapper_args__ = {'polymorphic_on': 'category'}


class Weapon(BaseItem):
	filename = "Weapons.txt"
	__mapper_args__ = {'polymorphic_identity': 'weap'}


class Armor(BaseItem):
	filename = "Armor.txt"
	__mapper_args__ = {'polymorphic_identity': 'armo'}


class Misc(BaseItem):
	filename = "Misc.txt"
	__mapper_args__ = {'polymorphic_identity': 'misc'}