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:
BenBooth1344 2019-11-04 07:24:43 -05:00 committed by Yair Morgenstern
parent d22598d6ac
commit 92ddc864fa
9 changed files with 79 additions and 33 deletions

View File

@ -77,6 +77,10 @@
Ukrainian:"Міст-держав" Ukrainian:"Міст-держав"
} }
"One City Challenge":{
}
"No barbarians":{//it can be showed correct as usual, so I'm not translate it. "No barbarians":{//it can be showed correct as usual, so I'm not translate it.
Italian:"Niente barbari" Italian:"Niente barbari"
French:"Pas de barbare" French:"Pas de barbare"

View File

@ -2576,6 +2576,14 @@
Russian:"Разорить" Russian:"Разорить"
Czech:"Srovnat se zemí" Czech:"Srovnat se zemí"
Ukrainian:"Зруйнувати" 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.":{ "Razing the city annexes it, and starts razing the city to the ground.":{

View File

@ -235,10 +235,10 @@ class Battle(val gameInfo:GameInfo) {
} }
city.hasJustBeenConquered = true city.hasJustBeenConquered = true
if (attacker.getCivInfo().isPlayerCivilization()) if (attackerCiv.isPlayerCivilization())
attackerCiv.popupAlerts.add(PopupAlert(AlertType.CityConquered, city.name)) attackerCiv.popupAlerts.add(PopupAlert(AlertType.CityConquered, city.name))
else { else {
city.puppetCity(attacker.getCivInfo()) city.puppetCity(attackerCiv)
if (city.population.population < 4) { if (city.population.population < 4) {
city.annexCity() city.annexCity()
city.isBeingRazed = true city.isBeingRazed = true
@ -254,9 +254,11 @@ class Battle(val gameInfo:GameInfo) {
} }
private fun captureCivilianUnit(attacker: ICombatant, defender: ICombatant){ 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() if(attacker.getCivInfo().isBarbarian()
|| (attacker.getCivInfo().isCityState() && defender.getName()==Constants.settler)){ || ((attacker.getCivInfo().isCityState() || attacker.getCivInfo().isPlayerOneCityChallenger())
&& defender.getName()==Constants.settler)){
defender.takeDamage(100) defender.takeDamage(100)
return return
} }

View File

@ -126,6 +126,10 @@ class CivilizationInfo {
fun getCapital()=cities.first { it.isCapital() } fun getCapital()=cities.first { it.isCapital() }
fun isPlayerCivilization() = playerType==PlayerType.Human fun isPlayerCivilization() = playerType==PlayerType.Human
fun isPlayerOneCityChallenger() = (
playerType==PlayerType.Human &&
!cities.isEmpty() &&
gameInfo.gameParameters.oneCityChallenge)
fun isCurrentPlayer() = gameInfo.getCurrentPlayerCivilization()==this fun isCurrentPlayer() = gameInfo.getCurrentPlayerCivilization()==this
fun isBarbarian() = nation.isBarbarian() fun isBarbarian() = nation.isBarbarian()
fun isCityState(): Boolean = nation.isCityState() fun isCityState(): Boolean = nation.isCityState()

View File

@ -467,7 +467,7 @@ class MapUnit {
actions.add { actions.add {
val chosenUnit = listOf(Constants.settler, Constants.worker,"Warrior").random() 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.placeUnitNearTile(tile.position, chosenUnit)
civInfo.addNotification("A [$chosenUnit] has joined us!", tile.position, Color.BROWN) civInfo.addNotification("A [$chosenUnit] has joined us!", tile.position, Color.BROWN)
} }

View File

@ -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 (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 (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.isCityState()) return "No settler for city-states"
if (name == Constants.settler && civInfo.isPlayerOneCityChallenger()) return "No settler for players in One City Challenge"
return "" return ""
} }

View File

@ -16,6 +16,7 @@ class GameParameters { // Default values are the default new game
var numberOfCityStates = 0 var numberOfCityStates = 0
var mapType = MapType.pangaea var mapType = MapType.pangaea
var noBarbarians = false var noBarbarians = false
var oneCityChallenge = false
var noRuins = false; var noRuins = false;
var mapFileName: String? = null var mapFileName: String? = null
var victoryTypes: ArrayList<VictoryType> = VictoryType.values().toCollection(ArrayList()) // By default, all victory types var victoryTypes: ArrayList<VictoryType> = VictoryType.values().toCollection(ArrayList()) // By default, all victory types

View File

@ -27,6 +27,7 @@ class NewGameScreenOptionsTable(val newGameParameters: GameParameters, val onMul
addCityStatesSelectBox() addCityStatesSelectBox()
addVictoryTypeCheckboxes() addVictoryTypeCheckboxes()
addBarbariansCheckbox() addBarbariansCheckbox()
addOneCityChallengeCheckbox()
addNoRuinsCheckbox() addNoRuinsCheckbox()
addIsOnlineMultiplayerCheckbox() addIsOnlineMultiplayerCheckbox()
@ -45,6 +46,16 @@ class NewGameScreenOptionsTable(val newGameParameters: GameParameters, val onMul
add(noBarbariansCheckbox).colspan(2).row() 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() { private fun addNoRuinsCheckbox() {
val noRuinsCheckbox = CheckBox("No ancient ruins".tr(), CameraStageBaseScreen.skin) val noRuinsCheckbox = CheckBox("No ancient ruins".tr(), CameraStageBaseScreen.skin)
noRuinsCheckbox.isChecked = newGameParameters.noRuins noRuinsCheckbox.isChecked = newGameParameters.noRuins

View File

@ -76,36 +76,51 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
addSeparator() addSeparator()
} }
add(TextButton("Annex".tr(), skin).onClick { if (!conqueringCiv.isPlayerOneCityChallenger()){
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("Puppet".tr(), skin).onClick { add(TextButton("Annex".tr(), skin).onClick {
city.puppetCity(conqueringCiv) city.puppetCity(conqueringCiv)
worldScreen.shouldUpdate=true city.annexCity()
close() worldScreen.shouldUpdate=true
}).row() close()
addGoodSizedLabel("Puppeted cities do not increase your tech or policy cost, but their citizens generate 1.5x the regular unhappiness.").row() }).row()
addGoodSizedLabel("You have no control over the the production of puppeted cities.").row() addGoodSizedLabel("Annexed cities become part of your regular empire.").row()
addGoodSizedLabel("Puppeted cities also generate 25% less Gold and Science.").row() addGoodSizedLabel("Their citizens generate 2x the unhappiness, unless you build a courthouse.").row()
addGoodSizedLabel("A puppeted city can be annexed at any time.").row() addSeparator()
addSeparator()
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()
}
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()
} }
AlertType.BorderConflict -> { AlertType.BorderConflict -> {
val civInfo = worldScreen.gameInfo.getCivilization(popupAlert.value) val civInfo = worldScreen.gameInfo.getCivilization(popupAlert.value)