Skip to content

Commit

Permalink
Additional wormhole information
Browse files Browse the repository at this point in the history
Added wormhole information such as life, mass and last modified, into the "additional info" column. Column widths are now part of the settings file.
  • Loading branch information
Valtyr Farshield committed Apr 23, 2016
1 parent ab2dfee commit 50344c6
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 23 deletions.
22 changes: 15 additions & 7 deletions src/pathfinder/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ def __init__(self, parent=None):
self.crest_client_id = None
self.crest_client_secret = None

# Table configuration
self.tableWidget_path.setColumnCount(5)
self.tableWidget_path.setHorizontalHeaderLabels(
["System name", "Class", "Security", "Instructions", "Additional information"]
)
self.tableWidget_path.horizontalHeader().setStretchLastSection(True)

# Read stored settings
self.read_settings()

Expand Down Expand Up @@ -185,13 +192,6 @@ def additional_gui_setup(self):
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
line_edit_field.setCompleter(completer)

# Table configuration
self.tableWidget_path.setColumnCount(5)
self.tableWidget_path.setHorizontalHeaderLabels(
["System name", "Class", "Security", "Instructions", "Additional information"]
)
self.tableWidget_path.horizontalHeader().setStretchLastSection(True)

# Signals
self.pushButton_eve_login.clicked.connect(self.btn_eve_login_clicked)
self.pushButton_player_location.clicked.connect(self.btn_player_location_clicked)
Expand Down Expand Up @@ -220,6 +220,8 @@ def read_settings(self):
win_state = self.settings.value("win_state")
if win_state:
self.restoreState(win_state)
for col_idx, column_width in enumerate(self.settings.value("table_widths", "110,75,75,180").split(',')):
self.tableWidget_path.setColumnWidth(col_idx, int(column_width))

# CREST info
self.crest_implicit = True if self.settings.value("crest_implicit", "true") == "true" else False
Expand Down Expand Up @@ -261,6 +263,12 @@ def write_settings(self):
# Window state
self.settings.setValue("win_geometry", self.saveGeometry())
self.settings.setValue("win_state", self.saveState())
self.settings.setValue("table_widths", ",".join([
str(self.tableWidget_path.columnWidth(0)),
str(self.tableWidget_path.columnWidth(1)),
str(self.tableWidget_path.columnWidth(2)),
str(self.tableWidget_path.columnWidth(3)),
]))

# Crest info
self.settings.setValue("crest_implicit", self.crest_implicit)
Expand Down
44 changes: 32 additions & 12 deletions src/pathfinder/model/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _get_instructions(weight):
if weight[0] == SolarMap.GATE:
instructions = "Jump gate"
elif weight[0] == SolarMap.WORMHOLE:
[wh_sig, wh_code, _] = weight[1]
[wh_sig, wh_code, _, _, _, _] = weight[1]
instructions = "Jump wormhole {}[{}]".format(wh_sig, wh_code)
else:
instructions = "Instructions unclear, initiate self-destruct"
Expand All @@ -49,22 +49,42 @@ def _get_additional_info(weight, weight_back):
info = ""
if weight and weight_back:
if weight_back[0] == SolarMap.WORMHOLE:
[wh_sig, wh_code, wh_size] = weight_back[1]
# Return signature
info += "Return sig: {}[{}]".format(wh_sig, wh_code)

[wh_sig, wh_code, wh_size, wh_life, wh_mass, time_elapsed] = weight_back[1]
# Wormhole size
info += ", Size: "
if wh_size == 0:
info += "Small"
wh_size_text = "Small"
elif wh_size == 1:
info += "Medium"
wh_size_text = "Medium"
elif wh_size == 2:
info += "Large"
wh_size_text = "Large"
elif wh_size == 3:
info += "X-large"
wh_size_text = "X-large"
else:
wh_size_text = "Unknown"

# Wormhole life
if wh_life == 1:
wh_life_text = "Stable"
else:
info += "Unknown"
wh_life_text = "Critical"

# Wormhole mass
if wh_mass == 2:
wh_mass_text = "Stable"
elif wh_mass == 1:
wh_mass_text = "Destab"
else:
wh_mass_text = "Critical"

# Return signature
info = "Return sig: {}[{}], Size: {}, Life: {}, Mass: {}, Updated: {}h ago".format(
wh_sig,
wh_code,
wh_size_text,
wh_life_text,
wh_mass_text,
time_elapsed
)

return info

Expand Down Expand Up @@ -110,7 +130,7 @@ def route(self, source, destination, avoidance_list, size_restriction):
if prev_gate:
if prev_gate != path[idx - 1]:
short_format += "...-->"
[wh_sig, _, _] = weight[1]
[wh_sig, _, _, _, _, _] = weight[1]
short_format += system_description[0] + "[{}]~~>".format(wh_sig)
prev_gate = None
elif weight[0] == SolarMap.GATE:
Expand Down
6 changes: 3 additions & 3 deletions src/pathfinder/model/solarmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ def add_connection(
self.systems_list[source].add_neighbor(self.systems_list[destination], [SolarMap.GATE, None])
self.systems_list[destination].add_neighbor(self.systems_list[source], [SolarMap.GATE, None])
elif con_type == SolarMap.WORMHOLE:
[sig_source, code_source, sig_dest, code_dest, wh_size] = con_info
[sig_source, code_source, sig_dest, code_dest, wh_size, wh_life, wh_mass, time_elapsed] = con_info
self.systems_list[source].add_neighbor(
self.systems_list[destination],
[SolarMap.WORMHOLE, [sig_source, code_source, wh_size]]
[SolarMap.WORMHOLE, [sig_source, code_source, wh_size, wh_life, wh_mass, time_elapsed]]
)
self.systems_list[destination].add_neighbor(
self.systems_list[source],
[SolarMap.WORMHOLE, [sig_dest, code_dest, wh_size]]
[SolarMap.WORMHOLE, [sig_dest, code_dest, wh_size, wh_life, wh_mass, time_elapsed]]
)
else:
# you shouldn't be here
Expand Down
19 changes: 18 additions & 1 deletion src/pathfinder/model/tripwire.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import requests
import urlparse
import logging
from datetime import datetime
from solarmap import SolarMap


Expand Down Expand Up @@ -76,12 +77,28 @@ def augment_map(self, solar_map):
if sig["type"] != "GATE":
connections += 1

# Retrieve signature meta data
source = convert_to_int(sig["systemID"])
dest = convert_to_int(sig["connectionID"])
sig_source = sig["signatureID"]
sig_dest = sig["sig2ID"]
code_source = sig["type"]
code_dest = sig["sig2Type"]
if sig["life"] == "Stable":
wh_life = 1
else:
wh_life = 0
if sig["mass"] == "Stable":
wh_mass = 2
elif sig["mass"] == "Destab":
wh_mass = 1
else:
wh_mass = 0

# Compute time elapsed from this moment to when the signature was updated
last_modified = datetime.strptime(sig["time"], "%Y-%m-%d %H:%M:%S")
delta = datetime.utcnow() - last_modified
time_elapsed = round(delta.total_seconds() / 3600.0, 1)

if source != 0 and dest != 0:
# Determine wormhole size
Expand All @@ -100,7 +117,7 @@ def augment_map(self, solar_map):
source,
dest,
SolarMap.WORMHOLE,
[sig_source, code_source, sig_dest, code_dest, wh_size],
[sig_source, code_source, sig_dest, code_dest, wh_size, wh_life, wh_mass, time_elapsed],
)

return connections
Expand Down

0 comments on commit 50344c6

Please sign in to comment.