Skip to content

Commit

Permalink
fixing unintentional behaviour of #37 fix
Browse files Browse the repository at this point in the history
What was missing:

In "Log" scantype event did not clear the scan 2 pos distance string.
since after "Log" we only have distance 1.

didn't use the proper last_scan_plant string (have to split it because of #29 ) didn't do that before was resetting distance 1 without showing everytime before I changed this. Also forgot to clear the string variable.

Though I needed to adjust the case for when to update the distances.
Might be doing nothing since on "1/3" plugin.AST_scan_2_pos_vector[0] will always be None.
atleast now it properly checks for plugin.AST_scan_2_pos_vector.

extended line in the preferences menu.
no string or other ui element in there should be longer than line.

readme updated so that the "new" features are not really new since they've been in two prior releases. with varying ways of them working.

demoted all the logger.info calls in journalcrawler.py to logger.debug.
  • Loading branch information
Balvald committed Jan 8, 2023
1 parent 558f92e commit 1195d4d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 45 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ArtemisScannerTracker v0.2.4
# ArtemisScannerTracker v0.2.5
An [EDMC](https://github.com/EDCD/EDMarketConnector) plugin that keeps track of the exobiology scanner of a CMDRs artemis suit in ED:Odyssey


Expand All @@ -24,17 +24,16 @@ You will need to re-start EDMC if EDMC was open while you installed the plugin.
It tracks which species (Tussock, Fungoida, ...), and on which body the last exobiology scan occurred (Futes A 2, Moriosong A 1 a, ...) and also the state of the progress of the last exobiological scan. (1/3 found, 2/3 found...)

- It keeps track of unsold profits. Vista genomics prices in this plugin are at the state of U14.01
- *NEW*: the credit amounts shown can be shortened (e.g. 1,000 KCr. ...) with another setting
- the credit amounts shown can be shortened (e.g. 1,000 KCr. ...) with another setting

- It also keeps track of your sold and scanned but unsold exobiology once it is installed and running, and show it when you're in the corresponding system.

- Handy buttons in the preferences that'll let the plugin scan through your journal files to retroactively track exobiology scans you've done in the past.
- *NEW*: It now also tracks the value of old scans that are still unsold.

- Multi Commander Support. The plugin can handle you playing with many different CMDRs on the same machine with the same EDMC installation.

- Shows the Clonal Colony Range of the last scanned exobiology scan, and your current distance to up to two previous scan locations with corresponding bearing.
- *NEW*: now in _c o l o u r_
- will show in _c o l o u r_ if you've driven far enough for the next exobiolgy scan

- A button that copies the value of your currently unsold scans to your clipboard

Expand Down
68 changes: 34 additions & 34 deletions journalcrawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def build_biodata_json(logger: any, journaldir: str) -> int: # noqa #CCR001
Also return the value of still unsold scans.
"""
logger.info = print
# logger.debug = print

logger.info("start logging")
logger.debug("start logging")

directory, sourcename = os.path.split(os.path.realpath(__file__))

Expand All @@ -45,7 +45,7 @@ def build_biodata_json(logger: any, journaldir: str) -> int: # noqa #CCR001

currententrytowrite = {}

logger.info(directory)
logger.debug(directory)

sold_exobiology = {}
possibly_sold_data = {}
Expand All @@ -57,15 +57,15 @@ def build_biodata_json(logger: any, journaldir: str) -> int: # noqa #CCR001

with open(directory + "\\soldbiodata.json", "r", encoding="utf8") as f:
sold_exobiology = json.load(f)
# logger.info(sold_exobiology)
# logger.info(len(sold_exobiology))
# logger.debug(sold_exobiology)
# logger.debug(len(sold_exobiology))
pass

edlogs = [f for f in os.listdir(journaldir) if f.endswith(".log")]

for filename in edlogs:
f = os.path.join(journaldir, filename)
logger.info("Current file: " + f)
logger.debug("Current file: " + f)
# checking if it is a file
if os.path.isfile(f):
file = open(f, "r", encoding="utf8")
Expand All @@ -74,7 +74,7 @@ def build_biodata_json(logger: any, journaldir: str) -> int: # noqa #CCR001
entry = json.loads(line)

if entry["event"] in ["LoadGame", "Commander"]:
# logger.info("CMDR change event!")
# logger.debug("CMDR change event!")
if entry["event"] == "Commander":
cmdr = entry["Name"]
else:
Expand All @@ -85,7 +85,7 @@ def build_biodata_json(logger: any, journaldir: str) -> int: # noqa #CCR001

if cmdr != "" and cmdr is not None and cmdr not in sold_exobiology.keys():
sold_exobiology[cmdr] = {alphabet[i]: {} for i in range(len(alphabet))}
logger.info(sold_exobiology)
logger.debug(sold_exobiology)

if cmdr != "" and cmdr not in possibly_sold_data.keys():
possibly_sold_data[cmdr] = []
Expand All @@ -99,11 +99,11 @@ def build_biodata_json(logger: any, journaldir: str) -> int: # noqa #CCR001
except KeyError:
# Was playing in old Horizons so
# Touchdown and Liftoff don't have body nor system
logger.info("We've encountered a KeyError in the code "
+ "for updating the current system and body.")
logger.info(entry)
logger.debug("We've encountered a KeyError in the code "
+ "for updating the current system and body.")
logger.debug(entry)
if entry["event"] == "ScanOrganic":
logger.info("Scan organic Event!")
logger.debug("Scan organic Event!")
if entry["ScanType"] in ["Sample", "Analyse"]:
if entry["ScanType"] == "Analyse":
currententrytowrite["species"] = generaltolocalised(entry["Species"].lower())
Expand All @@ -116,11 +116,11 @@ def build_biodata_json(logger: any, journaldir: str) -> int: # noqa #CCR001

if entry["event"] == "Resurrect":
# Reset - player was unable to sell before death
logger.info("We died")
logger.debug("We died")
possibly_sold_data[cmdr] = []

if entry["event"] == "SellOrganicData":
logger.info("SellOrganicData event!")
logger.debug("SellOrganicData event!")
currentbatch = {}
# Lets create a more human readable list of different types
# of sold biodata to see how we can continue from there.
Expand All @@ -140,10 +140,10 @@ def build_biodata_json(logger: any, journaldir: str) -> int: # noqa #CCR001
bysystem[biodata["system"]] = {}
bysystem[biodata["system"]][biodata["species"]] = 1
soldbysystempossible = {}
logger.info("bysystem:")
logger.info(bysystem)
logger.info("Currentbatch:")
logger.info(currentbatch)
logger.debug("bysystem:")
logger.debug(bysystem)
logger.debug("Currentbatch:")
logger.debug(currentbatch)
# input()

# Get every system
Expand Down Expand Up @@ -186,7 +186,7 @@ def build_biodata_json(logger: any, journaldir: str) -> int: # noqa #CCR001

# An eligible system was found and we selected the first
if thesystem != "":
logger.info("CMDR sold by system: " + thesystem)
logger.debug("CMDR sold by system: " + thesystem)
i = 0
while i < len(possibly_sold_data[cmdr]):
# For the case when we are done when we havent sold everything
Expand All @@ -197,7 +197,7 @@ def build_biodata_json(logger: any, journaldir: str) -> int: # noqa #CCR001
if done:
break

logger.info(" i = " + str(i))
logger.debug(" i = " + str(i))

firstletter = possibly_sold_data[cmdr][i]["system"][0].lower()
if firstletter not in alphabet:
Expand All @@ -208,10 +208,10 @@ def build_biodata_json(logger: any, journaldir: str) -> int: # noqa #CCR001
# the specifc data was sold only
# in one system that at this point
# is saved in the variable "thesystem"
logger.info("possibly sold data")
logger.info(possibly_sold_data[cmdr])
logger.info("current batch")
logger.info(currentbatch)
logger.debug("possibly sold data")
logger.debug(possibly_sold_data[cmdr])
logger.debug("current batch")
logger.debug(currentbatch)

if (thesystem not in sold_exobiology[cmdr][firstletter].keys()
and (thesystem[0].lower() == firstletter or firstletter == "-")):
Expand All @@ -223,7 +223,7 @@ def build_biodata_json(logger: any, journaldir: str) -> int: # noqa #CCR001
and possibly_sold_data[cmdr][i]["species"] in currentbatch.keys())
if check:
if currentbatch[possibly_sold_data[cmdr][i]["species"]] > 0:
logger.info("We append in specific system")
logger.debug("We append in specific system")
sold_exobiology[cmdr][firstletter][thesystem].append(possibly_sold_data[cmdr][i])
currentbatch[possibly_sold_data[cmdr][i]["species"]] -= 1
thing = possibly_sold_data[cmdr].pop(i)
Expand All @@ -236,11 +236,11 @@ def build_biodata_json(logger: any, journaldir: str) -> int: # noqa #CCR001
+ " this is a problem")
i += 1
else:
logger.info("CMDR sold the whole batch.")
logger.info("possibly sold data")
logger.info(possibly_sold_data[cmdr])
logger.info("current batch")
logger.info(currentbatch)
logger.debug("CMDR sold the whole batch.")
logger.debug("possibly sold data")
logger.debug(possibly_sold_data[cmdr])
logger.debug("current batch")
logger.debug(currentbatch)

for data in possibly_sold_data[cmdr]:
firstletter = data["system"][0].lower()
Expand All @@ -258,14 +258,14 @@ def build_biodata_json(logger: any, journaldir: str) -> int: # noqa #CCR001
and currentbatch[data["species"]] > 0):
currentbatch[data["species"]] -= 1

logger.info("We append single bit of whole batch")
logger.debug("We append single bit of whole batch")
sold_exobiology[cmdr][firstletter][data["system"]].append(data)
logger.info("We appended single bit of whole batch")
logger.debug("We appended single bit of whole batch")
possibly_sold_data[cmdr] = []

file.close()

logger.info("Saving file now")
logger.debug("Saving file now")

solddata = None

Expand Down Expand Up @@ -326,7 +326,7 @@ def build_biodata_json(logger: any, journaldir: str) -> int: # noqa #CCR001
print(element)
unsoldvalue += vistagenomicsprices[element["species"]]

logger.info("Done with journalcrawling!")
logger.debug("Done with journalcrawling!")

return unsoldvalue

Expand Down
16 changes: 9 additions & 7 deletions load.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def setup_preferences(self, parent: nb.Notebook, cmdr: str, is_beta: bool) -> Op
if currentcommander != "" and currentcommander is not None:
load_cmdr(cmdr)

line = "_______________________________________________"
line = "_____________________________________________________"

current_row = 0
frame = nb.Frame(parent)
Expand Down Expand Up @@ -515,7 +515,7 @@ def dashboard_entry(cmdr: str, is_beta, entry) -> None: # noqa #CCR001
plugin.AST_scan_1_dist_green = True
if olddist1check != plugin.AST_scan_1_dist_green:
flag = True
if plugin.AST_current_scan_progress.get() == "2/3" and plugin.AST_scan_1_pos_vector[0] is not None:
if plugin.AST_current_scan_progress.get() in ["1/3", "2/3"] and plugin.AST_scan_2_pos_vector[0] is not None:
distance2 = orgi.computedistance(plugin.AST_current_pos_vector[0],
plugin.AST_current_pos_vector[1],
plugin.AST_scan_2_pos_vector[0],
Expand Down Expand Up @@ -655,6 +655,7 @@ def bioscan_event(cmdr: str, is_beta, entry) -> None: # noqa #CCR001
plugin.AST_scan_1_pos_vector[0] = plugin.AST_current_pos_vector[0]
plugin.AST_scan_1_pos_vector[1] = plugin.AST_current_pos_vector[1]
plugin.AST_scan_2_pos_vector = [None, None]
plugin.AST_scan_2_pos_dist.set("")
plugin.on_preferences_closed(cmdr, is_beta)
elif entry["ScanType"] in ["Sample", "Analyse"]:
if (entry["ScanType"] == "Analyse"):
Expand Down Expand Up @@ -696,22 +697,23 @@ def bioscan_event(cmdr: str, is_beta, entry) -> None: # noqa #CCR001
f.truncate()
currententrytowrite = {}
else:

# Check if we already have scan progress 2/3 with same species on the same body.
# case 1: "2/3" with same species and body -> don't change 2nd dist
# case 2: "1/3" with same species and body -> change 2nd dist
# case 3: "1/3" without same species and body -> change 2nd dist, clear 1st dist. skipped a log
# case 4: "3/3" with same species and body -> impossible, do nothing, we can tag along with case 2
# case 5: "3/3" not same species and body -> change 2nd dist, clear 1st dist. skipped a log like case 3
if plugin.AST_current_scan_progress.get() in ["1/3", "3/3"]:
# cases for "0/3" same as 2 and 3
if (plugin.AST_current_scan_progress.get() != "2/3"):
# case 2, 3, 4, 5.
plugin.AST_scan_2_pos_vector[0] = plugin.AST_current_pos_vector[0]
plugin.AST_scan_2_pos_vector[1] = plugin.AST_current_pos_vector[1]
if not(old_AST_last_scan_system == plugin.AST_last_scan_system.get()
and old_AST_last_scan_body == plugin.AST_last_scan_body.get()
and old_AST_last_scan_plant == plugin.AST_last_scan_plant.get()):
if (not(old_AST_last_scan_system == plugin.AST_last_scan_system.get()
and old_AST_last_scan_body == plugin.AST_last_scan_body.get()
and old_AST_last_scan_plant == str(plugin.AST_last_scan_plant.get().split(" (Worth: ")[0]))):
# case 3 and 5
plugin.AST_scan_1_pos_vector = [None, None]
plugin.AST_scan_1_pos_dist.set("")

plugin.AST_current_scan_progress.set("2/3")
plugin.AST_CCR.set(orgi.getclonalcolonialranges(orgi.genusgeneraltolocalised(entry["Genus"])))
Expand Down

0 comments on commit 1195d4d

Please sign in to comment.