Search in sources :

Example 1 with JobArcherTraining

use of com.minecolonies.coremod.colony.jobs.JobArcherTraining 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);
    }
}
Also used : JobArcherTraining(com.minecolonies.coremod.colony.jobs.JobArcherTraining) ICitizenData(com.minecolonies.api.colony.ICitizenData) JobCombatTraining(com.minecolonies.coremod.colony.jobs.JobCombatTraining)

Example 2 with JobArcherTraining

use of com.minecolonies.coremod.colony.jobs.JobArcherTraining 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);
    }
}
Also used : JobArcherTraining(com.minecolonies.coremod.colony.jobs.JobArcherTraining) ICitizenData(com.minecolonies.api.colony.ICitizenData) JobCombatTraining(com.minecolonies.coremod.colony.jobs.JobCombatTraining)

Aggregations

ICitizenData (com.minecolonies.api.colony.ICitizenData)2 JobArcherTraining (com.minecolonies.coremod.colony.jobs.JobArcherTraining)2 JobCombatTraining (com.minecolonies.coremod.colony.jobs.JobCombatTraining)2