mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 12:11:33 -06:00
LADX: Adding Slot Data For Magpie Tracker (#3582)
* wip: LADX slot_data * LADX: slot_data * Sending slot_data to magpie. * Moved sending slot_data from pushing to pull by Magpie request. * Adding EoF newline to tracker.py. * Update Tracker.py * Update __init__.py * Update LinksAwakeningClient.py --------- Co-authored-by: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com>
This commit is contained in:
@@ -149,6 +149,8 @@ class MagpieBridge:
|
||||
item_tracker = None
|
||||
ws = None
|
||||
features = []
|
||||
slot_data = {}
|
||||
|
||||
async def handler(self, websocket):
|
||||
self.ws = websocket
|
||||
while True:
|
||||
@@ -163,6 +165,9 @@ class MagpieBridge:
|
||||
await self.send_all_inventory()
|
||||
if "checks" in self.features:
|
||||
await self.send_all_checks()
|
||||
if "slot_data" in self.features:
|
||||
await self.send_slot_data(self.slot_data)
|
||||
|
||||
# Translate renamed IDs back to LADXR IDs
|
||||
@staticmethod
|
||||
def fixup_id(the_id):
|
||||
@@ -222,6 +227,18 @@ class MagpieBridge:
|
||||
return
|
||||
await gps.send_location(self.ws)
|
||||
|
||||
async def send_slot_data(self, slot_data):
|
||||
if not self.ws:
|
||||
return
|
||||
|
||||
logger.debug("Sending slot_data to magpie.")
|
||||
message = {
|
||||
"type": "slot_data",
|
||||
"slot_data": slot_data
|
||||
}
|
||||
|
||||
await self.ws.send(json.dumps(message))
|
||||
|
||||
async def serve(self):
|
||||
async with websockets.serve(lambda w: self.handler(w), "", 17026, logger=logger):
|
||||
await asyncio.Future() # run forever
|
||||
@@ -237,4 +254,3 @@ class MagpieBridge:
|
||||
await self.send_all_inventory()
|
||||
else:
|
||||
await self.send_inventory_diffs()
|
||||
|
||||
|
@@ -512,3 +512,31 @@ class LinksAwakeningWorld(World):
|
||||
if change and item.name in self.rupees:
|
||||
state.prog_items[self.player]["RUPEES"] -= self.rupees[item.name]
|
||||
return change
|
||||
|
||||
def fill_slot_data(self):
|
||||
slot_data = {}
|
||||
|
||||
if not self.multiworld.is_race:
|
||||
# all of these option are NOT used by the LADX- or Text-Client.
|
||||
# they are used by Magpie tracker (https://github.com/kbranch/Magpie/wiki/Autotracker-API)
|
||||
# for convenient auto-tracking of the generated settings and adjusting the tracker accordingly
|
||||
|
||||
slot_options = ["instrument_count"]
|
||||
|
||||
slot_options_display_name = [
|
||||
"goal", "logic", "tradequest", "rooster",
|
||||
"experimental_dungeon_shuffle", "experimental_entrance_shuffle", "trendy_game", "gfxmod",
|
||||
"shuffle_nightmare_keys", "shuffle_small_keys", "shuffle_maps",
|
||||
"shuffle_compasses", "shuffle_stone_beaks", "shuffle_instruments", "nag_messages"
|
||||
]
|
||||
|
||||
# use the default behaviour to grab options
|
||||
slot_data = self.options.as_dict(*slot_options)
|
||||
|
||||
# for options which should not get the internal int value but the display name use the extra handling
|
||||
slot_data.update({
|
||||
option: value.current_key
|
||||
for option, value in dataclasses.asdict(self.options).items() if option in slot_options_display_name
|
||||
})
|
||||
|
||||
return slot_data
|
||||
|
Reference in New Issue
Block a user