Last active 1549704372

Steven Smith revised this gist 1549740371. Go to revision

1 file changed, 19 insertions, 51 deletions

wownav.py

@@ -5,29 +5,18 @@ from peewee import *
5 5 db = SqliteDatabase("wownav.db")
6 6
7 7 class BaseModel(Model):
8 - def __init__(self, *args, **kwargs):
9 - super(*args, **kwargs)
10 - self.save()
11 8 class Meta:
12 9 database = db
13 -
14 10 class Faction(BaseModel):
15 11 name = CharField()
16 - hostile_to = ForeignKeyField(Faction)
17 -
18 12 class City(BaseModel):
19 13 name = CharField()
20 14 faction = ForeignKeyField(Faction, backref="cities")
21 -
22 15 class Location(BaseModel):
23 16 name = CharField()
24 17 city = ForeignKeyField(City, backref="locations")
25 - lat = DoubleField()
26 - lon = DoubleField()
27 -
28 18 class Mode(BaseModel):
29 19 name = CharField()
30 -
31 20 class Path(BaseModel):
32 21 start_city = ForeignKeyField(City, backref="paths_start")
33 22 dest_city = ForeignKeyField(City, backref="paths_dest")
@@ -35,7 +24,7 @@ class Path(BaseModel):
35 24 dest_loc = ForeignKeyField(Location, backref="paths_dest")
36 25 seconds = IntegerField()
37 26 mode = ForeignKeyField(Mode, backref="paths")
38 - danger = BooleanField() # to <faction> players from npcs
27 + danger = BooleanField()
39 28 faction = ForeignKeyField(Faction, backref="paths")
40 29
41 30 if __name__ == "__main__":
@@ -44,52 +33,31 @@ if __name__ == "__main__":
44 33
45 34 Neutral = Faction(name="Neutral")
46 35 Alliance = Faction(name="Alliance")
47 - Horde = Faction(name="Horde", hostile_to=Alliance)
48 - Alliance.hostile_to = Horde
36 + Horde = Faction(name="Horde")
49 37
50 38 Boralus = City(name="Boralus", faction=Alliance)
51 39 DazarAlor = City(name="Dazar'alor", faction=Horde)
52 40
53 - TradewindsFlightMaster = Location(name="Tradewinds Market Flight Master", city=Boralus, lat=67, lon=14.84)
54 - BFA_Alliance_PVP_Vendor = Location(name="BFA Alliance PVP Vendor", city=Boralus, lat=55.81, lon=25.16)
41 + TradewindsFlightMaster = Location(name="Tradewinds Market Flight Master", city=Boralus)
42 + BFA_Alliance_PVP_Vendor = Location(name="BFA Alliance PVP Vendor", city=Boralus)
55 43
56 - GreatSealFlightMaster = Location(name="Great Seal Flight Master", city=DazarAlor, lat=51.51, lon=41.08)
57 - MugumbalaFlightMaster = Location(name="Mugumbala Flight Master", city=DazarAlor, lat=35.87, lon=84.52)
58 - BFA_Horde_PVP_Vendor = Location(name="BFA Horde PVP Vendor", city=DazarAlor, lat=32.28, lon=89.46)
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)
59 47
60 48 GroundMount = Mode(name="Ground mount")
61 49 GoblinGlider = Mode(name="Goblin Glider")
62 50 FlightMaster = Mode(name="Flight Master")
63 51
64 - tw_to_pvp = Path(start_city=Boralus,
65 - dest_city=Boralus,
66 - start_loc=TradewindsFlightMaster,
67 - dest_loc=BFA_Alliance_PVP_Vendor,
68 - seconds=17,
69 - mode=GroundMount,
70 - danger=False,
71 - faction=Alliance)
72 - gs_to_pvp = Path(start_city=DazarAlor,
73 - dest_city=DazarAlor,
74 - start_loc=GreatSealFlightMaster,
75 - dest_loc=BFA_Horde_PVP_Vendor,
76 - seconds=62,
77 - mode=GoblinGlider,
78 - danger=True,
79 - faction=Horde)
80 - gs_to_mug = Path(start_city=DazarAlor,
81 - dest_city=DazarAlor,
82 - start_loc=GreatSealFlightMaster,
83 - dest_loc=MugumbalaFlightMaster,
84 - seconds=37,
85 - mode=FlightMaster,
86 - danger=False,
87 - faction=Horde)
88 - mug_to_pvp = Path(start_city=DazarAlor,
89 - dest_city=DazarAlor,
90 - start_loc=MugumbalaFlightMaster,
91 - dest_loc=BFA_Horde_PVP_Vendor,
92 - seconds=7,
93 - mode=GroundMount,
94 - danger=False,
95 - faction=Horde)
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)

