forked from Hay1tsme/artemis
allnet: basic playhistory
This commit is contained in:
@ -593,7 +593,6 @@ class BillingServlet:
|
||||
return PlainTextResponse("result=5&linelimit=&message=field is missing or formatting is incorrect\r\n")
|
||||
|
||||
kc_serial_bytes = req.keychipid.encode()
|
||||
|
||||
|
||||
machine = await self.data.arcade.get_machine(req.keychipid)
|
||||
if machine is None and not self.config.server.allow_unregistered_serials:
|
||||
@ -614,6 +613,32 @@ class BillingServlet:
|
||||
}
|
||||
|
||||
if machine is not None:
|
||||
if self.config.allnet.save_billing:
|
||||
lastcredit = await self.data.arcade.billing_get_credit(machine['id'], req.gameid)
|
||||
if lastcredit is not None:
|
||||
last_playct = lastcredit['playcount']
|
||||
else:
|
||||
last_playct = 0
|
||||
|
||||
# Technically if a cab resets it's playcount and then does more plays then the previous
|
||||
# playcount before a billing checkin occours, we will lose plays equal to the current playcount.
|
||||
if req.playcnt < last_playct: await self.data.arcade.billing_add_playcount(machine['id'], req.gameid, req.playcnt)
|
||||
elif req.playcnt == last_playct: pass # No plays since last checkin, skip update
|
||||
else: await self.data.arcade.billing_add_playcount(machine['id'], req.gameid, req.playcnt - last_playct)
|
||||
|
||||
plays = await self.data.arcade.billing_get_playcount_3mo(machine['id'], req.gameid)
|
||||
if plays is not None and len(plays) > 0:
|
||||
playhist = ""
|
||||
|
||||
for x in range(len(plays), 0, -1): playhist += f"{plays[x]['year']:04d}{plays[x]['month']:02d}/{plays[x]['playct']}:"
|
||||
playhist = playhist[:-1]
|
||||
|
||||
else:
|
||||
playhist = "000000/0:000000/0:000000/0"
|
||||
|
||||
else:
|
||||
playhist = "000000/0:000000/0:000000/0"
|
||||
|
||||
for x in range(1, len(req_dict)):
|
||||
if not req_dict[x]:
|
||||
continue
|
||||
@ -649,6 +674,7 @@ class BillingServlet:
|
||||
if self.config.allnet.save_billing:
|
||||
await self.data.arcade.billing_set_credit(
|
||||
machine['id'],
|
||||
req.gameid,
|
||||
tmp.chute_type.value,
|
||||
tmp.service_type.value,
|
||||
tmp.operation_type.value,
|
||||
@ -708,9 +734,7 @@ class BillingServlet:
|
||||
digest.update(nearfull.to_bytes(4, "little") + kc_serial_bytes)
|
||||
nearfull_sig = signer.sign(digest).hex()
|
||||
|
||||
# TODO: playhistory
|
||||
|
||||
resp = BillingResponse(playlimit, playlimit_sig, nearfull, nearfull_sig, req.requestno, req.protocolver)
|
||||
resp = BillingResponse(playlimit, playlimit_sig, nearfull, nearfull_sig, req.requestno, req.protocolver, playhist)
|
||||
|
||||
resp_str = urllib.parse.unquote(urllib.parse.urlencode(vars(resp))) + "\r\n"
|
||||
|
||||
|
Reference in New Issue
Block a user