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

@ -75,6 +75,10 @@
Korean:"도시 국가 수"
Czech:"Počet městských států"
Ukrainian:"Міст-держав"
}
"One City Challenge":{
}
"No barbarians":{//it can be showed correct as usual, so I'm not translate it.

View File

@ -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.":{

View File

@ -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
}

View File

@ -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()

View File

@ -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)
}

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 (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 ""
}

View File

@ -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

View File

@ -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

View File

@ -76,6 +76,8 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
addSeparator()
}
if (!conqueringCiv.isPlayerOneCityChallenger()){
add(TextButton("Annex".tr(), skin).onClick {
city.puppetCity(conqueringCiv)
city.annexCity()
@ -97,6 +99,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
addGoodSizedLabel("A puppeted city can be annexed at any time.").row()
addSeparator()
add(TextButton("Raze".tr(), skin).onClick {
city.puppetCity(conqueringCiv)
city.annexCity()
@ -106,6 +109,18 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
}).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)