Steven Smith revised this gist 1549737212. Go to revision

1 file changed, 95 insertions

wownav.py(file created)

@@ -0,0 +1,95 @@
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 + def __init__(self, *args, **kwargs):
9 + super(*args, **kwargs)
10 + self.save()
11 + class Meta:
12 + database = db
13 +
14 + class Faction(BaseModel):
15 + name = CharField()
16 + hostile_to = ForeignKeyField(Faction)
17 +
18 + class City(BaseModel):
19 + name = CharField()
20 + faction = ForeignKeyField(Faction, backref="cities")
21 +
22 + class Location(BaseModel):
23 + name = CharField()
24 + city = ForeignKeyField(City, backref="locations")
25 + lat = DoubleField()
26 + lon = DoubleField()
27 +
28 + class Mode(BaseModel):
29 + name = CharField()
30 +
31 + class Path(BaseModel):
32 + start_city = ForeignKeyField(City, backref="paths_start")
33 + dest_city = ForeignKeyField(City, backref="paths_dest")
34 + start_loc = ForeignKeyField(Location, backref="paths_start")
35 + dest_loc = ForeignKeyField(Location, backref="paths_dest")
36 + seconds = IntegerField()
37 + mode = ForeignKeyField(Mode, backref="paths")
38 + danger = BooleanField() # to <faction> players from npcs
39 + faction = ForeignKeyField(Faction, backref="paths")
40 +
41 + if __name__ == "__main__":
42 + db.connect()
43 + db.create_tables([Faction,City,Location,Mode,Path])
44 +
45 + Neutral = Faction(name="Neutral")
46 + Alliance = Faction(name="Alliance")
47 + Horde = Faction(name="Horde", hostile_to=Alliance)
48 + Alliance.hostile_to = Horde
49 +
50 + Boralus = City(name="Boralus", faction=Alliance)
51 + DazarAlor = City(name="Dazar'alor", faction=Horde)
52 +
53 + TradewindsFlightMaster = Location(name="Tradewinds Market Flight Master", city=Boralus, lat=67, lon=14.84)
54 + BFA_Alliance_PVP_Vendor = Location(name="BFA Alliance PVP Vendor", city=Boralus, lat=55.81, lon=25.16)
55 +
56 + GreatSealFlightMaster = Location(name="Great Seal Flight Master", city=DazarAlor, lat=51.51, lon=41.08)
57 + MugumbalaFlightMaster = Location(name="Mugumbala Flight Master", city=DazarAlor, lat=35.87, lon=84.52)
58 + BFA_Horde_PVP_Vendor = Location(name="BFA Horde PVP Vendor", city=DazarAlor, lat=32.28, lon=89.46)
59 +
60 + GroundMount = Mode(name="Ground mount")
61 + GoblinGlider = Mode(name="Goblin Glider")
62 + FlightMaster = Mode(name="Flight Master")
63 +
64 + tw_to_pvp = Path(start_city=Boralus,
65 + dest_city=Boralus,
66 + start_loc=TradewindsFlightMaster,
67 + dest_loc=BFA_Alliance_PVP_Vendor,
68 + seconds=17,
69 + mode=GroundMount,
70 + danger=False,
71 + faction=Alliance)
72 + gs_to_pvp = Path(start_city=DazarAlor,
73 + dest_city=DazarAlor,
74 + start_loc=GreatSealFlightMaster,
75 + dest_loc=BFA_Horde_PVP_Vendor,
76 + seconds=62,
77 + mode=GoblinGlider,
78 + danger=True,
79 + faction=Horde)
80 + gs_to_mug = Path(start_city=DazarAlor,
81 + dest_city=DazarAlor,
82 + start_loc=GreatSealFlightMaster,
83 + dest_loc=MugumbalaFlightMaster,
84 + seconds=37,
85 + mode=FlightMaster,
86 + danger=False,
87 + faction=Horde)
88 + mug_to_pvp = Path(start_city=DazarAlor,
89 + dest_city=DazarAlor,
90 + start_loc=MugumbalaFlightMaster,
91 + dest_loc=BFA_Horde_PVP_Vendor,
92 + seconds=7,
93 + mode=GroundMount,
94 + danger=False,
95 + faction=Horde)
Newer Older