Skip full cache chests until reopened
This commit is contained in:
1 parent
5197c1ece7
commit
1b4dc21ea4
2 files changed
+150
-4
No files matched your search
@@ -217,6 +217,93 @@ class CacheItemsTests(unittest.TestCase):
|
||||
state.choose_trapped_chest()
|
||||
self.assertIs(state.state.__func__, state.cleanup.__func__)
|
||||
|
||||
def test_full_chest_is_blacklisted_when_first_opened(self):
|
||||
position = (5, 64, 0)
|
||||
key = (position,)
|
||||
window = Munch(container_slots=27, contents={})
|
||||
closed = []
|
||||
|
||||
class FakeGame:
|
||||
@staticmethod
|
||||
def count_window_slots():
|
||||
return 27
|
||||
|
||||
@staticmethod
|
||||
def close_window():
|
||||
closed.append(True)
|
||||
|
||||
state = CacheItemsStates(Munch(
|
||||
game=FakeGame(), window=window, inv={}, item_lock=False,
|
||||
look_at=None))
|
||||
state.current_container_key = key
|
||||
state.is_labeled_container = True
|
||||
|
||||
state.move_items()
|
||||
|
||||
self.assertIn(key, state.useless_chests)
|
||||
self.assertTrue(state.container_was_full_on_open)
|
||||
self.assertEqual(closed, [True])
|
||||
|
||||
def test_chest_filled_by_this_cache_round_is_not_blacklisted(self):
|
||||
position = (5, 64, 0)
|
||||
key = (position,)
|
||||
item_id = items.get_id('dirt')
|
||||
stack = Munch(present=True, item_id=item_id, item_count=16)
|
||||
window = Munch(container_slots=27, contents={
|
||||
**dict.fromkeys(range(27)), 27: stack,
|
||||
})
|
||||
clicks = []
|
||||
|
||||
class FakeGame:
|
||||
used = 26
|
||||
|
||||
@classmethod
|
||||
def count_window_slots(cls):
|
||||
return cls.used
|
||||
|
||||
@classmethod
|
||||
def click_window(cls, *_args):
|
||||
clicks.append(True)
|
||||
cls.used = 27
|
||||
window.contents[27] = Munch(
|
||||
present=False, item_id=0, item_count=0)
|
||||
|
||||
@staticmethod
|
||||
def close_window():
|
||||
return None
|
||||
|
||||
state = CacheItemsStates(Munch(
|
||||
game=FakeGame(), window=window, inv={}, item_lock=False,
|
||||
look_at=None))
|
||||
state.current_container_key = key
|
||||
|
||||
state.move_items()
|
||||
self.assertFalse(state.container_was_full_on_open)
|
||||
self.assertEqual(clicks, [True])
|
||||
|
||||
state.pending_transfer['confirm_after'] = 0
|
||||
state.g.item_lock = False
|
||||
state.move_items()
|
||||
|
||||
self.assertNotIn(key, state.useless_chests)
|
||||
self.assertIs(state.state.__func__, state.cleanup.__func__)
|
||||
|
||||
def test_other_player_open_removes_chest_from_full_blacklist(self):
|
||||
position = (5, 64, 0)
|
||||
key = (position, (6, 64, 0))
|
||||
g = Munch(chest_open_events=[])
|
||||
state = CacheItemsStates(g)
|
||||
state.useless_chests.add(key)
|
||||
state.checked_labeled_chests.add(key)
|
||||
|
||||
g.chest_open_events.append({
|
||||
'position': (6, 64, 0), 'timestamp': 1.0,
|
||||
})
|
||||
state.run()
|
||||
|
||||
self.assertNotIn(key, state.useless_chests)
|
||||
self.assertNotIn(key, state.checked_labeled_chests)
|
||||
|
||||
def test_mutually_reachable_opening_is_skipped_after_path_failure(self):
|
||||
start = (0, 64, 0)
|
||||
first = (4, 64, 0)
|
||||
|
||||
Reference in new issue
Block a user