Interface KonquestUpgradeManager
public interface KonquestUpgradeManager
A manager for town upgrades in Konquest.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
applyTownUpgrade
(KonquestTown town, KonquestUpgrade upgrade, int level) Apply the given upgrade and level to the given town.Provides a list of upgrades available for purchase for the given town.int
getTownUpgradeLevel
(KonquestTown town, KonquestUpgrade upgrade) Gets the current upgrade level of the given town.int
getUpgradeCost
(KonquestUpgrade upgrade, int level) Gets the cost in favor of the given upgrade and level.int
getUpgradePopulation
(KonquestUpgrade upgrade, int level) Gets the population requirement of the given upgrade and level.boolean
Check whether town upgrades are enabled from the Konquest configuration.
-
Method Details
-
isEnabled
boolean isEnabled()Check whether town upgrades are enabled from the Konquest configuration.- Returns:
- True when upgrades are enabled, else false
-
getAvailableUpgrades
Provides a list of upgrades available for purchase for the given town. Checks for valid cost and level requirements. Upgrade levels will not be listed if cost is less than 0 (e.g. -1).- Parameters:
town
- The town to search for available upgrades- Returns:
- A map of available upgrades and their levels
-
getUpgradeCost
Gets the cost in favor of the given upgrade and level. The given level must be greater than 0 and less than or equal to the upgrade's max level. Upgrade costs are pulled from Konquest configuration.- Parameters:
upgrade
- The upgradelevel
- The level of the given upgrade- Returns:
- The cost in favor, or -1 when level is not valid
-
getUpgradePopulation
Gets the population requirement of the given upgrade and level. The given level must be greater than 0 and less than or equal to the upgrade's max level. Upgrade populations are pulled from Konquest configuration.- Parameters:
upgrade
- The upgradelevel
- The level of the given upgrade- Returns:
- The population, or 0 when level is not valid
-
getTownUpgradeLevel
Gets the current upgrade level of the given town. Returns 0 if the town does not have the upgrade.- Parameters:
town
- The town to checkupgrade
- The upgrade- Returns:
- The level of the upgrade, or 0 if the upgrade is not applied
-
applyTownUpgrade
Apply the given upgrade and level to the given town. The given level must be greater than or equal to 0 and less than or equal to the upgrade's max level. Applying a level of 0 will remove the upgrade. The upgrade feature must be enabled in the Konquest configuration.- Parameters:
town
- The town to upgradeupgrade
- The upgrade to applylevel
- The level of the upgrade- Returns:
- True when the upgrade is applied successfully, else false
-