forked from Hay1tsme/artemis
mai2: properly add present items
This commit is contained in:
parent
af8bd1d1c0
commit
ecb2e9ec75
@ -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}
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user