diff --git a/generate-nodes.py b/generate-nodes.py new file mode 100755 index 0000000..d3f02da --- /dev/null +++ b/generate-nodes.py @@ -0,0 +1,53 @@ +#!/usr/bin/python +import yaml +import json +import argparse +from pprint import pprint + +def getStopStation(stop): + if type(stop) is list: + return stop[0] + else: + return stop + +parser = argparse.ArgumentParser(description=''' +Generates a json file containing node link information, +to be used to determine fastest route.''') +parser.add_argument('inputfile', metavar='INPUT', type=str, help='input yaml file') +parser.add_argument('outputfile', metavar='OUTPUT', type=str, help='output json file') +parser.add_argument('--javascript', action='store_true', help='output valid js file hack') +args = parser.parse_args() + +yaml_file = open(args.inputfile, 'r') +yaml_data = yaml.load(yaml_file) +yaml_file.close() + +stations = yaml_data["stations"] +lines = yaml_data["lines"] + +for station in stations: + stations[station]["destinations"] = [] + +for linename,line in lines.iteritems(): + previous = "" + for stopindex, stop in enumerate(line["stops"]): + if stopindex > 0 or line["flow"] == "loop": + previousStation = getStopStation(line["stops"][stopindex-1]) + stations[getStopStation(stop)]["destinations"].append(previousStation) + try: + if line["flow"] == "loop" and stopindex+1 > len(line["stops"])-1: + nextStation = getStopStation(line["stops"][0]) + else: + nextStation = getStopStation(line["stops"][stopindex+1]) + stations[getStopStation(stop)]["destinations"].append(nextStation) + except IndexError: + pass + +pprint(stations) +json_file = open(args.outputfile, 'w') +if args.javascript: + json_file.write("stations =") +json.dump(stations, json_file) +if args.javascript: + json_file.write(";") +json_file.close() \ No newline at end of file diff --git a/pve-6-rails.yaml b/pve-6-rails.yaml index 1e4a062..95bbc99 100644 --- a/pve-6-rails.yaml +++ b/pve-6-rails.yaml @@ -1,6 +1,6 @@ name: PvE Rail Network -xrange: [-2000, 2000] -zrange: [-2000, 2000] +xrange: [-3000, 3000] +zrange: [-3000, 3000] stations: # Official Stations @@ -18,6 +18,10 @@ stations: x: -285 z: -35 notes: "Access via Snapperolle Underground" + + SE Terminal: + x: 8 + z: 129 # Northern Stations Pico: @@ -36,13 +40,29 @@ stations: Pico PV Embassy: x: 12 z: -1420 - + + North Transfer: + x: -62 + z: -848 + # Northeastern Stations - Blanco Junction: + Northeast Junction: x: 1200 - z: -1300 + z: -1400 notes: "No pedestrian access - just switches between lines" - + + saffsd Junction: + x: 1226 + z: -1784 + + Blanco: + x: 1765 + z: -1781 + + Diehimmel: + x: 1600 + z: -1487 + Pleasantville: x: 1200 z: -1000 @@ -50,7 +70,19 @@ stations: Beacon Island: x: 540 z: -720 - + + Gobias: + x: 2500 + z: -1000 + + Esper: + x: 1025 + z: -1418 + + Esper PV Express: + x: 1047 + z: -1342 + # Eastern Stations East Transfer: x: 850 @@ -67,7 +99,11 @@ stations: "Nuttin' Atoll": x: 1120 z: -260 - + + New Athens: + x: 951 + z: 533 + # Southeastern Stations Wellspring: x: 945 @@ -88,7 +124,35 @@ stations: East Ocean: x: 1630 z: 1500 - + + "Monkeh/Whore Junction": + x: 2323 + z: 312 + notes: "No surface access" + + Whore Island: + x: 2518 + z: 51 + + Monkeh Island: + x: 2337 + z: 567 + + "Island/Argoth Junction": + x: 1521 + z: 312 + notes: "No surface access" + + Derp Town: + x: 905 + z: 310 + notes: "Station access via ladder down in sandstone building. Not connected to 850 loop." + + Hall of Pillars: + x: 1559 + z: 2230 + notes: "Schererererer's Uberproject" + # Southern Stations South Transfer: x: -43 @@ -97,6 +161,14 @@ stations: South Portal: x: -40 z: 1700 + + "Makdaam's Retreat": + x: 2 + z: 2401 + + Southquan: + x: 2 + z: 2810 # In the future, jchance may add Birch Island. @@ -116,8 +188,12 @@ stations: # Southwestern Stations Deorne: x: -850 - z: 855 + z: 865 notes: "The line selector is after you leave the station" + + 850 South West Transfer: + x: -850 + z: 850 New Hempshire: x: -1460 @@ -135,7 +211,15 @@ stations: QN Junction: x: -1630 - z 717 + z: 717 + + Cathedral: + x: -299 + z: 194 + + Lothos Desert: + x: -585 + z: 1130 # Western Stations West Transfer: @@ -156,6 +240,10 @@ stations: x: -925 z: -760 notes: "The line selector is after you leave the station" + + 850 North West Transfer: + x: -850 + z: -850 Snowhedge: x: -1630 @@ -169,9 +257,21 @@ stations: x: -1190 z: -1630 + Metro Hub: + x: -1146 + z: -1005 + + Metro West: + x: -1626 + z: -1009 + + Dimma Vale: + x: -1019 + z: -1106 + lines: # 10X - Cardinal Cross, y = 12 - 103: + 101: name: "North Trunk" direction: north type: trunk @@ -179,9 +279,10 @@ lines: level: underground stops: - Spawn Station + - North Transfer - [Pico, south platform] - 104: + 102: name: "East Trunk" direction: east type: trunk @@ -189,10 +290,11 @@ lines: level: underground stops: - Spawn Station + - [-90, -115] - East Transfer - New Argoth - 105: + 103: name: "South Trunk" direction: south type: trunk @@ -202,6 +304,18 @@ lines: - Spawn Station - South Transfer - Nowhere + + 104: + name: "West Trunk" + direction: west + type: trunk + flow: twoway + level: underground + stops: + - Spawn Station + - [-90, -115] + - West Transfer + - Topaz West # Other 1X0 lines 110: @@ -211,13 +325,15 @@ lines: flow: loop level: underground stops: - # - North Transfer # broken now + - North Transfer + - [850,-850] - East Transfer - Wellspring + - [850,850] - South Transfer - Deorne - West Transfer - - Agua Fria + - 850 North West Transfer 120: name: "Y70 Outer Loop" @@ -227,24 +343,34 @@ lines: level: el stops: - [Pico, east platform] - - Blanco Junction + - Esper + - Northeast Junction - Pleasantville - "Nuttin' Atoll" + - [1520, -260] - New Argoth - Kilst Island - Not Bacon - Birch Island - East Ocean + - [1630, 1632] # - Nowhere Y70 - Unknown Station + - [-1100, 1632] + - [-1100, 1540] - New Hempshire + - [-1630, 1540] - Deepholm Junction - QN Junction - Topaz West - Snowhedge + - Metro West + - [-1626, -1640] - Something Else - Andaren - Montpellier + - [-100, -1633] + - [-100, -1500] # 200 lines - Central (Seneca) 207: @@ -256,6 +382,7 @@ lines: level: underground stops: - Seneca + - [-15,-1000] - Pleasantville 210: @@ -268,6 +395,16 @@ lines: stops: - Snapperolle - Seneca + + 220: + name: "Wellspring/Spawn" + direction: out + type: citylink + flow: twoway + level: underground + stops: + - SE Terminal + - Wellspring # 300 lines - North (Pico) 300: @@ -279,7 +416,58 @@ lines: stops: - [Pico, north platform] - North Portal - + + 310: + name: "Beacon Island/Pico" + direction: north + type: citylink + flow: oneway + level: underground + stops: + - Beacon Island + - Pico PV Embassy + + 320: + name: "Metro/Dimma Vale" + direction: east + type: citylink + flow: twoway + level: underground + stops: + - Metro West + - Metro Hub + - Dimma Vale + + 321: + name: "Metro/Agua Fria" + direction: east + type: citylink + flow: twoway + level: underground + stops: + - Metro Hub + - Agua Fria + + 330: + name: "850 NW Aqua Fria Transfer" + direction: out + type: citylink + flow: oneway + level: underground + stops: + - 850 North West Transfer + - Agua Fria + + 350: + name: "850 SW Deorne Transfer" + direction: out + type: citylink + flow: oneway + level: underground + stops: + - 850 South West Transfer + - Deorne + # 400 lines - East (New Argoth) 400: name: "New Argoth/Portal" @@ -292,6 +480,50 @@ lines: - New Argoth - [East Portal, west of portal] + 410: + name: "Monkeh Island" + direction: out + flow: twoway + type: citylink + level: underground + stops: + - "Monkeh/Whore Junction" + - Monkeh Island + + 420: + name: "Whore Island" + direction: west + flow: twoway + type: citylink + level: underground + stops: + - Whore Island + - "Monkeh/Whore Junction" + - "Island/Argoth Junction" + - Derp Town + + 430: + name: "Argoth/Wellspring" + direction: west + flow: twoway + type: citylink + level: underground + stops: + - New Argoth + - New Athens + - Wellspring + + 450: + name: "Hall of Pillars" + direction: south + flow: twoway + type: citylink + level: underground + stops: + - New Argoth + - "Island/Argoth Junction" + - Hall of Pillars + # 500 lines - South (Nowhere) 520: name: "Lothos/Portal" @@ -301,8 +533,21 @@ lines: level: underground stops: - [Lothos, "east [green] bay"] + - Nowhere - South Portal - + + 530: + name: "Southquan Rail" + direction: south + type: citylink + flow: twoway + level: surface + stops: + - South Portal + - "Makdaam's Retreat" + - Southquan + + 540: name: "Deepholm" direction: in @@ -312,6 +557,27 @@ lines: stops: - Deepholm Junction - Deepholm + + 550: + name: "Lothos/Deorne" + direction: west + type: citylink + flow: twoway + level: underground + stops: + - Lothos + - Lothos Desert + - Deorne + + 560: + name: "Lothos/Cathdral" + direction: north + type: citylink + flow: twoway + level: underground + stops: + - Lothos + - Cathedral # 600 lines - West (Topaz) @@ -324,4 +590,56 @@ lines: level: underground stops: - Pleasantville - - Pico PV Embassy \ No newline at end of file + - [-15,-1000] + - Pico PV Embassy + + 720: + name: "PV/Beacon Island" + direction: out + type: citylink + flow: twoway + level: underground + stops: + - Pleasantville + - Beacon Island + + 730: + name: "PV/Gobias" + direction: out + type: citylink + flow: twoway + level: underground + stops: + - Pleasantville + - Gobias + + 740: + name: "PV/Esper" + direction: out + type: citylink + flow: twoway + level: underground + stops: + - Pleasantville + - Esper PV Express + + 750: + name: "Blanco Rail" + direction: out + type: citylink + flow: twoway + level: elevated + stops: + - Northeast Junction + - saffsd Junction + - Blanco + + 760: + name: "Diehimmel Rail" + direction: east + type: citylink + flow: twoway + level: elevated + stops: + - Northeast Junction + - Diehimmel \ No newline at end of file diff --git a/railgen.rb b/railgen.rb index 802bc5b..834dded 100755 --- a/railgen.rb +++ b/railgen.rb @@ -26,6 +26,10 @@ require 'haml' require 'yaml' +def is_a_number?(s) + s.to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/) == nil ? false : true +end + class RailNetwork def self.load (data) network = self.new(data["name"] || "Rail Network") @@ -40,7 +44,11 @@ def self.load (data) line = network.add_line n, ln["name"], ln["direction"].to_sym, ln["flow"].to_sym, ln["level"].to_sym, ln["type"].to_sym, ln["notes"] ln["stops"].each do |stop| if stop.is_a?(Array) - line.add_stop(stop[0], stop[1]) + if is_a_number?(stop[0]) and is_a_number?(stop[1]) + line.add_stop(stop, nil) + else + line.add_stop(stop[0], stop[1]) + end else line.add_stop(stop, nil) end @@ -250,7 +258,11 @@ def color end def add_stop (stop, landing) - stop = @network.get_station stop + if !stop.is_a?(Array) + stop = @network.get_station stop + else + stop = Station.new(@network, '', stop[0], stop[1], nil) + end @stops << [stop, landing] stop.add_line(self, landing) end diff --git a/route.html b/route.html new file mode 100644 index 0000000..618f21a --- /dev/null +++ b/route.html @@ -0,0 +1,77 @@ + + +MCPublic PvE Rail Directions + + + + + + + + + +
+ + \ No newline at end of file