MineColonies

MineColonies

57M Downloads

Related citizens can become partners

dupontct opened this issue ยท 0 comments

commented

I believe that the following code allows citizens that are related to one another to become partners. I am assuming that this is not intended functionality.

firstParent = assignedCitizens.get(random.nextInt(assignedCitizens.size()));
secondParent = firstParent.getPartner();
if (secondParent == null)
{
assignedCitizens.removeIf(cit -> cit.getPartner() != null || cit.getName().equals(firstParent.getName()));
if (assignedCitizens.size() > 0 && random.nextBoolean())
{
secondParent = assignedCitizens.get(random.nextInt(assignedCitizens.size()));
}
else
{
final BlockPos altPos = colony.getBuildingManager().getRandomBuilding(b -> b.hasModule(LivingBuildingModule.class) && !b.getPosition().equals(newHome.getPosition()) && BlockPosUtil.getDistance2D(b.getPosition(), newHome.getPosition()) < 50);
if (altPos != null)
{
final IBuilding building = colony.getBuildingManager().getBuilding(altPos);
final List<ICitizenData> newAssignedCitizens = building.getAssignedCitizen();
newAssignedCitizens.removeIf(cit -> cit.isChild() || cit.getPartner() != null && !cit.isRelatedTo(firstParent));
if (newAssignedCitizens.size() > 0)
{
secondParent = newAssignedCitizens.get(random.nextInt(newAssignedCitizens.size()));
}
}
}
}

Line 114:

assignedCitizens.removeIf(cit -> cit.getPartner() != null || cit.getName().equals(firstParent.getName()));

Doesn't exclude citizens related to the first parent form being chosen as the second parent.

and

Line 126:

newAssignedCitizens.removeIf(cit -> cit.isChild() || cit.getPartner() != null && !cit.isRelatedTo(firstParent));

This ensures that the citizen selected from the second house checked is related to the first parent or is already partnered with some other citizen?