NationUnique is now removable whenever we want ;)

This commit is contained in:
Yair Morgenstern 2020-08-06 23:48:25 +03:00
parent 0a30e99359
commit f0b041b20b
14 changed files with 47 additions and 50 deletions

View file

@ -3,7 +3,6 @@ package com.unciv.logic.battle
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.unciv.Constants import com.unciv.Constants
import com.unciv.UncivGame import com.unciv.UncivGame
import com.unciv.UniqueAbility
import com.unciv.logic.city.CityInfo import com.unciv.logic.city.CityInfo
import com.unciv.logic.civilization.AlertType import com.unciv.logic.civilization.AlertType
import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.CivilizationInfo

View file

@ -1,7 +1,6 @@
package com.unciv.logic.battle package com.unciv.logic.battle
import com.unciv.Constants import com.unciv.Constants
import com.unciv.UniqueAbility
import com.unciv.logic.map.MapUnit import com.unciv.logic.map.MapUnit
import com.unciv.logic.map.TileInfo import com.unciv.logic.map.TileInfo
import com.unciv.models.ruleset.unit.UnitType import com.unciv.models.ruleset.unit.UnitType

View file

@ -1,7 +1,6 @@
package com.unciv.logic.city package com.unciv.logic.city
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.unciv.UniqueAbility
import com.unciv.logic.automation.Automation import com.unciv.logic.automation.Automation
import com.unciv.logic.map.TileInfo import com.unciv.logic.map.TileInfo
import com.unciv.ui.utils.withItem import com.unciv.ui.utils.withItem

View file

