Skip to content

Commit

Permalink
[2262] Move SLEF to Monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
Rixxan committed Jun 23, 2024
1 parent 0cc35db commit 3b62592
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 311 deletions.
267 changes: 0 additions & 267 deletions inara.json

This file was deleted.

34 changes: 32 additions & 2 deletions monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
from typing import TYPE_CHECKING, Any, BinaryIO, MutableMapping
import semantic_version
import util_ships
from config import config
from edmc_data import edmc_suit_shortnames, edmc_suit_symbol_localised
from config import config, appname, appversion
from edmc_data import edmc_suit_shortnames, edmc_suit_symbol_localised, ship_name_map
from EDMCLogging import get_main_logger
from edshipyard import ships

if TYPE_CHECKING:
import tkinter
Expand Down Expand Up @@ -109,6 +110,7 @@ def __init__(self) -> None:
self.group: str | None = None
self.cmdr: str | None = None
self.started: int | None = None # Timestamp of the LoadGame event
self.slef: str | None = None

self._navroute_retries_remaining = 0
self._last_navroute_journal_timestamp: float | None = None
Expand Down Expand Up @@ -701,6 +703,34 @@ def parse_entry(self, line: bytes) -> MutableMapping[str, Any]: # noqa: C901, C
module.pop('AmmoInHopper')

self.state['Modules'][module['Slot']] = module
# SLEF
initial_dict = {
"header": {"appName": appname, "appVersion": str(appversion())}
}
data_dict = {}
for module in entry['Modules']:
if module.get('Slot') == 'FuelTank':
cap = module['Item'].split('size')
cap = cap[1].split('_')
cap = 2 ** int(cap[0])
ship = ship_name_map[entry["Ship"]]
fuel = {'Main': cap, 'Reserve': ships[ship]['reserveFuelCapacity']}
data_dict.update({"FuelCapacity": fuel})
data_dict.update({
'Ship': entry["Ship"],
'ShipName': entry['ShipName'],
'ShipIdent': entry['ShipIdent'],
'HullValue': entry['HullValue'],
'ModulesValue': entry['ModulesValue'],
'Rebuy': entry['Rebuy'],
'MaxJumpRange': entry['MaxJumpRange'],
'UnladenMass': entry['UnladenMass'],
'CargoCapacity': entry['CargoCapacity'],
'Modules': entry['Modules'],
})
initial_dict.update({'data': data_dict})
output = json.dumps(initial_dict, indent=4)
self.slef = str(output)

elif event_type == 'modulebuy':
self.state['Modules'][entry['Slot']] = {
Expand Down
35 changes: 0 additions & 35 deletions plugins/inara.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import edmc_data
import killswitch
import myNotebook as nb # noqa: N813
from edshipyard import ships
import plug
import timeout_session
from companion import CAPIData
Expand Down Expand Up @@ -872,7 +871,6 @@ def journal_entry( # noqa: C901, CCR001
cur_ship['shipRebuyCost'] = state['Rebuy']

new_add_event('setCommanderShip', entry['timestamp'], cur_ship)
make_slef(entry)

# Stored modules
if event_name == 'StoredModules':
Expand Down Expand Up @@ -1479,39 +1477,6 @@ def make_loadout(state: dict[str, Any]) -> dict[str, Any]: # noqa: CCR001
}


def make_slef(entry) -> None:
initial_dict = {
"header": {"appName": appname, "appVersion": str(appversion())}
}
data_dict = {}
for module in entry['Modules']:
if module.get('Slot') == 'FuelTank':
cap = module['Item'].split('size')
cap = cap[1].split('_')
cap = 2 ** int(cap[0])
ship = edmc_data.ship_name_map[entry["Ship"]]
fuel = {'Main': cap, 'Reserve': ships[ship]['reserveFuelCapacity']}
data_dict.update({"FuelCapacity": fuel})
data_dict.update({
'Ship': entry["Ship"],
'ShipName': entry['ShipName'],
'ShipIdent': entry['ShipIdent'],
'HullValue': entry['HullValue'],
'ModulesValue': entry['ModulesValue'],
'Rebuy': entry['Rebuy'],
'MaxJumpRange': entry['MaxJumpRange'],
'UnladenMass': entry['UnladenMass'],
'CargoCapacity': entry['CargoCapacity'],
'Modules': entry['Modules'],
})
initial_dict.update({'data': data_dict})
output = json.dumps(initial_dict, indent=4)
this.SLEF = str(output)
print('set output')
print(type(this.SLEF))
return None


def new_add_event(
name: str,
timestamp: str,
Expand Down
Loading

0 comments on commit 3b62592

Please sign in to comment.