1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-14 00:07:14 +03:00

426 Commits

Author SHA1 Message Date
Athanasius
5f59487a7b Zero out BackPack Materials on ShipLockerMaterials
This at least ensures we're correct after logging back in at a station.

If you relog whilst out at a Settlement then counts will definitely be
wrong now.  But there are no events for using consumables, or picking
anything up anyway, so it's almost always going to be off there.
2021-04-12 08:31:47 +01:00
Athanasius
9609286ff4 Support for 'TransferMicroResources' event. 2021-04-12 08:31:47 +01:00
Athanasius
c5d2300ba5 Support for 'TradeMicroResources' event
This has an array 'Offered' listing what was traded away.
'Category' & 'Received' is what you got in return, 'Count' many.

Again, we assume this only interacts with ShipLocker, not BackPack.
2021-04-12 08:31:47 +01:00
Athanasius
c94ebad54c Support for event 'SellMicroResources'
These are being sold to a Bar Tender.

There's a MicroResources array, one per item name.  We assume this is
always selling from ShipLocker, not BackPack.
2021-04-12 08:31:47 +01:00
Athanasius
a2c48fdd70 Support for 'BuyMicroResources' event
This is currently only when buying Consumables from a Pioneer Supplies
vendor.

One event per Item type, it's not an array.

We're assuming these go into ShipLocker, not BackPack.
2021-04-12 08:31:47 +01:00
Athanasius
28c4fa03b1 Add support for BacKPackMaterials event
It's unclear from my Journals if this is adding to the current or is the
total state at the time.  I think it's the latter, despite not finding
where a '737844537' had come from (looks like from a mission, but that
would be reward and should have gone straight to ShipLocker?).
2021-04-12 08:31:47 +01:00
Athanasius
7040975bd2 Add support for 'ShipLockerMaterials' 2021-04-12 08:31:47 +01:00
Athanasius
ad677d73f6 monitor.state: Group all Odyssey, and add other ShipLocker categories 2021-04-12 08:31:47 +01:00
Athanasius
c4df5b2822 DRY init of self.state
It's identical in both places, so use a common function.
2021-04-12 08:31:47 +01:00
Athanasius
5c5e5b507e monitor.py: Fix up legavy config.get() calls 2021-04-12 08:31:47 +01:00
Athanasius
c26d1bce93 Comment out un-necessary logger.trace()
In monitor.py it was all that 'Location' event tracing.
2021-04-12 08:30:51 +01:00
Athanasius
3933dea479 Convert monitor.event_queue to a queue.Queue.
* We now use event_queue.empty() to see if it is indeed empty.
* Changed AppWindow.journal_event() to also use .empty() rather than
  `while True`.  Keeping the `'if not entry'` check just in case.
  This prevents it from calling monitor.get_entry() when the prior run
  through the loop has just emptied the queue.  Thus we'll only log when
  it genuinely IS unexpectedly empty.
* During *game* Shutdown we can send the synthetic 'Shutdown' event
  through, and then find and append the actual game 'Shutdown' event
  (i.e. this wasn't a crash, which is what the synthetic event is meant
  to react to).  But AppWindow.journal_event() loop picks up both events
  in one call, so the second <<JournalEvent>> sends it working on an
  empty queue.
  Thus we log in monitor.get_entry() only if the queue is empty *and*
  the game is still running.
* NB: Also adds 'Component' to the OTHER place montitor.state is
  initialised.
2021-04-12 08:30:51 +01:00
Athanasius
8f2802fbcf monitor.py: Add support for Odyssey 'Component' materials. 2021-04-12 08:30:51 +01:00
Athanasius
5edf8d5b59 Change monitor.state['on_foot'] to 'OnFoot' for consistency 2021-04-12 08:30:51 +01:00
Athanasius
f45f817fa2 EDDB plugin now setting Station name correctly on_foot
* monitor.on_foot is now monitor.state['on_foot'] as plugins need to
  access it.
* EDDB:journal_entry() now stores that in this.on_foot to check later.
* this.on_foot checked in cmdr_data() to actually set station name from
  that data if needs be.  This avoids setting it to STATION_UNDOCKED if
  data['commander']['docked'] is False, when we're on_foot.
2021-04-12 08:30:51 +01:00
Athanasius
567cfdb9ca Will now send data to EDDN when on-foot in-station.
NB: No shipyard in tests because data['ships']['shipyard_list'] is an
empty list.  This might be the bug not having been fixed, or the station
might genuinely have no ships for sale.  We have no way to check in
Odyssey Alpha Phase 1.
2021-04-12 08:30:51 +01:00
Athanasius
a09512f3b3 Mostly refactoring companion.ship_file_name() into util_ships.py
* Also prevent "You're not docked at a station!" for on_foot.
2021-04-12 08:30:51 +01:00
Athanasius
6fe86cd719 on_foot: Attempt to set correctly when state changes.
* For taxi-usage you 'Embark' on it to take the trip and 'Disembark'
  onto foot at the other end.
* Joining a multi-crew session will mean no longer being on foot.
* When quitting a multi-crew session we might miss that you're back
  on-foot.  Need to test.
2021-04-12 08:30:51 +01:00
Athanasius
0113295ae5 monitor.py: Set monitor.on_foot if LoadGame is in a suit
* Also sets monitor.station via BodyType/Body if the former is
  'Station'.
