def getWeather(self,address): fullLocName,lat,lng = self.getLoaction(address) if fullLocName != None: webWeather = ServerCaller("https://api.forecast.io/forecast/0e75783f8a3fa4de5b49fff8115d93b4/"+str(lat)+","+str(lng)) webWeather.callService() currently = Weather("Currently",webWeather.data["currently"]) return currently.getWeatherInfo(fullLocName) else: return "(wtf) - 404 Location not found!"
def getLoaction(self,address): url = "http://maps.googleapis.com/maps/api/geocode/json?address="+address+"&sensor=false" location = ServerCaller(url) location.callService() if location.data["status"] == "OK": fullLocName = location.data["results"][0]["formatted_address"] lat = location.data["results"][0]["geometry"]["location"]["lat"] lng = location.data["results"][0]["geometry"]["location"]["lng"] return fullLocName,lat,lng else: return None,None,None
parser.add_argument('session_id', help='The current PHPSESSID') parser.add_argument('--server', default='s1.railnation.de', help='The server where the session is active') parser.add_argument('--max_invest_count', default=2, type=int, help='Maximum of invest clicks per factory') parser.add_argument('--max_invest_costs', default=10000, type=int, help='Maximum costs for an individual invest') args = parser.parse_args() # let's go api = ServerCaller(args.server, args.session_id) tracks_graph = track_network(api) # factory properties factory_properties = api.properties('factories') factory_growth_properties = api.properties('factory_growth') factories = api.call('LocationInterface', 'getAllFactories', short_call=1236)['Body'] factories = [ factory for factory in factories if factory['Id'] in tracks_graph.nodes ] print(f'Connected to {len(factories)} factories') # iterate over all connected factories
import argparse from server import ServerCaller if __name__ == "__main__": parser = argparse.ArgumentParser(description='Collect all train spotters') parser.add_argument('session_id', help='The current PHPSESSID') parser.add_argument('--server', default='s1.railnation.de', help='The server where the session is active') args = parser.parse_args() # let's go api = ServerCaller(args.server, args.session_id) # train spotters spotters = api.call('TrainSpotterInterface', 'getWaitingAndCollected', short_call=1236) print( f'Found {len(spotters["Body"]["Waiting"]["TrainSpotter"])} train spotters' ) collected_spotters = list( api.bulk_call('TrainSpotterInterface', 'collect', spotters['Body']['Waiting']['TrainSpotter'])) print(f'Collected {len(collected_spotters)} train spotters')
from tqdm import tqdm from server import ServerCaller from time import sleep if __name__ == "__main__": parser = argparse.ArgumentParser( description='Generate prestige overview for association members') parser.add_argument('session_id', help='The current PHPSESSID') parser.add_argument('--server', default='s204.railnation.de', help='The server where the session is active') args = parser.parse_args() # let's go api = ServerCaller(args.server, args.session_id) # association analysis assoc_info = api.call('CorporationInterface', 'getOtherMemberBuildings', ["00000000-0000-0000-0000-000000000000"]) print(f"Info for {len(assoc_info['Body'])} members") # fetch all prestige details prestiges = {} for user_id, member in tqdm(assoc_info['Body'].items()): prestiges[user_id] = {} prestiges[user_id]['overview'] = api.call( 'BudgetInterface', 'getPrestigeHistoryDetails', [user_id, 9])['Body']['balance'] sleep(1) prestiges[user_id]['cities'] = api.call(
from server import ServerCaller from statistics import mean from collections import defaultdict if __name__ == "__main__": parser = argparse.ArgumentParser( description='Calculate break-even for bonus workers') parser.add_argument('session_id', help='The current PHPSESSID') parser.add_argument('--server', default='s204.railnation.de', help='The server where the session is active') args = parser.parse_args() # let's go api = ServerCaller(args.server, args.session_id) # association analysis assoc_info = api.call('CorporationInterface', 'getOtherMemberBuildings', ["00000000-0000-0000-0000-000000000000"]) # 7: Hotel, 8: Restaurant, 9: Mall print(f"Info for {len(assoc_info['Body'])} members") buildings = { "7": api.properties('building_hotel', version='8984d44e15dc4d3481b18a42aa1969e6'), "8": api.properties('building_restaurant', version='8984d44e15dc4d3481b18a42aa1969e6'), "9":