Add signed general cache destinations
This commit is contained in:
1 parent
11c1bad0c4
commit
86fbf911a5
7 files changed
+305
-114
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import unittest
|
||||
from munch import Munch
|
||||
|
||||
from mosfet.info import items
|
||||
from mosfet.info import blocks, items
|
||||
from mosfet.world import World
|
||||
|
||||
|
||||
@@ -60,6 +60,72 @@ class StorageLabelTests(unittest.TestCase):
|
||||
self.assertIn(items.WHEAT_SEEDS_ID, chests[0]['item_ids'])
|
||||
self.assertEqual(chests[0]['labels'], {'Seeds'})
|
||||
|
||||
def test_general_cache_sign_matches_bot_group_and_prefers_side_chest(self):
|
||||
sign_pos = (0, 64, 0)
|
||||
side_chest = (1, 64, 0)
|
||||
chest_below = (0, 63, 0)
|
||||
sign_state = blocks.MCD_BLOCKS['oak_wall_sign']['minStateId']
|
||||
chest_state = next(
|
||||
state for state in blocks.CHEST_IDS
|
||||
if blocks.PROPS[state].get('type') == 'single')
|
||||
blocks_by_pos = {
|
||||
sign_pos: sign_state,
|
||||
side_chest: chest_state,
|
||||
chest_below: chest_state,
|
||||
}
|
||||
chunks = Munch(
|
||||
block_entities={sign_pos: {
|
||||
'type': 7,
|
||||
'data': {'front_text': {'messages': [
|
||||
'mosfet cache', '', '', '',
|
||||
]}},
|
||||
}},
|
||||
index={},
|
||||
get_block_at=lambda *pos: blocks_by_pos.get(tuple(pos)),
|
||||
)
|
||||
world = World(Munch(chunks=chunks))
|
||||
|
||||
group_caches = world.find_cache_chests(sign_pos, 'mosfet2', 10)
|
||||
|
||||
self.assertEqual(len(group_caches), 1)
|
||||
self.assertEqual(group_caches[0]['position'], side_chest)
|
||||
self.assertEqual(group_caches[0]['positions'], (side_chest,))
|
||||
self.assertEqual(world.find_cache_chests(
|
||||
sign_pos, 'mosfet4', 10), [])
|
||||
|
||||
def test_side_chest_takes_priority_over_chest_below_sign(self):
|
||||
sign_pos = (0, 64, 0)
|
||||
side_chest = (1, 64, 0)
|
||||
chest_below = (0, 63, 0)
|
||||
sign_state = blocks.MCD_BLOCKS['oak_wall_sign']['minStateId']
|
||||
chest_state = next(
|
||||
state for state in blocks.CHEST_IDS
|
||||
if blocks.PROPS[state].get('type') == 'single')
|
||||
blocks_by_pos = {
|
||||
sign_pos: sign_state,
|
||||
side_chest: chest_state,
|
||||
chest_below: chest_state,
|
||||
}
|
||||
chunks = Munch(
|
||||
block_entities={sign_pos: {
|
||||
'type': 7,
|
||||
'data': {'front_text': {'messages': [
|
||||
'Saplings', '', '', '',
|
||||
]}},
|
||||
}},
|
||||
index={},
|
||||
get_block_at=lambda *pos: blocks_by_pos.get(tuple(pos)),
|
||||
)
|
||||
|
||||
chests = World(Munch(chunks=chunks)).find_labeled_chests(
|
||||
sign_pos, 10)
|
||||
|
||||
self.assertEqual(len(chests), 1)
|
||||
self.assertEqual(chests[0]['position'], side_chest)
|
||||
self.assertEqual(chests[0]['positions'], (side_chest,))
|
||||
self.assertNotIn(chest_below, chests[0]['positions'])
|
||||
self.assertEqual(chests[0]['item_ids'], items.SAPLING_IDS)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user