mirror of
https://github.com/solero/houdini.git
synced 2024-11-22 05:27:23 +00:00
Use vanilla_inventory
and legacy_inventory
columns to determine default inventories
This commit is contained in:
parent
874c4d6a68
commit
2d9b73e54b
@ -1,6 +1,7 @@
|
|||||||
from houdini.data import AbstractDataCollection, db
|
from houdini.data import AbstractDataCollection, db
|
||||||
from functools import cached_property
|
from functools import cached_property
|
||||||
|
|
||||||
|
|
||||||
class Flooring(db.Model):
|
class Flooring(db.Model):
|
||||||
__tablename__ = 'flooring'
|
__tablename__ = 'flooring'
|
||||||
|
|
||||||
@ -29,7 +30,6 @@ class Furniture(db.Model):
|
|||||||
innocent = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
|
innocent = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Igloo(db.Model):
|
class Igloo(db.Model):
|
||||||
__tablename__ = 'igloo'
|
__tablename__ = 'igloo'
|
||||||
|
|
||||||
@ -118,6 +118,14 @@ class IglooCollection(AbstractDataCollection):
|
|||||||
__indexby__ = 'id'
|
__indexby__ = 'id'
|
||||||
__filterby__ = 'id'
|
__filterby__ = 'id'
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def legacy_inventory(self):
|
||||||
|
return [item for item in self.values() if item.legacy_inventory]
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def vanilla_inventory(self):
|
||||||
|
return [item for item in self.values() if item.vanilla_inventory]
|
||||||
|
|
||||||
|
|
||||||
class PenguinIglooCollection(AbstractDataCollection):
|
class PenguinIglooCollection(AbstractDataCollection):
|
||||||
__model__ = PenguinIgloo
|
__model__ = PenguinIgloo
|
||||||
@ -130,6 +138,14 @@ class LocationCollection(AbstractDataCollection):
|
|||||||
__indexby__ = 'id'
|
__indexby__ = 'id'
|
||||||
__filterby__ = 'id'
|
__filterby__ = 'id'
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def legacy_inventory(self):
|
||||||
|
return [item for item in self.values() if item.legacy_inventory]
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def vanilla_inventory(self):
|
||||||
|
return [item for item in self.values() if item.vanilla_inventory]
|
||||||
|
|
||||||
|
|
||||||
class PenguinLocationCollection(AbstractDataCollection):
|
class PenguinLocationCollection(AbstractDataCollection):
|
||||||
__model__ = PenguinLocation
|
__model__ = PenguinLocation
|
||||||
@ -146,6 +162,14 @@ class FurnitureCollection(AbstractDataCollection):
|
|||||||
def innocent(self):
|
def innocent(self):
|
||||||
return [item for item in self.values() if item.innocent]
|
return [item for item in self.values() if item.innocent]
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def legacy_inventory(self):
|
||||||
|
return [item for item in self.values() if item.legacy_inventory]
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def vanilla_inventory(self):
|
||||||
|
return [item for item in self.values() if item.vanilla_inventory]
|
||||||
|
|
||||||
|
|
||||||
class PenguinFurnitureCollection(AbstractDataCollection):
|
class PenguinFurnitureCollection(AbstractDataCollection):
|
||||||
__model__ = PenguinFurniture
|
__model__ = PenguinFurniture
|
||||||
@ -158,6 +182,14 @@ class FlooringCollection(AbstractDataCollection):
|
|||||||
__indexby__ = 'id'
|
__indexby__ = 'id'
|
||||||
__filterby__ = 'id'
|
__filterby__ = 'id'
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def legacy_inventory(self):
|
||||||
|
return [item for item in self.values() if item.legacy_inventory]
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def vanilla_inventory(self):
|
||||||
|
return [item for item in self.values() if item.vanilla_inventory]
|
||||||
|
|
||||||
|
|
||||||
class PenguinFlooringCollection(AbstractDataCollection):
|
class PenguinFlooringCollection(AbstractDataCollection):
|
||||||
__model__ = PenguinFlooring
|
__model__ = PenguinFlooring
|
||||||
|
@ -73,6 +73,14 @@ class ItemCollection(AbstractDataCollection):
|
|||||||
def innocent(self):
|
def innocent(self):
|
||||||
return [item for item in self.values() if item.innocent]
|
return [item for item in self.values() if item.innocent]
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def legacy_inventory(self):
|
||||||
|
return [item for item in self.values() if item.legacy_inventory]
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def vanilla_inventory(self):
|
||||||
|
return [item for item in self.values() if item.vanilla_inventory]
|
||||||
|
|
||||||
|
|
||||||
class PenguinItemCollection(AbstractDataCollection):
|
class PenguinItemCollection(AbstractDataCollection):
|
||||||
__model__ = PenguinItem
|
__model__ = PenguinItem
|
||||||
|
@ -136,11 +136,6 @@ async def igloos_load(server):
|
|||||||
server.logger.info(f'Loaded {len(server.flooring)} igloo flooring')
|
server.logger.info(f'Loaded {len(server.flooring)} igloo flooring')
|
||||||
|
|
||||||
|
|
||||||
DefaultFurnitureItems = [787, 788, 790, 792, 793]
|
|
||||||
DefaultIglooId = 1
|
|
||||||
DefaultLocationId = 1
|
|
||||||
|
|
||||||
|
|
||||||
@handlers.handler(XMLPacket('login'), priority=Priority.Low)
|
@handlers.handler(XMLPacket('login'), priority=Priority.Low)
|
||||||
@handlers.allow_once
|
@handlers.allow_once
|
||||||
async def load_igloo_inventory(p):
|
async def load_igloo_inventory(p):
|
||||||
@ -150,15 +145,29 @@ async def load_igloo_inventory(p):
|
|||||||
p.flooring = await PenguinFlooringCollection.get_collection(p.id)
|
p.flooring = await PenguinFlooringCollection.get_collection(p.id)
|
||||||
p.locations = await PenguinLocationCollection.get_collection(p.id)
|
p.locations = await PenguinLocationCollection.get_collection(p.id)
|
||||||
|
|
||||||
if DefaultIglooId not in p.igloos:
|
default_igloos = p.server.igloos.legacy_inventory if p.is_legacy_client else \
|
||||||
await p.igloos.insert(igloo_id=DefaultIglooId)
|
p.server.igloos.vanilla_inventory
|
||||||
|
for default_item in default_igloos:
|
||||||
|
if default_item.id not in p.igloos:
|
||||||
|
await p.igloos.insert(igloo_id=default_item.id)
|
||||||
|
|
||||||
if DefaultLocationId not in p.locations:
|
default_locations = p.server.locations.legacy_inventory if p.is_legacy_client else \
|
||||||
await p.locations.insert(location_id=DefaultLocationId)
|
p.server.locations.vanilla_inventory
|
||||||
|
for default_item in default_locations:
|
||||||
|
if default_item.id not in p.locations:
|
||||||
|
await p.locations.insert(location_id=default_item.id)
|
||||||
|
|
||||||
for default_item_id in DefaultFurnitureItems:
|
default_flooring = p.server.flooring.legacy_inventory if p.is_legacy_client else \
|
||||||
if default_item_id not in p.furniture:
|
p.server.flooring.vanilla_inventory
|
||||||
await p.furniture.insert(furniture_id=default_item_id)
|
for default_item in default_flooring:
|
||||||
|
if default_item.id not in p.flooring:
|
||||||
|
await p.flooring.insert(flooring_id=default_item.id)
|
||||||
|
|
||||||
|
default_furniture = p.server.furniture.legacy_inventory if p.is_legacy_client else \
|
||||||
|
p.server.furniture.vanilla_inventory
|
||||||
|
for default_item in default_furniture:
|
||||||
|
if default_item.id not in p.furniture:
|
||||||
|
await p.furniture.insert(furniture_id=default_item.id)
|
||||||
|
|
||||||
|
|
||||||
@handlers.handler(XTPacket('g', 'gm'))
|
@handlers.handler(XTPacket('g', 'gm'))
|
||||||
@ -254,9 +263,6 @@ async def handle_buy_furniture(p, furniture: Furniture):
|
|||||||
if furniture is None:
|
if furniture is None:
|
||||||
return await p.send_error(402)
|
return await p.send_error(402)
|
||||||
|
|
||||||
if furniture.id in p.furniture:
|
|
||||||
return await p.send_error(400)
|
|
||||||
|
|
||||||
if p.coins < furniture.cost:
|
if p.coins < furniture.cost:
|
||||||
return await p.send_error(401)
|
return await p.send_error(401)
|
||||||
|
|
||||||
|
@ -40,21 +40,20 @@ async def items_load(server):
|
|||||||
server.logger.info(f'Loaded {len(server.items)} clothing items')
|
server.logger.info(f'Loaded {len(server.items)} clothing items')
|
||||||
|
|
||||||
|
|
||||||
DefaultInventory = [1285, 9106]
|
|
||||||
|
|
||||||
|
|
||||||
@handlers.handler(XMLPacket('login'), priority=Priority.Low)
|
@handlers.handler(XMLPacket('login'), priority=Priority.Low)
|
||||||
@handlers.allow_once
|
@handlers.allow_once
|
||||||
async def load_inventory(p):
|
async def load_inventory(p):
|
||||||
p.inventory = await PenguinItemCollection.get_collection(p.id)
|
p.inventory = await PenguinItemCollection.get_collection(p.id)
|
||||||
p.permissions = await PenguinPermissionCollection.get_collection(p.id)
|
p.permissions = await PenguinPermissionCollection.get_collection(p.id)
|
||||||
|
|
||||||
if p.color not in p.inventory:
|
if p.color is not None and p.color not in p.inventory:
|
||||||
await p.inventory.insert(item_id=p.color)
|
await p.inventory.insert(item_id=p.color)
|
||||||
|
|
||||||
for default_item_id in DefaultInventory:
|
default_items = p.server.items.legacy_inventory if p.is_legacy_client else \
|
||||||
if default_item_id not in p.inventory:
|
p.server.items.vanilla_inventory
|
||||||
await p.inventory.insert(item_id=default_item_id)
|
for default_item in default_items:
|
||||||
|
if default_item.id not in p.inventory:
|
||||||
|
await p.inventory.insert(item_id=default_item.id)
|
||||||
|
|
||||||
|
|
||||||
@handlers.handler(XTPacket('i', 'gi'))
|
@handlers.handler(XTPacket('i', 'gi'))
|
||||||
|
Loading…
Reference in New Issue
Block a user