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()
|
||||
@@ -65,6 +65,35 @@ class ThrowSignTests(unittest.TestCase):
|
||||
bot1 = world.find_throw_signs((0, 64, 0), 'mosfet1', 10)
|
||||
self.assertEqual([sign['position'] for sign in bot1], [group_sign])
|
||||
|
||||
def test_throw_accepts_unqualified_items_and_species_log_labels(self):
|
||||
single_item_sign = (0, 64, 0)
|
||||
oak_family_sign = (4, 64, 0)
|
||||
chunks = FakeChunks(
|
||||
block_entities={
|
||||
single_item_sign: {'data': {'front_text': {'messages': [
|
||||
'mosfet1 throw oak_log', '', '', '',
|
||||
]}}},
|
||||
oak_family_sign: {'data': {'front_text': {'messages': [
|
||||
'mosfet1 throw Oak Logs', '', '', '',
|
||||
]}}},
|
||||
},
|
||||
states={
|
||||
single_item_sign: wall_sign_state('north'),
|
||||
oak_family_sign: wall_sign_state('north'),
|
||||
})
|
||||
world = World(Munch(chunks=chunks))
|
||||
|
||||
directives = world.find_throw_signs((0, 64, 0), 'mosfet1', 10)
|
||||
exact = next(sign for sign in directives
|
||||
if sign['position'] == single_item_sign)
|
||||
family = next(sign for sign in directives
|
||||
if sign['position'] == oak_family_sign)
|
||||
|
||||
self.assertEqual(exact['item_ids'], {items.get_id('oak_log')})
|
||||
self.assertEqual(family['item_ids'], items.get_set({
|
||||
'oak_log', 'stripped_oak_log', 'oak_wood', 'stripped_oak_wood',
|
||||
}))
|
||||
|
||||
def test_back_text_uses_back_face_normal(self):
|
||||
position = (0, 64, 0)
|
||||
world = World(Munch(chunks=FakeChunks(
|
||||
|
||||
Reference in new issue
Block a user