Allow bot names 1-9 instead of 1-3
This commit is contained in:
1 parent
fb28fefc8a
commit
1dd02f887c
9 files changed
+75
-48
No files matched your search
@@ -41,6 +41,13 @@ class TestInventoryCommands(unittest.TestCase):
|
||||
self.commands.handle_chat(('CHAT', 'tester', 'mosfet1: 1drop'))
|
||||
self.assertEqual(self.chat.sent, ['ok'])
|
||||
|
||||
def test_command_prefix_uses_the_ninth_bot_number(self):
|
||||
self.commands.g.name = 'mosfet9'
|
||||
|
||||
self.commands.handle_chat(('CHAT', 'tester', 'mosfet9: 9drop'))
|
||||
|
||||
self.assertEqual(self.chat.sent, ['ok'])
|
||||
|
||||
def test_dump_command_starts_dump_for_item_id(self):
|
||||
self.commands.handle_chat(('CHAT', 'tester', 'mosfet1: 1dump 62'))
|
||||
self.assertEqual(self.game.dump_item, 62)
|
||||
|
||||
@@ -5,11 +5,13 @@ from mosfet import utils
|
||||
|
||||
|
||||
class NearbyBotTests(unittest.TestCase):
|
||||
def test_family_removes_every_digit(self):
|
||||
self.assertEqual(utils.bot_name_family('foo1'), 'foo')
|
||||
self.assertEqual(utils.bot_name_family('foo2'), 'foo')
|
||||
self.assertEqual(utils.bot_name_family('bar1'), 'bar')
|
||||
self.assertEqual(utils.bot_name_family('bar123'), 'bar')
|
||||
def test_family_strips_only_a_valid_single_digit_suffix(self):
|
||||
for suffix in range(1, 10):
|
||||
self.assertEqual(
|
||||
utils.bot_name_family('foo{}'.format(suffix)), 'foo')
|
||||
self.assertEqual(utils.bot_name_family('FOO9'), 'foo')
|
||||
self.assertEqual(utils.bot_name_family('bar123'), 'bar12')
|
||||
self.assertEqual(utils.bot_name_family('foo10'), 'foo10')
|
||||
|
||||
def test_finds_only_nearby_other_bots_in_same_name_family(self):
|
||||
global_state = Munch(
|
||||
@@ -22,7 +24,7 @@ class NearbyBotTests(unittest.TestCase):
|
||||
},
|
||||
player_names={
|
||||
'self': 'bar1',
|
||||
'bar-uuid': 'bar123',
|
||||
'bar-uuid': 'bar9',
|
||||
'foo-uuid': 'foo2',
|
||||
'far-uuid': 'bar2',
|
||||
})
|
||||
@@ -30,12 +32,12 @@ class NearbyBotTests(unittest.TestCase):
|
||||
nearby = utils.find_nearby_bots(
|
||||
global_state, (0, 64, 0), 4)
|
||||
|
||||
self.assertEqual([bot['name'] for bot in nearby], ['bar123'])
|
||||
self.assertEqual([bot['name'] for bot in nearby], ['bar9'])
|
||||
self.assertEqual(nearby[0]['distance'], 3.0)
|
||||
|
||||
def test_returns_no_matches_without_a_bot_name_family(self):
|
||||
self.assertEqual(utils.find_nearby_bots(
|
||||
Munch(name='123', players={}, player_names={}),
|
||||
Munch(name='', players={}, player_names={}),
|
||||
(0, 64, 0), 4), [])
|
||||
|
||||
|
||||
|
||||
@@ -48,8 +48,10 @@ class SafetySignTests(unittest.TestCase):
|
||||
self.assertEqual(bot2[1]['normal'], (-1.0, 0.0, 0.0))
|
||||
self.assertEqual([sign['position'] for sign in world.find_safety_signs(
|
||||
(0, 64, 0), 'mosfet1', 10)], [group_sign])
|
||||
self.assertEqual([sign['position'] for sign in world.find_safety_signs(
|
||||
(0, 64, 0), 'mosfet9', 10)], [group_sign])
|
||||
self.assertEqual(world.find_safety_signs(
|
||||
(0, 64, 0), 'mosfet4', 10), [])
|
||||
(0, 64, 0), 'mosfet10', 10), [])
|
||||
|
||||
def test_safety_openings_try_text_facing_standable_positions_first(self):
|
||||
sign_pos = (0, 64, 0)
|
||||
|
||||
+34
-2
@@ -93,10 +93,11 @@ class SignReadingTests(unittest.TestCase):
|
||||
'mosfet', 'stay within25', 'square', '',
|
||||
]}}},
|
||||
}), pos=(0, 64, 0)))
|
||||
for bot_name in ('mosfet1', 'mosfet2', 'mosfet3'):
|
||||
for bot_num in range(1, 10):
|
||||
bot_name = 'mosfet{}'.format(bot_num)
|
||||
self.assertEqual([p['shape'] for p in
|
||||
group_world.sign_policies(bot_name)], ['square'])
|
||||
self.assertEqual(group_world.sign_policies('mosfet4'), [])
|
||||
self.assertEqual(group_world.sign_policies('mosfet10'), [])
|
||||
|
||||
individual_world = World(Munch(chunks=Munch(block_entities={
|
||||
(1, 64, 0): {'data': {'front_text': {'messages': [
|
||||
@@ -131,6 +132,37 @@ class SignReadingTests(unittest.TestCase):
|
||||
world.find_sand_origins((0, 64, 0), 'mosfet2')],
|
||||
[(1, 64, 0), (2, 64, 0)],
|
||||
)
|
||||
self.assertEqual(
|
||||
[origin['position'] for origin in
|
||||
world.find_sand_origins((0, 64, 0), 'mosfet9')],
|
||||
[(1, 64, 0)],
|
||||
)
|
||||
self.assertEqual(
|
||||
world.find_sand_origins((0, 64, 0), 'mosfet10'), [])
|
||||
|
||||
def test_supply_sign_group_address_includes_bot_nine_only(self):
|
||||
sign_pos = (0, 64, 0)
|
||||
chest_pos = (1, 64, 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')
|
||||
block_states = {sign_pos: sign_state, chest_pos: chest_state}
|
||||
chunks = Munch(
|
||||
block_entities={sign_pos: {'data': {'front_text': {
|
||||
'messages': ['mosfet supplies', '', '', ''],
|
||||
}}}},
|
||||
index={},
|
||||
get_block_at=lambda *pos: block_states.get(tuple(pos), blocks.AIR),
|
||||
)
|
||||
world = World(Munch(chunks=chunks))
|
||||
|
||||
supplies = world.find_supply_chests(sign_pos, 'mosfet9', 10)
|
||||
|
||||
self.assertEqual(len(supplies), 1)
|
||||
self.assertEqual(supplies[0]['positions'], (chest_pos,))
|
||||
self.assertEqual(world.find_supply_chests(
|
||||
sign_pos, 'mosfet10', 10), [])
|
||||
|
||||
def test_sign_policies_read_any_distance_within_loaded_signs(self):
|
||||
position = (100, 64, 0)
|
||||
|
||||
@@ -99,7 +99,9 @@ class StorageLabelTests(unittest.TestCase):
|
||||
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), [])
|
||||
sign_pos, 'mosfet9', 10), group_caches)
|
||||
self.assertEqual(world.find_cache_chests(
|
||||
sign_pos, 'mosfet10', 10), [])
|
||||
|
||||
def test_side_chest_takes_priority_over_chest_below_sign(self):
|
||||
sign_pos = (0, 64, 0)
|
||||
|
||||
@@ -64,6 +64,10 @@ class ThrowSignTests(unittest.TestCase):
|
||||
|
||||
bot1 = world.find_throw_signs((0, 64, 0), 'mosfet1', 10)
|
||||
self.assertEqual([sign['position'] for sign in bot1], [group_sign])
|
||||
bot9 = world.find_throw_signs((0, 64, 0), 'mosfet9', 10)
|
||||
self.assertEqual([sign['position'] for sign in bot9], [group_sign])
|
||||
self.assertEqual(world.find_throw_signs(
|
||||
(0, 64, 0), 'mosfet10', 10), [])
|
||||
|
||||
def test_throw_accepts_unqualified_items_and_species_log_labels(self):
|
||||
single_item_sign = (0, 64, 0)
|
||||
|
||||
Reference in new issue
Block a user