Raw
#!/usr/bin/env python3
# proof of concept for an idea i've had for a while
from peewee import *
db = SqliteDatabase("wownav.db")
class BaseModel(Model):
class Meta:
database = db
class Faction(BaseModel):
name = CharField()
class City(BaseModel):
name = CharField()
faction = ForeignKeyField(Faction, backref="cities")
class Location(BaseModel):
name = CharField()
city = ForeignKeyField(City, backref="locations")
class Mode(BaseModel):
name = CharField()
class Path(BaseModel):
start_city = ForeignKeyField(City, backref="paths_start")
dest_city = ForeignKeyField(City, backref="paths_dest")
start_loc = ForeignKeyField(Location, backref="paths_start")
dest_loc = ForeignKeyField(Location, backref="paths_dest")
seconds = IntegerField()
mode = ForeignKeyField(Mode, backref="paths")
danger = BooleanField()
faction = ForeignKeyField(Faction, backref="paths")
if __name__ == "__main__":
db.connect()
db.create_tables([Faction,City,Location,Mode,Path])
Neutral = Faction(name="Neutral")
Alliance = Faction(name="Alliance")
Horde = Faction(name="Horde")
Boralus = City(name="Boralus", faction=Alliance)
DazarAlor = City(name="Dazar'alor", faction=Horde)
TradewindsFlightMaster = Location(name="Tradewinds Market Flight Master", city=Boralus)
BFA_Alliance_PVP_Vendor = Location(name="BFA Alliance PVP Vendor", city=Boralus)
GreatSealFlightMaster = Location(name="Great Seal Flight Master", city=DazarAlor)
MugumbalaFlightMaster = Location(name="Mugumbala Flight Master", city=DazarAlor)
BFA_Horde_PVP_Vendor = Location(name="BFA Horde PVP Vendor", city=DazarAlor)
GroundMount = Mode(name="Ground mount")
GoblinGlider = Mode(name="Goblin Glider")
FlightMaster = Mode(name="Flight Master")
tw_to_pvp = Path(start_city=Boralus, dest_city=Boralus,
start_loc=TradewindsFlightMaster, dest_loc=BFA_Alliance_PVP_Vendor,
seconds=17, mode=GroundMount, danger=False, faction=Alliance)
gs_to_pvp = Path(start_city=DazarAlor, dest_city=DazarAlor,
start_loc=GreatSealFlightMaster, dest_loc=BFA_Horde_PVP_Vendor,
seconds=62, mode=GoblinGlider, danger=True, faction=Horde)
gs_to_mug = Path(start_city=DazarAlor, dest_city=DazarAlor,
start_loc=GreatSealFlightMaster, dest_loc=MugumbalaFlightMaster,
seconds=37, mode=FlightMaster, danger=False, faction=Horde)
mug_to_pvp = Path(start_city=DazarAlor, dest_city=DazarAlor,
start_loc=MugumbalaFlightMaster, dest_loc=BFA_Horde_PVP_Vendor,
seconds=7, mode=GroundMount, danger=False, faction=Horde)
| 1 | #!/usr/bin/env python3 |
| 2 | # proof of concept for an idea i've had for a while |
| 3 | from peewee import * |
| 4 | |
| 5 | db = SqliteDatabase("wownav.db") |
| 6 | |
| 7 | class BaseModel(Model): |
| 8 | class Meta: |
| 9 | database = db |
| 10 | class Faction(BaseModel): |
| 11 | name = CharField() |
| 12 | class City(BaseModel): |
| 13 | name = CharField() |
| 14 | faction = ForeignKeyField(Faction, backref="cities") |
| 15 | class Location(BaseModel): |
| 16 | name = CharField() |
| 17 | city = ForeignKeyField(City, backref="locations") |
| 18 | class Mode(BaseModel): |
| 19 | name = CharField() |
| 20 | class Path(BaseModel): |
| 21 | start_city = ForeignKeyField(City, backref="paths_start") |
| 22 | dest_city = ForeignKeyField(City, backref="paths_dest") |
| 23 | start_loc = ForeignKeyField(Location, backref="paths_start") |
| 24 | dest_loc = ForeignKeyField(Location, backref="paths_dest") |
| 25 | seconds = IntegerField() |
| 26 | mode = ForeignKeyField(Mode, backref="paths") |
| 27 | danger = BooleanField() |
| 28 | faction = ForeignKeyField(Faction, backref="paths") |
| 29 | |
| 30 | if __name__ == "__main__": |
| 31 | db.connect() |
| 32 | db.create_tables([Faction,City,Location,Mode,Path]) |
| 33 | |
| 34 | Neutral = Faction(name="Neutral") |
| 35 | Alliance = Faction(name="Alliance") |
| 36 | Horde = Faction(name="Horde") |
| 37 | |
| 38 | Boralus = City(name="Boralus", faction=Alliance) |
| 39 | DazarAlor = City(name="Dazar'alor", faction=Horde) |
| 40 | |
| 41 | TradewindsFlightMaster = Location(name="Tradewinds Market Flight Master", city=Boralus) |
| 42 | BFA_Alliance_PVP_Vendor = Location(name="BFA Alliance PVP Vendor", city=Boralus) |
| 43 | |
| 44 | GreatSealFlightMaster = Location(name="Great Seal Flight Master", city=DazarAlor) |
| 45 | MugumbalaFlightMaster = Location(name="Mugumbala Flight Master", city=DazarAlor) |
| 46 | BFA_Horde_PVP_Vendor = Location(name="BFA Horde PVP Vendor", city=DazarAlor) |
| 47 | |
| 48 | GroundMount = Mode(name="Ground mount") |
| 49 | GoblinGlider = Mode(name="Goblin Glider") |
| 50 | FlightMaster = Mode(name="Flight Master") |
| 51 | |
| 52 | tw_to_pvp = Path(start_city=Boralus, dest_city=Boralus, |
| 53 | start_loc=TradewindsFlightMaster, dest_loc=BFA_Alliance_PVP_Vendor, |
| 54 | seconds=17, mode=GroundMount, danger=False, faction=Alliance) |
| 55 | gs_to_pvp = Path(start_city=DazarAlor, dest_city=DazarAlor, |
| 56 | start_loc=GreatSealFlightMaster, dest_loc=BFA_Horde_PVP_Vendor, |
| 57 | seconds=62, mode=GoblinGlider, danger=True, faction=Horde) |
| 58 | gs_to_mug = Path(start_city=DazarAlor, dest_city=DazarAlor, |
| 59 | start_loc=GreatSealFlightMaster, dest_loc=MugumbalaFlightMaster, |
| 60 | seconds=37, mode=FlightMaster, danger=False, faction=Horde) |
| 61 | mug_to_pvp = Path(start_city=DazarAlor, dest_city=DazarAlor, |
| 62 | start_loc=MugumbalaFlightMaster, dest_loc=BFA_Horde_PVP_Vendor, |
| 63 | seconds=7, mode=GroundMount, danger=False, faction=Horde) |