Public Repository for the Magicbane Shadowbane Emulator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.2 KiB

package engine.jobs;
import engine.gameManager.BuildingManager;
import engine.job.AbstractScheduleJob;
import engine.objects.Building;
import org.pmw.tinylog.Logger;
/*
* This class handles upgrading of buildings, swapping the
* appropriate mesh according to the building's blueprint.
* @Author
*/
public class UpgradeBuildingJob extends AbstractScheduleJob {
private final Building rankingBuilding;
public UpgradeBuildingJob(Building building) {
super();
this.rankingBuilding = building;
}
@Override
protected void doJob() {
// Must have a building to rank!
if (rankingBuilding == null) {
Logger.error("Attempting to rank null building");
return;
}
// Make sure the building is currently set to upgrade
// (Duplicate job sanity check)
if (rankingBuilding.isRanking() == false)
return;
// SetCurrentRank also changes the mesh and maxhp
// accordingly for buildings with blueprints
BuildingManager.setRank(rankingBuilding, rankingBuilding.getRank() + 1);
// Reload the object
}
@Override
protected void _cancelJob() {
}
}