1
0
mirror of synced 2024-12-18 00:05:53 +01:00

mai2: properly add present items

This commit is contained in:
Kevin Trocolli 2024-06-28 23:55:23 -04:00
parent af8bd1d1c0
commit ecb2e9ec75
2 changed files with 11 additions and 6 deletions

View File

@ -490,7 +490,6 @@ class Mai2Base:
pres_id += present['itemId']
items.append({"itemId": pres_id, "itemKind": 4, "stock": present['stock'], "isValid": True})
self.logger.info(f"Give user {data['userId']} {present['stock']}x item {present['itemId']} (kind {present['itemKind']}) as present")
await self.data.item.put_item(data["userId"], present['itemKind'], present['itemId'], present['stock'], True)
return { "userId": data.get("userId", 0), "length": len(items), "userPresentList": items}

View File

@ -196,10 +196,17 @@ class Mai2DX(Mai2Base):
if "userItemList" in upsert and len(upsert["userItemList"]) > 0:
for item in upsert["userItemList"]:
if item["itemKind"] == 4:
item_id = item["itemId"] % 1000000
item_kind = item["itemId"] // 1000000
else:
item_id = item["itemId"]
item_kind = item["itemKind"]
await self.data.item.put_item(
user_id,
int(item["itemKind"]),
item["itemId"],
item_kind,
item_id,
item["stock"],
item["isValid"],
)
@ -325,8 +332,8 @@ class Mai2DX(Mai2Base):
}
async def handle_get_user_item_api_request(self, data: Dict) -> Dict:
kind = int(data["nextIndex"] / 10000000000)
next_idx = int(data["nextIndex"] % 10000000000)
kind = data["nextIndex"] // 10000000000
next_idx = data["nextIndex"] % 10000000000
items: List[Dict[str, Any]] = []
if kind == 4: # presents
@ -348,7 +355,6 @@ class Mai2DX(Mai2Base):
pres_id += present['itemId']
items.append({"itemId": pres_id, "itemKind": 4, "stock": present['stock'], "isValid": True})
self.logger.info(f"Give user {data['userId']} {present['stock']}x item {present['itemId']} (kind {present['itemKind']}) as present")
await self.data.item.put_item(data["userId"], present['itemKind'], present['itemId'], present['stock'], True)
else:
user_item_list = await self.data.item.get_items(data["userId"], kind)