Cache after sleep near labeled chests
This commit is contained in:
@@ -46,6 +46,112 @@ class CacheItemsTests(unittest.TestCase):
|
||||
finally:
|
||||
items.WANTED_ITEMS = old_wanted
|
||||
|
||||
def test_post_sleep_halves_threshold_only_with_compatible_nearby_chest(self):
|
||||
bed = (0, 64, 0)
|
||||
chest_position = (5, 64, 0)
|
||||
item_id = items.get_id('stone')
|
||||
|
||||
class FakeGame:
|
||||
@staticmethod
|
||||
def count_inventory_slots():
|
||||
return 14
|
||||
|
||||
class NearbyWorld:
|
||||
@staticmethod
|
||||
def find_labeled_chests(_center, _distance):
|
||||
return [{
|
||||
'position': chest_position,
|
||||
'positions': (chest_position,),
|
||||
'item_ids': {item_id},
|
||||
}]
|
||||
|
||||
g = Munch(
|
||||
game=FakeGame(), world=NearbyWorld(),
|
||||
minimum_cache_slots=27, post_sleep_cache_bed=bed,
|
||||
inv={9: Munch(present=True, item_id=item_id, item_count=64)})
|
||||
state = CacheItemsStates(g)
|
||||
|
||||
state.init()
|
||||
|
||||
self.assertIs(state.state.__func__, state.find_trapped_chests.__func__)
|
||||
self.assertNotIn('post_sleep_cache_bed', g)
|
||||
|
||||
def test_post_sleep_threshold_rounds_27_up_to_14(self):
|
||||
bed = (0, 64, 0)
|
||||
item_id = items.get_id('stone')
|
||||
|
||||
class FakeGame:
|
||||
@staticmethod
|
||||
def count_inventory_slots():
|
||||
return 13
|
||||
|
||||
class NearbyWorld:
|
||||
@staticmethod
|
||||
def find_labeled_chests(_center, _distance):
|
||||
return [{
|
||||
'position': (5, 64, 0),
|
||||
'positions': ((5, 64, 0),),
|
||||
'item_ids': {item_id},
|
||||
}]
|
||||
|
||||
g = Munch(
|
||||
game=FakeGame(), world=NearbyWorld(), minimum_cache_slots=27,
|
||||
post_sleep_cache_bed=bed,
|
||||
inv={9: Munch(present=True, item_id=item_id, item_count=64)})
|
||||
state = CacheItemsStates(g)
|
||||
|
||||
state.init()
|
||||
|
||||
self.assertIs(state.state.__func__, state.cleanup.__func__)
|
||||
|
||||
def test_post_sleep_does_not_lower_threshold_without_compatible_nearby_chest(self):
|
||||
class FakeGame:
|
||||
@staticmethod
|
||||
def count_inventory_slots():
|
||||
return 14
|
||||
|
||||
class EmptyWorld:
|
||||
@staticmethod
|
||||
def find_labeled_chests(_center, _distance):
|
||||
return []
|
||||
|
||||
g = Munch(
|
||||
game=FakeGame(), world=EmptyWorld(), minimum_cache_slots=27,
|
||||
post_sleep_cache_bed=(0, 64, 0), inv={})
|
||||
state = CacheItemsStates(g)
|
||||
|
||||
state.init()
|
||||
|
||||
self.assertIs(state.state.__func__, state.cleanup.__func__)
|
||||
self.assertNotIn('post_sleep_cache_bed', g)
|
||||
|
||||
def test_post_sleep_ignores_compatible_chest_beyond_16_blocks(self):
|
||||
item_id = items.get_id('stone')
|
||||
|
||||
class FakeGame:
|
||||
@staticmethod
|
||||
def count_inventory_slots():
|
||||
return 14
|
||||
|
||||
class FarWorld:
|
||||
@staticmethod
|
||||
def find_labeled_chests(_center, _distance):
|
||||
position = (17, 64, 0)
|
||||
return [{
|
||||
'position': position,
|
||||
'positions': (position,),
|
||||
'item_ids': {item_id},
|
||||
}]
|
||||
|
||||
state = CacheItemsStates(Munch(
|
||||
game=FakeGame(), world=FarWorld(), minimum_cache_slots=27,
|
||||
post_sleep_cache_bed=(0, 64, 0),
|
||||
inv={9: Munch(present=True, item_id=item_id, item_count=64)}))
|
||||
|
||||
state.init()
|
||||
|
||||
self.assertIs(state.state.__func__, state.cleanup.__func__)
|
||||
|
||||
def test_manual_cache_threshold_override_is_consumed_once(self):
|
||||
class FakeGame:
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user