mirror of
https://github.com/solero/houdini.git
synced 2024-11-10 05:08:19 +00:00
Add handle_buy_inventory handler
This commit is contained in:
parent
5f20d30ada
commit
f40cf8989b
@ -1,8 +1,28 @@
|
||||
from houdini import handlers
|
||||
from houdini.handlers import XTPacket
|
||||
from houdini.data.item import Item
|
||||
|
||||
|
||||
@handlers.handler(XTPacket('i', 'gi'))
|
||||
@handlers.allow_once
|
||||
async def handle_get_inventory(p):
|
||||
await p.send_xt('gi', *p.data.inventory.keys())
|
||||
|
||||
|
||||
@handlers.handler(XTPacket('i', 'ai'))
|
||||
@handlers.depends_on_packet(XTPacket('i', 'gi'))
|
||||
@handlers.cooldown(1)
|
||||
async def handle_buy_inventory(p, item: Item):
|
||||
if item.id not in p.server.items:
|
||||
return await p.send_error(402)
|
||||
|
||||
if item.id in p.data.inventory:
|
||||
return await p.send_error(400)
|
||||
|
||||
if item.epf:
|
||||
return await p.add_inbox(p.server.postcards[126])
|
||||
|
||||
if p.data.coins < item.cost:
|
||||
return await p.send_error(401)
|
||||
|
||||
await p.add_inventory(item)
|
||||
|
Loading…
Reference in New Issue
Block a user