LADX: Fix autotracking for shop items (#1623)

This commit is contained in:
zig-for 2023-03-29 05:56:10 -07:00 committed by GitHub
parent 53b3cd029e
commit bb79073ce7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 9 deletions

View File

@ -160,25 +160,26 @@ class MagpieBridge:
await self.send_all_inventory()
if "checks" in message["features"]:
await self.send_all_checks()
# Translate renamed IDs back to LADXR IDs
@staticmethod
def fixup_id(the_id):
if the_id == "0x2A1":
return "0x2A1-0"
if the_id == "0x2A7":
return "0x2A1-1"
return the_id
async def send_all_checks(self):
while self.checks == None:
await asyncio.sleep(0.1)
logger.info("sending all checks to magpie")
# Translate renamed IDs back to LADXR IDs
def fixup_id(the_id):
if the_id == "0x2A1":
return "0x2A1-0"
if the_id == "0x2A7":
return "0x2A1-1"
return the_id
message = {
"type": "check",
"refresh": True,
"version": "1.0",
"diff": False,
"checks": [{"id": fixup_id(check.id), "checked": check.value} for check in self.checks]
"checks": [{"id": self.fixup_id(check.id), "checked": check.value} for check in self.checks]
}
await self.ws.send(json.dumps(message))
@ -193,7 +194,7 @@ class MagpieBridge:
"refresh": True,
"version": "1.0",
"diff": True,
"checks": [{"id": check, "checked": True} for check in checks]
"checks": [{"id": self.fixup_id(check), "checked": True} for check in checks]
}
await self.ws.send(json.dumps(message))