/// Check if we can walk on the point if it is completely covered in terrain boost::test_tools::predicate_result checkWalkOnPoint(GameWorldGame& world, const MapPoint& startPt, const MapPoint& targetPt, Direction dir, TerrainType t) { // Block whole point const MapPoint nextPt = world.GetNeighbour(startPt, dir); for(unsigned i=0; i<6; i++) SetRightTerrain(world, nextPt, Direction::fromInt(i), t); if(world.FindHumanPath(startPt, targetPt) != INVALID_DIR) { boost::test_tools::predicate_result result(false); result.message() << "Failed for fwd direction"; return result; } if(world.FindHumanPath(targetPt, startPt) != INVALID_DIR) { boost::test_tools::predicate_result result(false); result.message() << "Failed for bwd direction"; return result; } for(unsigned i = 0; i < 6; i++) SetRightTerrain(world, nextPt, Direction::fromInt(i), TT_STEPPE); return true; }
/// Check if we can walk if on of the 2 or both surrounding terrains is changed boost::test_tools::predicate_result checkWalkOnTerrain(GameWorldGame& world, const MapPoint& startPt, const MapPoint& targetPt, Direction dir, TerrainType t, bool isWalkable) { // Block either side SetRightTerrain(world, startPt, dir, t); if((world.FindHumanPath(startPt, targetPt) != INVALID_DIR) != isWalkable) { boost::test_tools::predicate_result result(false); result.message() << "Failed for right terrain"; return result; } if((world.FindHumanPath(targetPt, startPt) != INVALID_DIR) != isWalkable) { boost::test_tools::predicate_result result(false); result.message() << "Failed for right terrain2"; return result; } SetRightTerrain(world, startPt, dir, TT_STEPPE); SetLeftTerrain(world, startPt, dir, t); if((world.FindHumanPath(startPt, targetPt) != INVALID_DIR) != isWalkable) { boost::test_tools::predicate_result result(false); result.message() << "Failed for left terrain"; return result; } if((world.FindHumanPath(targetPt, startPt) != INVALID_DIR) != isWalkable) { boost::test_tools::predicate_result result(false); result.message() << "Failed for left terrain2"; return result; } SetRightTerrain(world, startPt, dir, t); if((world.FindHumanPath(startPt, targetPt) != INVALID_DIR) != isWalkable) { boost::test_tools::predicate_result result(false); result.message() << "Failed for both terrain"; return result; } if((world.FindHumanPath(targetPt, startPt) != INVALID_DIR) != isWalkable) { boost::test_tools::predicate_result result(false); result.message() << "Failed for both terrain2"; return result; } SetRightTerrain(world, startPt, dir, TT_STEPPE); SetLeftTerrain(world, startPt, dir, TT_STEPPE); return true; }