43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
import unittest
|
|
from munch import Munch
|
|
|
|
from mosfet.info import blocks
|
|
from mosfet.world import BedArea, World
|
|
|
|
|
|
class BedWorldTests(unittest.TestCase):
|
|
def make_world(self, supported):
|
|
class GridChunks:
|
|
def get_block_at(self, x, y, z):
|
|
if y == 63 and (x, y, z) in supported:
|
|
return blocks.STONE
|
|
return blocks.AIR
|
|
|
|
return World(Munch(chunks=GridChunks(), mobs={}))
|
|
|
|
def test_bed_areas_require_standing_and_two_bed_tiles(self):
|
|
supported = {(x, 63, 0) for x in (1, 2, 3)}
|
|
world = self.make_world(supported)
|
|
|
|
layouts = list(world.find_bed_areas(
|
|
(0, 64, 0), 4, include_layout=True))
|
|
|
|
self.assertIn(BedArea(
|
|
foot=(2, 64, 0), head=(3, 64, 0),
|
|
opening=(1, 64, 0), facing=(1, 0, 0)), layouts)
|
|
self.assertIn((1, 64, 0), list(world.find_bed_areas((0, 64, 0), 4)))
|
|
|
|
def test_bed_lane_is_rejected_without_third_supported_block(self):
|
|
supported = {(1, 63, 0), (2, 63, 0)}
|
|
world = self.make_world(supported)
|
|
|
|
layouts = list(world.find_bed_areas(
|
|
(0, 64, 0), 4, include_layout=True))
|
|
|
|
self.assertFalse(any(
|
|
layout.opening == (1, 64, 0) for layout in layouts))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|