use of com.minecolonies.coremod.colony.jobs.JobCombatTraining in project minecolonies by Minecolonies.
the class GuardBuildingModule method onColonyTick.
@Override
public void onColonyTick(@NotNull final IColony colony) {
// Give the other assignment module also a chance.
if (random.nextInt(building.getModules(GuardBuildingModule.class).size()) > 0) {
return;
}
boolean hiredFromTraining = false;
// If we have no active worker, attempt to grab one from the appropriate trainer
if (building.getSetting(HIRE_TRAINEE).getValue() && !isFull() && ((building.getBuildingLevel() > 0 && building.isBuilt())) && ((this.getHiringMode() == HiringMode.DEFAULT && !building.getColony().isManualHiring()) || this.getHiringMode() == HiringMode.AUTO)) {
ICitizenData trainingCitizen = null;
int maxSkill = 0;
for (ICitizenData trainee : colony.getCitizenManager().getCitizens()) {
if ((getJobEntry() == ModJobs.archer && trainee.getJob() instanceof JobArcherTraining || getJobEntry() == ModJobs.knight && trainee.getJob() instanceof JobCombatTraining) && trainee.getCitizenSkillHandler().getLevel(getPrimarySkill()) > maxSkill) {
maxSkill = trainee.getCitizenSkillHandler().getLevel(getPrimarySkill());
trainingCitizen = trainee;
}
}
if (trainingCitizen != null) {
hiredFromTraining = true;
assignCitizen(trainingCitizen);
}
}
// If we hired, we may have more than one to hire, so let's skip the superclass until next time.
if (!hiredFromTraining) {
super.onColonyTick(colony);
}
}
use of com.minecolonies.coremod.colony.jobs.JobCombatTraining in project minecolonies by ldtteam.
the class GuardBuildingModule method onColonyTick.
@Override
public void onColonyTick(@NotNull final IColony colony) {
// Give the other assignment module also a chance.
if (random.nextInt(building.getModules(GuardBuildingModule.class).size()) > 0) {
return;
}
boolean hiredFromTraining = false;
// If we have no active worker, attempt to grab one from the appropriate trainer
if (building.getSetting(HIRE_TRAINEE).getValue() && !isFull() && ((building.getBuildingLevel() > 0 && building.isBuilt())) && (this.getHiringMode() == HiringMode.DEFAULT && !building.getColony().isManualHiring() || this.getHiringMode() == HiringMode.AUTO)) {
ICitizenData trainingCitizen = null;
int maxSkill = 0;
for (ICitizenData trainee : colony.getCitizenManager().getCitizens()) {
if ((getJobEntry() == ModJobs.archer && trainee.getJob() instanceof JobArcherTraining) || (getJobEntry() == ModJobs.knight && trainee.getJob() instanceof JobCombatTraining) && trainee.getCitizenSkillHandler().getLevel(getPrimarySkill()) > maxSkill) {
maxSkill = trainee.getCitizenSkillHandler().getLevel(getPrimarySkill());
trainingCitizen = trainee;
}
}
if (trainingCitizen != null) {
hiredFromTraining = true;
assignCitizen(trainingCitizen);
}
}
// If we hired, we may have more than one to hire, so let's skip the superclass until next time.
if (!hiredFromTraining) {
super.onColonyTick(colony);
}
}
Aggregations