Add sign-labeled chest storage
This commit is contained in:
@@ -8,6 +8,14 @@ from mosfet.jobs.grab_supplies import GrabSuppliesStates
|
||||
class GroundSupplyTests(unittest.TestCase):
|
||||
def test_default_needed_supplies_are_configured_by_constructor(self):
|
||||
state = GrabSuppliesStates(Munch())
|
||||
self.assertEqual(items.FOOD, [
|
||||
'cooked_porkchop', 'cooked_beef', 'bread', 'cooked_chicken',
|
||||
'cooked_cod', 'cooked_salmon',
|
||||
])
|
||||
self.assertEqual(items.FOOD_IDS, items.get_set({
|
||||
'cooked_porkchop', 'cooked_beef', 'bread', 'cooked_chicken',
|
||||
'cooked_cod', 'cooked_salmon',
|
||||
}))
|
||||
self.assertEqual(state.supplies, {
|
||||
tuple(items.BED_IDS): (1, 1),
|
||||
(items.CHEST_ID,): (1, 1),
|
||||
@@ -44,19 +52,50 @@ class GroundSupplyTests(unittest.TestCase):
|
||||
self.assertEqual(state.target_items, (items.CHEST_ID,))
|
||||
self.assertIs(state.state.__func__, state.find_ground_items.__func__)
|
||||
|
||||
def test_unreachable_barrel_ends_supply_task_without_trying_more(self):
|
||||
def test_supply_selection_uses_only_addressed_supply_chests(self):
|
||||
position = (4, 64, 0)
|
||||
chest_record = {
|
||||
'position': position,
|
||||
'positions': (position,),
|
||||
'labels': {'mosfet supplies'},
|
||||
'sign_positions': {(4, 64, 1)},
|
||||
}
|
||||
|
||||
class FakeWorld:
|
||||
@staticmethod
|
||||
def path_to_place_faked(_start, _barrel):
|
||||
return None
|
||||
def find_supply_chests(_center, _bot_name, _distance):
|
||||
return [chest_record]
|
||||
|
||||
@staticmethod
|
||||
def find_blocks_indexed(*_args):
|
||||
raise AssertionError('grab_supplies must not search barrels')
|
||||
|
||||
state = GrabSuppliesStates(Munch(
|
||||
name='mosfet1', pos=(0.5, 64.0, 0.5), world=FakeWorld()))
|
||||
state.find_supply_chests()
|
||||
state.choose_supply_chest()
|
||||
|
||||
self.assertEqual(state.chest, position)
|
||||
self.assertIs(state.state.__func__, state.path_to_supply_chest.__func__)
|
||||
|
||||
def test_unreachable_supply_chest_ends_task_without_searching_barrels(self):
|
||||
class FakeWorld:
|
||||
@staticmethod
|
||||
def path_to_place_faked(_start, _chest):
|
||||
return None
|
||||
|
||||
position = (10, 64, 10)
|
||||
state = GrabSuppliesStates(Munch(
|
||||
pos=(0.5, 64.0, 0.5), world=FakeWorld(), chunks=Munch()))
|
||||
state.barrel = (10, 64, 10)
|
||||
state.path_to_barrel()
|
||||
state.supply_chests = [{
|
||||
'position': position, 'positions': (position,),
|
||||
'labels': {'mosfet supplies'},
|
||||
}]
|
||||
state.choose_supply_chest()
|
||||
state.path_to_supply_chest()
|
||||
state.choose_supply_chest()
|
||||
|
||||
self.assertIs(state.state.__func__, state.cleanup.__func__)
|
||||
self.assertEqual(state.bad_barrels, [(10, 64, 10)])
|
||||
|
||||
def test_job_walks_to_and_picks_up_dropped_supply_before_barrels(self):
|
||||
axe_id = next(iter(items.AXE_IDS))
|
||||
|
||||
Reference in New Issue
Block a user