forked from Hay1tsme/artemis
mai2: fix presents
This commit is contained in:
@ -474,6 +474,7 @@ class Mai2Base:
|
||||
items: List[Dict[str, Any]] = []
|
||||
user_pres_list = await self.data.item.get_presents_by_version_user(self.version, data["userId"])
|
||||
if user_pres_list:
|
||||
self.logger.debug(f"Found {len(user_pres_list)} possible presents")
|
||||
for present in user_pres_list:
|
||||
if (present['startDate'] and present['startDate'].timestamp() > datetime.now().timestamp()):
|
||||
self.logger.debug(f"Present {present['id']} distribution hasn't started yet (begins {present['startDate']})")
|
||||
@ -485,7 +486,9 @@ class Mai2Base:
|
||||
|
||||
test = await self.data.item.get_item(data["userId"], present['itemKind'], present['itemId'])
|
||||
if not test: # Don't send presents for items the user already has
|
||||
items.append({"itemId": present['itemId'], "itemKind": present['itemKind'], "stock": present['stock'], "isValid": True})
|
||||
pres_id = present['itemKind'] * 1000000
|
||||
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)
|
||||
|
||||
|
Reference in New Issue
Block a user