Skip to content

Commit

Permalink
Fix for #53
Browse files Browse the repository at this point in the history
Also ensuring we ask Canonn upon the first event we know the system that we're in. (otherwise we just don't know how how many plants are in on a planet in that system)

Closes #53
  • Loading branch information
Balvald committed May 19, 2023
1 parent b19dd84 commit 671d13a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
5 changes: 3 additions & 2 deletions eventhandling.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ def bioscan_event(cmdr: str, is_beta, entry, plugin, currententrytowrite) -> Non
# If there is no second Sample scantype event
# we have to save the data here.
logger.debug("Saving data to notsoldbiodata.json")
plugin.notyetsolddata[cmdr].append(currententrytowrite)
plugin.notyetsolddata[cmdr].append(currententrytowrite.copy())
file = plugin.AST_DIR + "\\notsoldbiodata.json"
with open(file, "r+", encoding="utf8") as f:
notsolddata = json.load(f)
if cmdr not in notsolddata.keys():
notsolddata[cmdr] = []
notsolddata[cmdr].append(currententrytowrite)
notsolddata[cmdr].append(currententrytowrite.copy())
f.seek(0)
json.dump(notsolddata, f, indent=4)
f.truncate()
Expand Down Expand Up @@ -170,6 +170,7 @@ def system_body_change_event(cmdr: str, entry, plugin) -> None:

if systemchange:
try:
logger.debug("Asking Canonn about the SAAsignals in current system")
plugin.AST_bios_on_planet = plugin.ask_canonn_nicely(entry["StarSystem"])
except Exception as e:
logger.warning(e)
Expand Down
18 changes: 11 additions & 7 deletions load.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
AST_REPO = "Balvald/ArtemisScannerTracker"

firstdashboard = True
firstsystemevent = True

not_yet_sold_data = {}
sold_exobiology = {}
Expand Down Expand Up @@ -223,7 +224,7 @@ def journal_entry(cmdr: str, is_beta: bool, system: str, station: str, entry, st
:param state: More info about the commander, their ship, and their cargo
"""

global plugin
global plugin, firstsystemevent

logger.debug(entry)
logger.debug(f"Current event is {entry['event']}")
Expand All @@ -243,18 +244,21 @@ def journal_entry(cmdr: str, is_beta: bool, system: str, station: str, entry, st

logger.debug("Handled possible CMDR change")

if (plugin.AST_current_system.get() != system
or plugin.AST_current_system.get() == ""
or plugin.AST_current_system.get() == "None"):
logger.debug("Detected System check")
if ((plugin.AST_current_system.get() != system
or plugin.AST_current_system.get() == ""
or plugin.AST_current_system.get() == "None")
or (plugin.AST_current_system.get() == system
and firstsystemevent)):
logger.debug("Asking Canonn for system (first system related event run of plugin or system was unknown)")
firstsystemevent = False
if system not in ["None", "", None]:
plugin.AST_current_system.set(system)
plugin.AST_bios_on_planet = plugin.ask_canonn_nicely(system)
flag = True

logger.debug("Got past checkl to ask Canonn")
logger.debug("Got past check to ask Canonn")

# TODO: Check if upon death in 4.0 Horizons do we lose Exobiodata.
# TODO: Check if upon death in 4.0 Horizons do we lose Exoiodata.
# Probably?

# Frontline solutions does not have a Resurrect event.
Expand Down

0 comments on commit 671d13a

Please sign in to comment.