-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.py
executable file
·66 lines (49 loc) · 1.87 KB
/
model.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
from sqlalchemy.orm import relationship
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class Location(Base):
__tablename__ = 'location'
id = Column(Integer, primary_key=True, index=True)
name = Column(String)
description = Column(String)
area = Column(String, index=True)
def __init__(self, name, description, area):
self.name = name
self.description = description
self.area = area
class Rom(Base):
__tablename__ = 'rom'
id = Column(Integer, primary_key=True, index=True)
seed = Column(String)
def __init__(self, seed):
self.seed = seed
class Flag(Base):
__tablename__ = 'flag'
id = Column(Integer, primary_key=True, index=True)
name = Column(String, index=True)
value = Column(String, index=True)
romId = Column(Integer, ForeignKey('rom.id'), index=True)
rom = relationship("Rom", back_populates="flags")
def __init__(self, name, value, rom):
self.name = name
self.value = value
self.rom = rom
class Item(Base):
__tablename__ = 'item'
id = Column(Integer, primary_key=True, index=True)
name = Column(String, index=True)
sphere = Column(Integer, index=True)
player = Column(Integer)
locationId = Column(Integer, ForeignKey('location.id'), index=True)
location = relationship("Location")
romId = Column(Integer, ForeignKey('rom.id'), index=True)
rom = relationship("Rom", back_populates='items')
def __init__(self, name, sphere, player, location, rom):
self.name = name
self.sphere = sphere
self.player = player
self.location = location
self.rom = rom
Rom.flags = relationship("Flag", order_by=Flag.id, back_populates='rom')
Rom.items = relationship("Item", order_by=Item.id, back_populates='rom')