|
6 | 6 | #include "PointOutput.h" |
7 | 7 | #include "RttrForeachPt.h" |
8 | 8 | #include "buildings/nobBaseMilitary.h" |
| 9 | +#include "buildings/nobUsual.h" |
| 10 | +#include "factories/BuildingFactory.h" |
| 11 | +#include "figures/nofFarmhand.h" |
| 12 | +#include "figures/nofFisher.h" |
| 13 | +#include "gameTypes/Resource.h" |
9 | 14 | #include "desktops/dskGameInterface.h" |
10 | 15 | #include "helpers/containerUtils.h" |
11 | 16 | #include "uiHelper/uiHelpers.hpp" |
12 | 17 | #include "worldFixtures/CreateEmptyWorld.h" |
13 | 18 | #include "worldFixtures/WorldFixture.h" |
| 19 | +#include "worldFixtures/terrainHelpers.h" |
14 | 20 | #include "world/GameWorldViewer.h" |
15 | 21 | #include "nodeObjs/noEnvObject.h" |
16 | 22 | #include "nodeObjs/noStaticObject.h" |
@@ -476,4 +482,45 @@ BOOST_FIXTURE_TEST_CASE(RoadRemovesObjs, EmptyWorldFixture1P) |
476 | 482 | } |
477 | 483 | } |
478 | 484 |
|
| 485 | + |
| 486 | +BOOST_FIXTURE_TEST_CASE(FisherIgnoresIsolatedFishWater, EmptyWorldFixture1PBiggest) |
| 487 | +{ |
| 488 | + const DescIdx<TerrainDesc> tWater = GetWaterTerrain(world.GetDescription()); |
| 489 | + |
| 490 | + const MapPoint fisheryPos = world.MakeMapPoint(world.GetPlayer(0).GetHQPos() - Position(6, 6)); |
| 491 | + auto* fishery = dynamic_cast<nobUsual*>( |
| 492 | + BuildingFactory::CreateBuilding(world, BuildingType::Fishery, fisheryPos, 0, Nation::Romans)); |
| 493 | + BOOST_TEST_REQUIRE(fishery); |
| 494 | + |
| 495 | + nofFisher fisher(fisheryPos, 0, fishery); |
| 496 | + const nofFarmhand& farmhand = fisher; |
| 497 | + |
| 498 | + const MapPoint workPt = world.MakeMapPoint(fisheryPos + Position(4, 0)); |
| 499 | + const MapPoint fishPt = world.GetNeighbour(workPt, Direction::East); |
| 500 | + |
| 501 | + auto makeWaterPoint = [&](const MapPoint pt) { |
| 502 | + MapNode& nwNode = world.GetNodeWriteable(world.GetNeighbour(pt, Direction::NorthWest)); |
| 503 | + MapNode& neNode = world.GetNodeWriteable(world.GetNeighbour(pt, Direction::NorthEast)); |
| 504 | + MapNode& curNode = world.GetNodeWriteable(pt); |
| 505 | + MapNode& wNode = world.GetNodeWriteable(world.GetNeighbour(pt, Direction::West)); |
| 506 | + |
| 507 | + nwNode.t1 = tWater; |
| 508 | + nwNode.t2 = tWater; |
| 509 | + neNode.t1 = tWater; |
| 510 | + curNode.t1 = tWater; |
| 511 | + curNode.t2 = tWater; |
| 512 | + wNode.t2 = tWater; |
| 513 | + }; |
| 514 | + |
| 515 | + makeWaterPoint(fishPt); |
| 516 | + world.SetResource(fishPt, Resource(ResourceType::Fish, 4)); |
| 517 | + |
| 518 | + BOOST_TEST_REQUIRE(static_cast<unsigned>(farmhand.GetPointQuality(workPt)) |
| 519 | + == static_cast<unsigned>(nofFarmhand::PointQuality::NotPossible)); |
| 520 | + |
| 521 | + makeWaterPoint(world.GetNeighbour(fishPt, Direction::East)); |
| 522 | + |
| 523 | + BOOST_TEST_REQUIRE(static_cast<unsigned>(farmhand.GetPointQuality(workPt)) |
| 524 | + == static_cast<unsigned>(nofFarmhand::PointQuality::Class1)); |
| 525 | +} |
479 | 526 | BOOST_AUTO_TEST_SUITE_END() |
0 commit comments