def test_get_building_position_raises_an_exception_if_the_unit_has_not_been_added_to_the_map(self): # noqa tmap = TileMap(TileGrid(Size(10, 10))) farm = CabbageFarm() with self.assertRaises(TileMapException) as error_context: tmap.get_building_position(farm) self.assertIn( 'That building has not been added to the tile map', error_context.exception.message, )
def test_place_building_on_grid_puts_a_building_onto_the_map_in_the_specified_grid_cell(self): # noqa tmap = TileMap(TileGrid(Size(10, 10)), tile_sz=Size(20, 20)) farm = CabbageFarm() tmap.place_building_on_grid(farm, Point(5, 5)) self.assertIn(farm.building_id, tmap.building_registry) self.assertEqual( tmap.get_building_position(farm), Point(5*20+0.5*20, 5*20+0.5*20), )
def test_place_building_puts_a_building_into_the_building_registry_at_the_given_position(self): # noqa tmap = TileMap(TileGrid(Size(10, 10))) farm = CabbageFarm() tmap.place_building(farm, Point(50, 50)) self.assertIn(farm.building_id, tmap.building_registry) self.assertEqual(tmap.get_building_position(farm), Point(50, 50))
def test_get_building_position_returns_the_location_of_a_building(self): tmap = TileMap(TileGrid(Size(10, 10))) farm = CabbageFarm() tmap.place_building(farm, Point(100, 100)) self.assertEqual(tmap.get_building_position(farm), Point(100, 100))