@ -4,7 +4,6 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.math.Vector2 import com.badlogic.gdx.math.Vector2
import com.unciv.Constants import com.unciv.Constants
import com.unciv.UncivGame import com.unciv.UncivGame
import com.unciv.UniqueAbility
import com.unciv.logic.battle.Battle import com.unciv.logic.battle.Battle
import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.civilization.diplomacy.DiplomacyFlags import com.unciv.logic.civilization.diplomacy.DiplomacyFlags
@ -27,7 +26,10 @@ import com.unciv.ui.utils.withoutItem
import java.util.* import java.util.*
import kotlin.collections.HashMap import kotlin.collections.HashMap
import kotlin.collections.HashSet import kotlin.collections.HashSet
import kotlin.math.* import kotlin.math.ceil
import kotlin.math.max
import kotlin.math.min
import kotlin.math.roundToInt
class CityInfo { class CityInfo {
@Transient lateinit var civInfo: CivilizationInfo @Transient lateinit var civInfo: CivilizationInfo

View file

@ -2,7 +2,6 @@ package com.unciv.logic.city
import com.unciv.Constants import com.unciv.Constants
import com.unciv.UncivGame import com.unciv.UncivGame
import com.unciv.UniqueAbility
import com.unciv.logic.civilization.CityStateType import com.unciv.logic.civilization.CityStateType
import com.unciv.logic.civilization.diplomacy.RelationshipLevel import com.unciv.logic.civilization.diplomacy.RelationshipLevel
import com.unciv.logic.map.RoadStatus import com.unciv.logic.map.RoadStatus
@ -12,8 +11,6 @@ import com.unciv.models.ruleset.unit.BaseUnit
import com.unciv.models.ruleset.unit.UnitType import com.unciv.models.ruleset.unit.UnitType
import com.unciv.models.stats.Stat import com.unciv.models.stats.Stat
import com.unciv.models.stats.Stats import com.unciv.models.stats.Stats
import com.unciv.models.translations.equalsPlaceholderText
import com.unciv.models.translations.getPlaceholderParameters
class CityStats { class CityStats {

View file

@ -1,7 +1,6 @@
package com.unciv.logic.civilization package com.unciv.logic.civilization
import com.unciv.Constants import com.unciv.Constants
import com.unciv.UniqueAbility
import com.unciv.logic.civilization.diplomacy.RelationshipLevel import com.unciv.logic.civilization.diplomacy.RelationshipLevel
import com.unciv.logic.map.RoadStatus import com.unciv.logic.map.RoadStatus
import com.unciv.models.metadata.BASE_GAME_DURATION_TURNS import com.unciv.models.metadata.BASE_GAME_DURATION_TURNS

View file

@ -1,7 +1,6 @@
package com.unciv.logic.civilization package com.unciv.logic.civilization
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.unciv.UniqueAbility
import com.unciv.logic.map.TileInfo import com.unciv.logic.map.TileInfo
import com.unciv.models.ruleset.tile.ResourceSupplyList import com.unciv.models.ruleset.tile.ResourceSupplyList

View file

@ -1,7 +1,6 @@
package com.unciv.logic.civilization package com.unciv.logic.civilization
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.unciv.UniqueAbility
class GoldenAgeManager{ class GoldenAgeManager{
@Transient @Transient

View file

@ -2,7 +2,6 @@ package com.unciv.logic.civilization.diplomacy
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.unciv.Constants import com.unciv.Constants
import com.unciv.UniqueAbility
import com.unciv.logic.civilization.* import com.unciv.logic.civilization.*
import com.unciv.logic.trade.Trade import com.unciv.logic.trade.Trade
import com.unciv.logic.trade.TradeOffer import com.unciv.logic.trade.TradeOffer

View file

@ -4,7 +4,6 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.math.Vector2 import com.badlogic.gdx.math.Vector2
import com.unciv.Constants import com.unciv.Constants
import com.unciv.UncivGame import com.unciv.UncivGame
import com.unciv.UniqueAbility
import com.unciv.logic.automation.UnitAutomation import com.unciv.logic.automation.UnitAutomation
import com.unciv.logic.automation.WorkerAutomation import com.unciv.logic.automation.WorkerAutomation
import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.CivilizationInfo

View file

@ -3,7 +3,6 @@
import com.badlogic.gdx.math.Vector2 import com.badlogic.gdx.math.Vector2
import com.unciv.Constants import com.unciv.Constants
import com.unciv.UncivGame import com.unciv.UncivGame
import com.unciv.UniqueAbility
import com.unciv.logic.HexMath import com.unciv.logic.HexMath
import com.unciv.logic.city.CityInfo import com.unciv.logic.city.CityInfo
import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.CivilizationInfo

View file

@ -2,7 +2,6 @@ package com.unciv.logic.map
import com.badlogic.gdx.math.Vector2 import com.badlogic.gdx.math.Vector2
import com.unciv.Constants import com.unciv.Constants
import com.unciv.UniqueAbility
import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.CivilizationInfo
class UnitMovementAlgorithms(val unit:MapUnit) { class UnitMovementAlgorithms(val unit:MapUnit) {

View file

@ -19,45 +19,52 @@ enum class VictoryType{
class Nation : INamed { class Nation : INamed {
override lateinit var name: String override lateinit var name: String
var leaderName="" var leaderName = ""
fun getLeaderDisplayName() = if(isCityState()) name fun getLeaderDisplayName() = if (isCityState()) name
else "[$leaderName] of [$name]" else "[$leaderName] of [$name]"
var cityStateType: CityStateType? = null var cityStateType: CityStateType? = null
var preferredVictoryType:VictoryType = VictoryType.Neutral var preferredVictoryType: VictoryType = VictoryType.Neutral
var declaringWar="" var declaringWar = ""
var attacked="" var attacked = ""
var defeated="" var defeated = ""
var introduction="" var introduction = ""
var tradeRequest="" var tradeRequest = ""
var neutralHello="" var neutralHello = ""
var hateHello="" var hateHello = ""
lateinit var outerColor: List<Int> lateinit var outerColor: List<Int>
var unique: UniqueAbility? = null var unique: UniqueAbility? = null
val uniques = HashSet<String>() var uniqueName = ""
val uniqueObjects:List<Unique> by lazy { uniques.map { Unique(it) } } var uniques = HashSet<String>()
val uniqueObjects: List<Unique> by lazy { uniques.map { Unique(it) } }
var innerColor: List<Int>? = null var innerColor: List<Int>? = null
var startBias = ArrayList<String>() var startBias = ArrayList<String>()
@Transient private lateinit var outerColorObject:Color @Transient
private lateinit var outerColorObject: Color
fun getOuterColor(): Color = outerColorObject fun getOuterColor(): Color = outerColorObject
@Transient private lateinit var innerColorObject:Color @Transient
private lateinit var innerColorObject: Color
fun getInnerColor(): Color = innerColorObject fun getInnerColor(): Color = innerColorObject
fun isCityState()= cityStateType != null fun isCityState() = cityStateType != null
fun isMajorCiv() = !isBarbarian() && !isCityState() &&!isSpectator() fun isMajorCiv() = !isBarbarian() && !isCityState() && !isSpectator()
fun isBarbarian() = name== Constants.barbarians fun isBarbarian() = name == Constants.barbarians
fun isSpectator() = name == Constants.spectator fun isSpectator() = name == Constants.spectator
// This is its own transient because we'll need to check this for every tile-to-tile movement which is harsh // This is its own transient because we'll need to check this for every tile-to-tile movement which is harsh
@Transient var forestsAndJunglesAreRoads = false @Transient
var forestsAndJunglesAreRoads = false
// Same for Inca unique // Same for Inca unique
@Transient var ignoreHillMovementCost = false @Transient
@Transient var embarkDisembarkCosts1 = false var ignoreHillMovementCost = false
@Transient
var embarkDisembarkCosts1 = false
fun setTransients() { fun setTransients() {
outerColorObject = colorFromRGB(outerColor[0], outerColor[1], outerColor[2]) outerColorObject = colorFromRGB(outerColor[0], outerColor[1], outerColor[2])
@ -69,19 +76,17 @@ class Nation : INamed {
forestsAndJunglesAreRoads = true forestsAndJunglesAreRoads = true
if (uniques.contains("Units ignore terrain costs when moving into any tile with Hills")) if (uniques.contains("Units ignore terrain costs when moving into any tile with Hills"))
ignoreHillMovementCost = true ignoreHillMovementCost = true
if(uniques.contains("Units pay only 1 movement point to embark and disembark")) if (uniques.contains("Units pay only 1 movement point to embark and disembark"))
embarkDisembarkCosts1 = true embarkDisembarkCosts1 = true
} }
lateinit var cities: ArrayList<String> lateinit var cities: ArrayList<String>
fun getUniqueString(ruleset: Ruleset, forPickerScreen: Boolean = true): String { fun getUniqueString(ruleset: Ruleset, forPickerScreen: Boolean = true): String {
val textList = ArrayList<String>() val textList = ArrayList<String>()
if (leaderName.isNotEmpty() && !forPickerScreen){ if (leaderName.isNotEmpty() && !forPickerScreen) {
textList += getLeaderDisplayName().tr() textList += getLeaderDisplayName().tr()
textList += "" textList += ""
} }
@ -91,13 +96,18 @@ class Nation : INamed {
textList += "" textList += ""
} }
// if (uniqueName!="") {
// textList += uniqueName.tr() + ":"
// textList += " " + uniques.joinToString(", ").tr()
// textList += ""
// }
if (startBias.isNotEmpty()) { if (startBias.isNotEmpty()) {
textList += "Start bias:".tr() + startBias.joinToString(", ", " ") { it.tr() } textList += "Start bias:".tr() + startBias.joinToString(", ", " ") { it.tr() }
textList += "" textList += ""
} }
addUniqueBuildingsText(textList,ruleset) addUniqueBuildingsText(textList, ruleset)
addUniqueUnitsText(textList,ruleset) addUniqueUnitsText(textList, ruleset)
addUniqueImprovementsText(textList,ruleset) addUniqueImprovementsText(textList, ruleset)
return textList.joinToString("\n").tr().trim() return textList.joinToString("\n").tr().trim()
} }
@ -133,7 +143,7 @@ class Nation : INamed {
private fun addUniqueUnitsText(textList: ArrayList<String>, ruleset: Ruleset) { private fun addUniqueUnitsText(textList: ArrayList<String>, ruleset: Ruleset) {
for (unit in ruleset.units.values for (unit in ruleset.units.values
.filter { it.uniqueTo == name }) { .filter { it.uniqueTo == name }) {
if(unit.replaces != null) { if (unit.replaces != null) {
val originalUnit = ruleset.units[unit.replaces!!]!! val originalUnit = ruleset.units[unit.replaces!!]!!
textList += unit.name.tr() + " - " + "Replaces [${originalUnit.name}]".tr() textList += unit.name.tr() + " - " + "Replaces [${originalUnit.name}]".tr()
if (unit.cost != originalUnit.cost) if (unit.cost != originalUnit.cost)
@ -154,8 +164,7 @@ class Nation : INamed {
textList += " " + "Lost ability".tr() + "(vs " + originalUnit.name.tr() + "): " + Translations.translateBonusOrPenalty(unique) textList += " " + "Lost ability".tr() + "(vs " + originalUnit.name.tr() + "): " + Translations.translateBonusOrPenalty(unique)
for (promotion in unit.promotions.filter { it !in originalUnit.promotions }) for (promotion in unit.promotions.filter { it !in originalUnit.promotions })
textList += " " + promotion.tr() + " (" + Translations.translateBonusOrPenalty(ruleset.unitPromotions[promotion]!!.effect) + ")" textList += " " + promotion.tr() + " (" + Translations.translateBonusOrPenalty(ruleset.unitPromotions[promotion]!!.effect) + ")"
} } else {
else {
textList += unit.name.tr() textList += unit.name.tr()
textList += " " + unit.getDescription(true).split("\n").joinToString("\n ") textList += " " + unit.getDescription(true).split("\n").joinToString("\n ")
} }
@ -169,9 +178,9 @@ class Nation : INamed {
.filter { it.uniqueTo == name }) { .filter { it.uniqueTo == name }) {
textList += improvement.name.tr() textList += improvement.name.tr()
textList += " "+improvement.clone().toString() textList += " " + improvement.clone().toString()
for(unique in improvement.uniques) for (unique in improvement.uniques)
textList += " "+unique.tr() textList += " " + unique.tr()
} }
} }
} }

View file

@ -3,7 +3,6 @@ package com.unciv.ui.worldscreen.unit
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.unciv.Constants import com.unciv.Constants
import com.unciv.UncivGame import com.unciv.UncivGame
import com.unciv.UniqueAbility
import com.unciv.logic.automation.UnitAutomation import com.unciv.logic.automation.UnitAutomation
import com.unciv.logic.automation.WorkerAutomation import com.unciv.logic.automation.WorkerAutomation
import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.CivilizationInfo