Crash issue fix
This commit is contained in:
@@ -147,7 +147,9 @@ class EntityModel(
|
||||
|
||||
fun get(entity: String): EntityModel {
|
||||
if (_database == null) _database = EntityData.get().toMutableMap()
|
||||
return _database!![entity]!!
|
||||
return _database!![entity] ?: EntityModel(entity, "").apply {
|
||||
addPart(EntityInfoModel().apply { name = entity })
|
||||
}
|
||||
}
|
||||
|
||||
fun getList(): List<EntityModel> {
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
package ca.jonathanmccaffrey.igp.data.models.entity.data
|
||||
|
||||
import ca.jonathanmccaffrey.igp.data.models.entity.EntityModel
|
||||
import ca.jonathanmccaffrey.igp.data.models.entity.parts.EntityFactionModel
|
||||
import ca.jonathanmccaffrey.igp.data.models.entity.parts.EntityHarvestModel
|
||||
import ca.jonathanmccaffrey.igp.data.models.entity.parts.EntityInfoModel
|
||||
import ca.jonathanmccaffrey.igp.data.models.entity.parts.EntityProductionModel
|
||||
import ca.jonathanmccaffrey.igp.data.models.entity.parts.EntitySupplyModel
|
||||
import ca.jonathanmccaffrey.igp.data.models.entity.parts.EntityTierModel
|
||||
import ca.jonathanmccaffrey.igp.data.models.entity.types.DescriptiveType
|
||||
import ca.jonathanmccaffrey.igp.data.models.entity.types.ResourceType
|
||||
|
||||
object EntityData {
|
||||
private var _cache: Map<String, EntityModel>? = null
|
||||
|
||||
private fun getAbilityData(): Map<String, EntityModel> {
|
||||
// TODO: Convert from EntityData.Ability.cs - contains abilities like RadiantWard, Windstep, etc.
|
||||
return emptyMap()
|
||||
@@ -38,13 +48,101 @@ object EntityData {
|
||||
return emptyMap()
|
||||
}
|
||||
|
||||
private fun getEssentialEntities(): Map<String, EntityModel> {
|
||||
val bastion = EntityModel(IdsEntity.STARTING_Bastion, EntityType.Building).apply {
|
||||
addPart(EntityInfoModel().apply { name = "Bastion"; descriptive = DescriptiveType.Stronghold })
|
||||
addPart(EntityFactionModel().apply { faction = IdsEntity.FACTION_Neutral })
|
||||
addPart(EntityProductionModel().apply { buildTime = 0 })
|
||||
addPart(EntityTierModel())
|
||||
addPart(EntitySupplyModel().apply { grants = 20; takes = 0 })
|
||||
}
|
||||
|
||||
val townHallAru = EntityModel(IdsEntity.STARTING_TownHall_Aru, EntityType.Building).apply {
|
||||
addPart(EntityInfoModel().apply { name = "Town Hall (Aru)"; descriptive = DescriptiveType.TownHall_Starting })
|
||||
addPart(EntityFactionModel().apply { faction = IdsEntity.FACTION_Aru })
|
||||
addPart(EntityProductionModel().apply { buildTime = 0 })
|
||||
addPart(EntityTierModel())
|
||||
addPart(EntityHarvestModel().apply { slots = 0f; harvestedPerInterval = 0f })
|
||||
}
|
||||
|
||||
val townHallQRath = EntityModel(IdsEntity.STARTING_TownHall_QRath, EntityType.Building).apply {
|
||||
addPart(EntityInfoModel().apply { name = "Town Hall (QRath)"; descriptive = DescriptiveType.TownHall_Starting })
|
||||
addPart(EntityFactionModel().apply { faction = IdsEntity.FACTION_QRath })
|
||||
addPart(EntityProductionModel().apply { buildTime = 0 })
|
||||
addPart(EntityTierModel())
|
||||
addPart(EntityHarvestModel().apply { slots = 0f; harvestedPerInterval = 0f })
|
||||
}
|
||||
|
||||
val acropolis = EntityModel(IdsEntity.BUILDING_Acropolis, EntityType.Building).apply {
|
||||
addPart(EntityInfoModel().apply { name = "Acropolis"; descriptive = DescriptiveType.TownHall_Starting })
|
||||
addPart(EntityFactionModel().apply { faction = IdsEntity.FACTION_QRath })
|
||||
addPart(EntityProductionModel().apply { buildTime = 30 })
|
||||
addPart(EntityTierModel())
|
||||
addPart(EntitySupplyModel().apply { grants = 20; takes = 0 })
|
||||
}
|
||||
|
||||
val groveHeart = EntityModel(IdsEntity.BUILDING_GroveHeart, EntityType.Building).apply {
|
||||
addPart(EntityInfoModel().apply { name = "Grove Heart"; descriptive = DescriptiveType.TownHall_Starting })
|
||||
addPart(EntityFactionModel().apply { faction = IdsEntity.FACTION_Aru })
|
||||
addPart(EntityProductionModel().apply { buildTime = 30 })
|
||||
addPart(EntityTierModel())
|
||||
addPart(EntitySupplyModel().apply { grants = 20; takes = 0 })
|
||||
}
|
||||
|
||||
val mining2QRath = EntityModel(IdsEntity.BUPGRADE_MiningLevel2_QRath, EntityType.Building_Upgrade).apply {
|
||||
addPart(EntityInfoModel().apply { name = "Mining Level 2 (QRath)"; descriptive = DescriptiveType.Upgrade })
|
||||
addPart(EntityFactionModel().apply { faction = IdsEntity.FACTION_QRath })
|
||||
addPart(EntityProductionModel().apply { buildTime = 10; alloy = 25; ether = 25 })
|
||||
addPart(EntityTierModel())
|
||||
}
|
||||
|
||||
val mining2Aru = EntityModel(IdsEntity.BUPGRADE_MiningLevel2_Aru, EntityType.Building_Upgrade).apply {
|
||||
addPart(EntityInfoModel().apply { name = "Mining Level 2 (Aru)"; descriptive = DescriptiveType.Upgrade })
|
||||
addPart(EntityFactionModel().apply { faction = IdsEntity.FACTION_Aru })
|
||||
addPart(EntityProductionModel().apply { buildTime = 10; alloy = 25; ether = 25 })
|
||||
addPart(EntityTierModel())
|
||||
}
|
||||
|
||||
val workerMote = EntityModel(IdsEntity.WORKER_Mote, EntityType.Army).apply {
|
||||
addPart(EntityInfoModel().apply { name = "Mote"; descriptive = DescriptiveType.Worker })
|
||||
addPart(EntityFactionModel().apply { faction = IdsEntity.FACTION_Aru })
|
||||
addPart(EntityProductionModel().apply { buildTime = 8; alloy = 2.5f.toInt() })
|
||||
addPart(EntityTierModel())
|
||||
addPart(EntityHarvestModel().apply { resource = ResourceType.Alloy; slots = 1f; harvestedPerInterval = 2f; requiresWorker = true; totalAmount = 9999 })
|
||||
}
|
||||
|
||||
val workerSymbiote = EntityModel(IdsEntity.WORKER_Symbiote, EntityType.Army).apply {
|
||||
addPart(EntityInfoModel().apply { name = "Symbiote"; descriptive = DescriptiveType.Worker })
|
||||
addPart(EntityFactionModel().apply { faction = IdsEntity.FACTION_QRath })
|
||||
addPart(EntityProductionModel().apply { buildTime = 8; alloy = 2.5f.toInt() })
|
||||
addPart(EntityTierModel())
|
||||
addPart(EntityHarvestModel().apply { resource = ResourceType.Alloy; slots = 1f; harvestedPerInterval = 2f; requiresWorker = true; totalAmount = 9999 })
|
||||
}
|
||||
|
||||
return mapOf(
|
||||
IdsEntity.STARTING_Bastion to bastion,
|
||||
IdsEntity.STARTING_TownHall_Aru to townHallAru,
|
||||
IdsEntity.STARTING_TownHall_QRath to townHallQRath,
|
||||
IdsEntity.BUILDING_Acropolis to acropolis,
|
||||
IdsEntity.BUILDING_GroveHeart to groveHeart,
|
||||
IdsEntity.BUPGRADE_MiningLevel2_QRath to mining2QRath,
|
||||
IdsEntity.BUPGRADE_MiningLevel2_Aru to mining2Aru,
|
||||
IdsEntity.WORKER_Mote to workerMote,
|
||||
IdsEntity.WORKER_Symbiote to workerSymbiote
|
||||
)
|
||||
}
|
||||
|
||||
fun get(): Map<String, EntityModel> {
|
||||
return getResearchData() +
|
||||
if (_cache == null) {
|
||||
_cache = getResearchData() +
|
||||
getArmyData() +
|
||||
getAbilityData() +
|
||||
getMiscData() +
|
||||
getImmortalData() +
|
||||
getBuildingData() +
|
||||
getPassiveData()
|
||||
getPassiveData() +
|
||||
getEssentialEntities()
|
||||
}
|
||||
return _cache!!
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -190,7 +190,7 @@ class EconomyComparisonService : IEconomyComparisonService {
|
||||
|
||||
if (buildOrder.startedOrders.containsKey(interval)) {
|
||||
for (order in buildOrder.startedOrders[interval]!!) {
|
||||
val foundEntity = EntityModel.getDictionary()[order.dataType]!!
|
||||
val foundEntity = EntityModel.getDictionary()[order.dataType] ?: order
|
||||
val production = foundEntity.production()
|
||||
if (production != null) {
|
||||
economyAtSecond.alloy -= production.alloy
|
||||
|
||||
Reference in New Issue
Block a user