2021-04-12 08:30:50 +01:00
Athanasius
be740d0bcd Remove another open 'U' flag. 2021-04-01 14:46:43 +01:00
Athanasius
69bc90f5b4 Make export_ship() paranoid about possible encoding issues.
We had a report of a UnicodeDecodeError trying to read an old file.  So
try utf-8 first, if it fails try the default, and if nothing else try to
write a new file so the next call should actually work as expected.
2021-04-01 14:46:43 +01:00
A_D
60dd93a3de Fixed invalid type annotation 2021-04-01 14:45:50 +01:00
Athanasius
84afe6821a import of watchdog.events.FileCreatedEvent needed even when not type checking
PyCharm debugging bailed out due to the lack.
2021-04-01 14:45:50 +01:00
Athanasius
eef4acd30b Document line param to parse_entry() 2021-04-01 14:45:50 +01:00
Athanasius
4a1feb4d49 Type hints should be 100% now.
There's something around line 324:

                entry: OrderedDictT[str, Any] = OrderedDict([

producing an error with pre-commit's run of mypy
2021-04-01 14:45:50 +01:00
Athanasius
20772e7daf Fixed current mypy complaints.
There are still *missing* type annotations.
2021-04-01 14:45:50 +01:00
Athanasius
1c82605d9f monitor.py: General cleanup work on flake8 output.
* docstrings added as per flake8 complaints.
* Some type hints added (as I was documenting param and return).
* Also reworked two uses of .format()
* A number of functions had noqa added for cognitive complexity.
2021-04-01 14:45:50 +01:00
Athanasius
3fddd2bdf9 try/except ModulesInfo.json load & fully document 2021-04-01 14:45:50 +01:00
Athanasius
fd0ce63341 Add basic support for ModuleInfo event.
This still needs documentation adding in PLUGINS.md, which is easiest
done after #897 is merged and re-based upon.
2021-04-01 14:45:50 +01:00
Athanasius
361cd168af Actually show exception on json.load(<NavRoute.json>) exception 2021-04-01 14:45:50 +01:00
Athanasius
f280a7e863 try/except for NavRoute json.load() 2021-04-01 14:45:50 +01:00
Athanasius
0dc7c62fa8 Correct Route to NavRoute in the code/comments as well 2021-04-01 14:45:50 +01:00
Athanasius
b3a1b0492e Correct event and file name to NavRoute(.json) & expand docs
* Despite what section 4.18 of v28 Journal docs say, the event is
  `NavRoute`, not `Route`, and the file is `NavRoute.json`.  The array
  of hops is still keyed as `Route` though.

* Calls out that both `NavRoute` and `Cargo` events, as passed to
  plugins, are augmented with the data from their respective files, and
  are not simply the 'bare' event as seen in the Journal.
2021-04-01 14:45:50 +01:00
Athanasius
ef891fa8bd Initial support for Route.json file 2021-04-01 14:45:50 +01:00
Athanasius
96953744c9 monitor: Close journal loghandle if signalled to close down. 2021-04-01 14:45:50 +01:00
Athanasius
4255a2fd28 monitor: Fix isort complains
* Tested with py2exe build on Windows 10 native.  Frontier auth works.
2021-04-01 14:45:50 +01:00
Athanasius
d39c0521da Move JournalLock class into its own file
Closes #891

# Conflicts:
#	journal_lock.py
#	monitor.py
2021-04-01 14:45:49 +01:00
Athanasius
851c4f0c7e Update config.get() calls to config.get_str()
# Conflicts:
#	monitor.py
2021-04-01 14:45:49 +01:00
Athanasius
55ee4485d1 Implement retry of locking when journal dir changed.
In case the user does have another EDMC instance running that they need
to kill first.

# Conflicts:
#	monitor.py
2021-04-01 14:45:49 +01:00
Athanasius
0cb0701ca8 Implement releasing of monitor.JournalLock()
* Implement JournalLock.release_lock().
* Renamed other methods to remove journaldir_ prefix.
* Slightly tweak the code flow for obtaining the lock.
* Implement JournalLock.update_lock(), called from AppWindow.postprefs().

# Conflicts:
#	EDMarketConnector.py
2021-04-01 14:45:49 +01:00
Athanasius
b3959cb8d2 Move journal locking code into new monitor.JournalLock class 2021-04-01 14:45:49 +01:00
A_D
051245cf90 Renamed various config values to be backwards compatible 2021-04-01 14:45:48 +01:00
A_D
00629b7420 use _str versions of paths for string ops 2021-04-01 14:45:48 +01:00
A_D
48427a770d Updated monitor to support '' configured journal dir 2021-04-01 14:45:46 +01:00
A_D
278480b99f replaced ors with defaults in config usage 2021-04-01 14:45:46 +01:00
Athanasius
25852997c5 Updated all source to use new config methods
# Conflicts:
#	monitor.py
2021-04-01 14:45:46 +01:00
Athanasius
8b3785cdf7 monitor.py: Detailed logging EDLogs.worker() 2021-04-01 14:45:44 +01:00
Athanasius
9be7f14573 monitor.py: Detailed logging EDLogs.start() 2021-04-01 14:45:44 +01:00
Athanasius
4a84d9c341 monitor: Detailed logging EDLogs.stop()
# Conflicts:
#	monitor.py
2021-04-01 14:45:44 +01:00
Athanasius
7ebf2a553a monitor: Detailed logging EDLogs.close() 2021-04-01 14:45:44 +01:00