|
| 1 | +import sys |
| 2 | +if sys.version_info.major < 3: |
| 3 | + print("You need to use Python 3.x, e.g. python3 <filename>") |
| 4 | + exit() |
| 5 | + |
| 6 | +import edce.util |
| 7 | +import json |
| 8 | +from collections import OrderedDict |
| 9 | + |
| 10 | +def alignStr(title, word): |
| 11 | + return "{:<40s}{:<40s}".format(title, word) |
| 12 | + |
| 13 | +def alignNum(title, number): |
| 14 | + return "{:<40s}{:<40d}".format(title, number) |
| 15 | + |
| 16 | +player_json = '' |
| 17 | +try: |
| 18 | + with open("last.json", "r") as f: |
| 19 | + player_json = f.readline() |
| 20 | + f.close() |
| 21 | +except: |
| 22 | + "Please run edce_client.py at least once, so that it may create a last.json file." |
| 23 | + exit() |
| 24 | + |
| 25 | +data = edce.util.edict(player_json) |
| 26 | + |
| 27 | +station = "" |
| 28 | +if data.commander.docked: |
| 29 | + station = "/" + data.lastStarport.name |
| 30 | + |
| 31 | +print(alignStr("CMDR:",data.commander.name)) |
| 32 | +print(alignStr("System:",data.lastSystem.name + station)) |
| 33 | +print(alignNum("Credits:",data.commander.credits)) |
| 34 | + |
| 35 | +if "ship" in data: |
| 36 | + print(alignStr("Ship:",data.ship.name)) |
| 37 | + |
| 38 | +if "ships" in data: |
| 39 | + print("\n========== All ships: ==========") |
| 40 | + |
| 41 | + all_ships = {} |
| 42 | + for ship in data.ships: |
| 43 | + station = data.ships[ship].starsystem.name + "/" + data.ships[ship].station.name |
| 44 | + if not station in all_ships: |
| 45 | + all_ships[station]=[] |
| 46 | + all_ships[station].append(data.ships[ship].name) |
| 47 | + |
| 48 | + for s in OrderedDict(sorted(all_ships.items())): |
| 49 | + print(alignStr(s,", ".join(all_ships[s]))) |
| 50 | + |
| 51 | +if "stats" in data and "explore" in data.stats and "lastVisitedStarSystems" in data.stats.explore: |
| 52 | + print("\n========== Last Visited: ==========") |
| 53 | + for s in data.stats.explore.lastVisitedStarSystems: |
| 54 | + print(s) |
0 commit comments