mirror of
https://github.com/solero/houdini.git
synced 2024-11-22 13:37:28 +00:00
Implement inventory methods in penguin class
This commit is contained in:
parent
5249ce02a5
commit
677d60e398
@ -47,27 +47,119 @@ class Penguin(Spheniscidae):
|
|||||||
def nickname(self):
|
def nickname(self):
|
||||||
return self.data.safe_nickname(self.server.server_config['Language'])
|
return self.data.safe_nickname(self.server.server_config['Language'])
|
||||||
|
|
||||||
async def load(self):
|
async def join_room(self, room):
|
||||||
if self.data:
|
await room.add_penguin(self)
|
||||||
self.permissions = await PermissionCrumbsCollection.get_collection(self.data.id)
|
|
||||||
|
|
||||||
async def add_inventory(self, item):
|
async def add_inventory(self, item, notify=True):
|
||||||
pass
|
if item.id in self.data.inventory:
|
||||||
|
return False
|
||||||
|
|
||||||
async def add_igloo(self, igloo):
|
await self.data.inventory.set(item.id)
|
||||||
pass
|
await self.data.update(coins=self.data.coins - item.cost).apply()
|
||||||
|
|
||||||
async def add_furniture(self, furniture):
|
if notify:
|
||||||
pass
|
await self.send_xt('ai', item.id, self.data.coins)
|
||||||
|
|
||||||
async def add_flooring(self, flooring):
|
self.logger.info('{} added \'{}\' to their clothing inventory'.format(
|
||||||
pass
|
self.data.username, item.name))
|
||||||
|
|
||||||
async def add_buddy(self, buddy):
|
return True
|
||||||
pass
|
|
||||||
|
|
||||||
async def add_inbox(self, postcard):
|
async def add_igloo(self, igloo, notify=True):
|
||||||
pass
|
if igloo.id in self.data.igloos:
|
||||||
|
return False
|
||||||
|
|
||||||
|
await self.data.igloos.set(igloo.id)
|
||||||
|
await self.data.update(coins=self.data.coins - igloo.cost).apply()
|
||||||
|
|
||||||
|
if notify:
|
||||||
|
await self.send_xt('au', igloo.id, self.data.coins)
|
||||||
|
|
||||||
|
self.logger.info('{} added \'{}\' to their igloos inventory'.format(
|
||||||
|
self.data.username, igloo.name))
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
async def add_furniture(self, furniture, quantity=1, notify=True):
|
||||||
|
if furniture.id in self.data.furniture:
|
||||||
|
penguin_furniture = self.data.furniture[furniture.id]
|
||||||
|
if penguin_furniture.quantity >= furniture.max_quantity:
|
||||||
|
return False
|
||||||
|
|
||||||
|
await penguin_furniture.update(
|
||||||
|
quantity=penguin_furniture.quantity + quantity).apply()
|
||||||
|
else:
|
||||||
|
await self.data.furniture.set(furniture.id)
|
||||||
|
|
||||||
|
await self.data.update(coins=self.data.coins - furniture.cost).apply()
|
||||||
|
|
||||||
|
if notify:
|
||||||
|
await self.send_xt('af', furniture.id, self.data.coins)
|
||||||
|
|
||||||
|
self.logger.info('{} added \'{}\' to their furniture inventory'.format(
|
||||||
|
self.data.username, furniture.name))
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
async def add_card(self, card, quantity=1):
|
||||||
|
if card.id in self.data.cards:
|
||||||
|
penguin_card = self.data.cards[card.id]
|
||||||
|
|
||||||
|
await penguin_card.update(
|
||||||
|
quantity=penguin_card.quantity + quantity).apply()
|
||||||
|
else:
|
||||||
|
await self.data.cards.set(card.id)
|
||||||
|
|
||||||
|
self.logger.info('{} added \'{}\' to their ninja deck'.format(
|
||||||
|
self.data.username, card.name))
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
async def add_flooring(self, flooring, notify=True):
|
||||||
|
if flooring.id in self.data.flooring:
|
||||||
|
return False
|
||||||
|
|
||||||
|
await self.data.flooring.set(flooring.id)
|
||||||
|
await self.data.update(coins=self.data.coins - flooring.cost).apply()
|
||||||
|
|
||||||
|
if notify:
|
||||||
|
await self.send_xt('ag', flooring.id, self.data.coins)
|
||||||
|
|
||||||
|
self.logger.info('{} added \'{}\' to their flooring inventory'.format(
|
||||||
|
self.data.username, flooring.name))
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
async def add_location(self, location, notify=True):
|
||||||
|
if location.id in self.data.locations:
|
||||||
|
return False
|
||||||
|
|
||||||
|
await self.data.locations.set(location.id)
|
||||||
|
await self.data.update(coins=self.data.coins - location.cost).apply()
|
||||||
|
|
||||||
|
if notify:
|
||||||
|
await self.send_xt('aloc', location.id, self.data.coins)
|
||||||
|
|
||||||
|
self.logger.info('{} added \'{}\' to their location inventory'.format(
|
||||||
|
self.data.username, location.name))
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
async def add_inbox(self, postcard, sender_name="sys", sender_id=None, details=""):
|
||||||
|
penguin_postcard = await self.data.postcards.set(penguin_id=self.data.id,
|
||||||
|
sender_id=sender_id, postcard_id=postcard.id,
|
||||||
|
details=details)
|
||||||
|
|
||||||
|
await self.send_xt('mr', sender_name, 0, postcard.id, details, int(time.time()), penguin_postcard.id)
|
||||||
|
|
||||||
|
async def add_permission(self, permission):
|
||||||
|
if permission not in self.data.permissions:
|
||||||
|
await self.data.permissions.set(permission)
|
||||||
|
|
||||||
|
self.logger.info('{} was assigned permission \'{}\''.format(
|
||||||
|
self.data.username, permission))
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
if self.data is not None:
|
if self.data is not None:
|
||||||
|
Loading…
Reference in New Issue
Block a user