Keep chest contents out of player inventory
This commit is contained in:
1 parent
c2b595a70d
commit
9918baefdc
3 files changed
+97
No files matched your search
@@ -51,6 +51,34 @@ class TestInventoryDrain(unittest.TestCase):
|
||||
self.assertEqual(g.inv[44].item_id, 789)
|
||||
self.assertFalse(g.item_lock)
|
||||
|
||||
def test_short_window_snapshot_does_not_pollute_player_inventory(self):
|
||||
current = Slot(True, 123, 7)
|
||||
contents = [Slot(True, 456 + index, 1) for index in range(21)]
|
||||
g = Munch(
|
||||
inv={9: current},
|
||||
window=Munch(window_id=4, contents={}, container_slots=0),
|
||||
inventory_state_ids={}, item_lock=False,
|
||||
)
|
||||
manager = object.__new__(InventoryManager)
|
||||
manager.g = g
|
||||
|
||||
manager.handle_content(SimpleNamespace(
|
||||
container_id=4, state_id=9, items=contents,
|
||||
carried_item=Slot(False), partial=False,
|
||||
))
|
||||
|
||||
self.assertEqual(g.window.container_slots, 0)
|
||||
self.assertEqual(g.window.contents[0].item_id, 456)
|
||||
self.assertEqual(set(g.inv), {9})
|
||||
self.assertEqual((g.inv[9].item_id, g.inv[9].item_count), (123, 7))
|
||||
|
||||
manager.handle_slot(SimpleNamespace(
|
||||
container_id=4, state_id=10, slot=0, item=Slot(True, 789, 2),
|
||||
))
|
||||
|
||||
self.assertEqual(g.window.contents[0].item_id, 789)
|
||||
self.assertEqual((g.inv[9].item_id, g.inv[9].item_count), (123, 7))
|
||||
|
||||
def test_drop_packet_encodes_throw_whole_stack(self):
|
||||
packet = ContainerClickDropPacket(
|
||||
container_id=0, state_id=7, slot=45)
|
||||
|
||||
Reference in new issue
Block a user