mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-16 10:49:17 +07:00
Implemented One City Challenge (#1279)
* Implemented One City Challenge Implemented One City Challenge * prevent OCC from capturing settlers * Fixed spellling of Destroy * fixed capture logic for barbarian
This commit is contained in:

committed by
Yair Morgenstern

parent
d22598d6ac
commit
92ddc864fa
@ -77,6 +77,10 @@
|
||||
Ukrainian:"Міст-держав"
|
||||
}
|
||||
|
||||
"One City Challenge":{
|
||||
|
||||
}
|
||||
|
||||
"No barbarians":{//it can be showed correct as usual, so I'm not translate it.
|
||||
Italian:"Niente barbari"
|
||||
French:"Pas de barbare"
|
||||
|
@ -2576,6 +2576,14 @@
|
||||
Russian:"Разорить"
|
||||
Czech:"Srovnat se zemí"
|
||||
Ukrainian:"Зруйнувати"
|
||||
}
|
||||
|
||||
"Destroy":{
|
||||
|
||||
}
|
||||
|
||||
"Destroying the city instantly razes the city to the ground.":{
|
||||
|
||||
}
|
||||
|
||||
"Razing the city annexes it, and starts razing the city to the ground.":{
|
||||
|
@ -235,10 +235,10 @@ class Battle(val gameInfo:GameInfo) {
|
||||
}
|
||||
city.hasJustBeenConquered = true
|
||||
|
||||
if (attacker.getCivInfo().isPlayerCivilization())
|
||||
if (attackerCiv.isPlayerCivilization())
|
||||
attackerCiv.popupAlerts.add(PopupAlert(AlertType.CityConquered, city.name))
|
||||
else {
|
||||
city.puppetCity(attacker.getCivInfo())
|
||||
city.puppetCity(attackerCiv)
|
||||
if (city.population.population < 4) {
|
||||
city.annexCity()
|
||||
city.isBeingRazed = true
|
||||
@ -254,9 +254,11 @@ class Battle(val gameInfo:GameInfo) {
|
||||
}
|
||||
|
||||
private fun captureCivilianUnit(attacker: ICombatant, defender: ICombatant){
|
||||
// barbarians don't capture civilians, City-states don't capture settlers
|
||||
// barbarians don't capture civilians
|
||||
// City-states & OCC don't capture settlers
|
||||
if(attacker.getCivInfo().isBarbarian()
|
||||
|| (attacker.getCivInfo().isCityState() && defender.getName()==Constants.settler)){
|
||||
|| ((attacker.getCivInfo().isCityState() || attacker.getCivInfo().isPlayerOneCityChallenger())
|
||||
&& defender.getName()==Constants.settler)){
|
||||
defender.takeDamage(100)
|
||||
return
|
||||
}
|
||||
|
@ -126,6 +126,10 @@ class CivilizationInfo {
|
||||
|
||||
fun getCapital()=cities.first { it.isCapital() }
|
||||
fun isPlayerCivilization() = playerType==PlayerType.Human
|
||||
fun isPlayerOneCityChallenger() = (
|
||||
playerType==PlayerType.Human &&
|
||||
!cities.isEmpty() &&
|
||||
gameInfo.gameParameters.oneCityChallenge)
|
||||
fun isCurrentPlayer() = gameInfo.getCurrentPlayerCivilization()==this
|
||||
fun isBarbarian() = nation.isBarbarian()
|
||||
fun isCityState(): Boolean = nation.isCityState()
|
||||
|
@ -467,7 +467,7 @@ class MapUnit {
|
||||
|
||||
actions.add {
|
||||
val chosenUnit = listOf(Constants.settler, Constants.worker,"Warrior").random()
|
||||
if (!civInfo.isCityState() || chosenUnit != Constants.settler) { //City states don't get settler from ruins
|
||||
if (!(civInfo.isCityState() || civInfo.isPlayerOneCityChallenger()) || chosenUnit != Constants.settler) { //City states and OCC don't get settler from ruins
|
||||
civInfo.placeUnitNearTile(tile.position, chosenUnit)
|
||||
civInfo.addNotification("A [$chosenUnit] has joined us!", tile.position, Color.BROWN)
|
||||
}
|
||||
|
@ -140,6 +140,7 @@ class BaseUnit : INamed, IConstruction, ICivilopedia {
|
||||
if (GameBasics.Units.values.any { it.uniqueTo==civInfo.civName && it.replaces==name }) return "Our unique unit replaces this"
|
||||
if (requiredResource!=null && !civInfo.hasResource(requiredResource!!)) return "Requires [$requiredResource]"
|
||||
if (name == Constants.settler && civInfo.isCityState()) return "No settler for city-states"
|
||||
if (name == Constants.settler && civInfo.isPlayerOneCityChallenger()) return "No settler for players in One City Challenge"
|
||||
return ""
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@ class GameParameters { // Default values are the default new game
|
||||
var numberOfCityStates = 0
|
||||
var mapType = MapType.pangaea
|
||||
var noBarbarians = false
|
||||
var oneCityChallenge = false
|
||||
var noRuins = false;
|
||||
var mapFileName: String? = null
|
||||
var victoryTypes: ArrayList<VictoryType> = VictoryType.values().toCollection(ArrayList()) // By default, all victory types
|
||||
|
@ -27,6 +27,7 @@ class NewGameScreenOptionsTable(val newGameParameters: GameParameters, val onMul
|
||||
addCityStatesSelectBox()
|
||||
addVictoryTypeCheckboxes()
|
||||
addBarbariansCheckbox()
|
||||
addOneCityChallengeCheckbox()
|
||||
addNoRuinsCheckbox()
|
||||
|
||||
addIsOnlineMultiplayerCheckbox()
|
||||
@ -45,6 +46,16 @@ class NewGameScreenOptionsTable(val newGameParameters: GameParameters, val onMul
|
||||
add(noBarbariansCheckbox).colspan(2).row()
|
||||
}
|
||||
|
||||
private fun addOneCityChallengeCheckbox() {
|
||||
val oneCityChallengeCheckbox = CheckBox("One City Challenge".tr(), CameraStageBaseScreen.skin)
|
||||
oneCityChallengeCheckbox.isChecked = newGameParameters.oneCityChallenge
|
||||
oneCityChallengeCheckbox.addListener(object : ChangeListener() {
|
||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||
newGameParameters.oneCityChallenge = oneCityChallengeCheckbox.isChecked
|
||||
}
|
||||
})
|
||||
add(oneCityChallengeCheckbox).colspan(2).row()
|
||||
}
|
||||
private fun addNoRuinsCheckbox() {
|
||||
val noRuinsCheckbox = CheckBox("No ancient ruins".tr(), CameraStageBaseScreen.skin)
|
||||
noRuinsCheckbox.isChecked = newGameParameters.noRuins
|
||||
|
@ -76,36 +76,51 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
||||
addSeparator()
|
||||
}
|
||||
|
||||
add(TextButton("Annex".tr(), skin).onClick {
|
||||
city.puppetCity(conqueringCiv)
|
||||
city.annexCity()
|
||||
worldScreen.shouldUpdate=true
|
||||
close()
|
||||
}).row()
|
||||
addGoodSizedLabel("Annexed cities become part of your regular empire.").row()
|
||||
addGoodSizedLabel("Their citizens generate 2x the unhappiness, unless you build a courthouse.").row()
|
||||
addSeparator()
|
||||
if (!conqueringCiv.isPlayerOneCityChallenger()){
|
||||
|
||||
add(TextButton("Puppet".tr(), skin).onClick {
|
||||
city.puppetCity(conqueringCiv)
|
||||
worldScreen.shouldUpdate=true
|
||||
close()
|
||||
}).row()
|
||||
addGoodSizedLabel("Puppeted cities do not increase your tech or policy cost, but their citizens generate 1.5x the regular unhappiness.").row()
|
||||
addGoodSizedLabel("You have no control over the the production of puppeted cities.").row()
|
||||
addGoodSizedLabel("Puppeted cities also generate 25% less Gold and Science.").row()
|
||||
addGoodSizedLabel("A puppeted city can be annexed at any time.").row()
|
||||
addSeparator()
|
||||
add(TextButton("Annex".tr(), skin).onClick {
|
||||
city.puppetCity(conqueringCiv)
|
||||
city.annexCity()
|
||||
worldScreen.shouldUpdate=true
|
||||
close()
|
||||
}).row()
|
||||
addGoodSizedLabel("Annexed cities become part of your regular empire.").row()
|
||||
addGoodSizedLabel("Their citizens generate 2x the unhappiness, unless you build a courthouse.").row()
|
||||
addSeparator()
|
||||
|
||||
add(TextButton("Raze".tr(), skin).onClick {
|
||||
city.puppetCity(conqueringCiv)
|
||||
city.annexCity()
|
||||
city.isBeingRazed = true
|
||||
worldScreen.shouldUpdate=true
|
||||
close()
|
||||
}).row()
|
||||
addGoodSizedLabel("Razing the city annexes it, and starts razing the city to the ground.").row()
|
||||
addGoodSizedLabel("The population will gradually dwindle until the city is destroyed.").row()
|
||||
add(TextButton("Puppet".tr(), skin).onClick {
|
||||
city.puppetCity(conqueringCiv)
|
||||
worldScreen.shouldUpdate=true
|
||||
close()
|
||||
}).row()
|
||||
addGoodSizedLabel("Puppeted cities do not increase your tech or policy cost, but their citizens generate 1.5x the regular unhappiness.").row()
|
||||
addGoodSizedLabel("You have no control over the the production of puppeted cities.").row()
|
||||
addGoodSizedLabel("Puppeted cities also generate 25% less Gold and Science.").row()
|
||||
addGoodSizedLabel("A puppeted city can be annexed at any time.").row()
|
||||
addSeparator()
|
||||
|
||||
|
||||
add(TextButton("Raze".tr(), skin).onClick {
|
||||
city.puppetCity(conqueringCiv)
|
||||
city.annexCity()
|
||||
city.isBeingRazed = true
|
||||
worldScreen.shouldUpdate=true
|
||||
close()
|
||||
}).row()
|
||||
addGoodSizedLabel("Razing the city annexes it, and starts razing the city to the ground.").row()
|
||||
addGoodSizedLabel("The population will gradually dwindle until the city is destroyed.").row()
|
||||
} else {
|
||||
|
||||
add(TextButton("Destroy".tr(), skin).onClick {
|
||||
city.puppetCity(conqueringCiv)
|
||||
city.destroyCity()
|
||||
worldScreen.shouldUpdate=true
|
||||
close()
|
||||
}).row()
|
||||
addGoodSizedLabel("Destroying the city instantly razes the city to the ground.").row()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
AlertType.BorderConflict -> {
|
||||
val civInfo = worldScreen.gameInfo.getCivilization(popupAlert.value)
|
||||
|
Reference in New Issue
Block a user