mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-20 04:38:18 +07:00
Added "scenario editing" mode for creating prebuild scenarios
This commit is contained in:
@ -339,7 +339,8 @@ class CityConstructions {
|
|||||||
if (!getConstruction(constructionName).postBuildEvent(this, true))
|
if (!getConstruction(constructionName).postBuildEvent(this, true))
|
||||||
return false // nothing built - no pay
|
return false // nothing built - no pay
|
||||||
|
|
||||||
cityInfo.civInfo.gold -= getConstruction(constructionName).getGoldCost(cityInfo.civInfo)
|
if (!cityInfo.civInfo.gameInfo.gameParameters.godMode)
|
||||||
|
cityInfo.civInfo.gold -= getConstruction(constructionName).getGoldCost(cityInfo.civInfo)
|
||||||
|
|
||||||
if (queuePosition in 0 until constructionQueue.size)
|
if (queuePosition in 0 until constructionQueue.size)
|
||||||
removeFromQueue(queuePosition, automatic)
|
removeFromQueue(queuePosition, automatic)
|
||||||
|
@ -45,7 +45,8 @@ class CityExpansionManager {
|
|||||||
val goldCost = getGoldCostOfTile(tileInfo)
|
val goldCost = getGoldCostOfTile(tileInfo)
|
||||||
|
|
||||||
class NotEnoughGoldToBuyTileException : Exception()
|
class NotEnoughGoldToBuyTileException : Exception()
|
||||||
if (cityInfo.civInfo.gold < goldCost) throw NotEnoughGoldToBuyTileException()
|
if (cityInfo.civInfo.gold < goldCost && !cityInfo.civInfo.gameInfo.gameParameters.godMode)
|
||||||
|
throw NotEnoughGoldToBuyTileException()
|
||||||
cityInfo.civInfo.gold -= goldCost
|
cityInfo.civInfo.gold -= goldCost
|
||||||
takeOwnership(tileInfo)
|
takeOwnership(tileInfo)
|
||||||
}
|
}
|
||||||
|
@ -252,8 +252,10 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
|
|||||||
if (destination.isCityCenter() && destination.getOwner() != unit.civInfo && !destination.getCity()!!.hasJustBeenConquered)
|
if (destination.isCityCenter() && destination.getOwner() != unit.civInfo && !destination.getCity()!!.hasJustBeenConquered)
|
||||||
throw Exception("This is an enemy city, you can't go here!")
|
throw Exception("This is an enemy city, you can't go here!")
|
||||||
|
|
||||||
unit.currentMovement -= distanceToTiles[destination]!!.totalDistance
|
if (!unit.civInfo.gameInfo.gameParameters.godMode) {
|
||||||
if (unit.currentMovement < 0.1) unit.currentMovement = 0f // silly floats which are "almost zero"
|
unit.currentMovement -= distanceToTiles[destination]!!.totalDistance
|
||||||
|
if (unit.currentMovement < 0.1) unit.currentMovement = 0f // silly floats which are "almost zero"
|
||||||
|
}
|
||||||
if (unit.isFortified() || unit.action == Constants.unitActionSetUp || unit.isSleeping())
|
if (unit.isFortified() || unit.action == Constants.unitActionSetUp || unit.isSleeping())
|
||||||
unit.action = null // unfortify/setup after moving
|
unit.action = null // unfortify/setup after moving
|
||||||
|
|
||||||
|
@ -196,6 +196,13 @@ class NaturalWonderGenerator(val ruleset: Ruleset){
|
|||||||
for (tile in location.neighbors) {
|
for (tile in location.neighbors) {
|
||||||
if (tile.baseTerrain == Constants.coast) continue
|
if (tile.baseTerrain == Constants.coast) continue
|
||||||
if (tile.baseTerrain == Constants.mountain) continue
|
if (tile.baseTerrain == Constants.mountain) continue
|
||||||
|
for (neighbor in tile.neighbors)
|
||||||
|
// This is so we don't have this tile turn into Coast, and then it's touching a Lake tile.
|
||||||
|
// We just turn the lake tiles into this kind of tile.
|
||||||
|
if (neighbor.baseTerrain == Constants.lakes) {
|
||||||
|
neighbor.baseTerrain = tile.baseTerrain
|
||||||
|
neighbor.setTerrainTransients()
|
||||||
|
}
|
||||||
|
|
||||||
tile.baseTerrain = Constants.coast
|
tile.baseTerrain = Constants.coast
|
||||||
tile.terrainFeature = null
|
tile.terrainFeature = null
|
||||||
|
@ -19,6 +19,7 @@ class GameParameters { // Default values are the default new game
|
|||||||
|
|
||||||
var noBarbarians = false
|
var noBarbarians = false
|
||||||
var oneCityChallenge = false
|
var oneCityChallenge = false
|
||||||
|
var godMode = false
|
||||||
var nuclearWeaponsEnabled = true
|
var nuclearWeaponsEnabled = true
|
||||||
|
|
||||||
var victoryTypes: ArrayList<VictoryType> = arrayListOf(VictoryType.Cultural, VictoryType.Domination, VictoryType.Scientific) // By default, all victory types
|
var victoryTypes: ArrayList<VictoryType> = arrayListOf(VictoryType.Cultural, VictoryType.Domination, VictoryType.Scientific) // By default, all victory types
|
||||||
|
@ -43,7 +43,7 @@ class CityScreenTileTable(val cityScreen: CityScreen): Table(){
|
|||||||
city.expansion.buyTile(selectedTile)
|
city.expansion.buyTile(selectedTile)
|
||||||
UncivGame.Current.setScreen(CityScreen(city))
|
UncivGame.Current.setScreen(CityScreen(city))
|
||||||
}
|
}
|
||||||
if(goldCostOfTile>city.civInfo.gold
|
if((goldCostOfTile>city.civInfo.gold && !city.civInfo.gameInfo.gameParameters.godMode)
|
||||||
|| city.isPuppet
|
|| city.isPuppet
|
||||||
|| !cityScreen.canChangeState)
|
|| !cityScreen.canChangeState)
|
||||||
buyTileButton.disable()
|
buyTileButton.disable()
|
||||||
|
@ -327,7 +327,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
|||||||
|
|
||||||
val button = "".toTextButton()
|
val button = "".toTextButton()
|
||||||
|
|
||||||
if (construction == null || !construction.canBePurchased()
|
if (construction == null || (!construction.canBePurchased() && !city.civInfo.gameInfo.gameParameters.godMode)
|
||||||
) {
|
) {
|
||||||
// fully disable a "buy" button only for "priceless" buildings such as wonders
|
// fully disable a "buy" button only for "priceless" buildings such as wonders
|
||||||
// for all other cases, the price should be displayed
|
// for all other cases, the price should be displayed
|
||||||
@ -347,11 +347,11 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
|||||||
YesNoPopup(purchasePrompt, { purchaseConstruction(construction) }, cityScreen, { cityScreen.update() }).open()
|
YesNoPopup(purchasePrompt, { purchaseConstruction(construction) }, cityScreen, { cityScreen.update() }).open()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !construction.isBuildable(cityConstructions)
|
if (!construction.isBuildable(cityConstructions)
|
||||||
|| !cityScreen.canChangeState
|
|| !cityScreen.canChangeState
|
||||||
|| city.isPuppet || city.isInResistance()
|
|| city.isPuppet || city.isInResistance()
|
||||||
|| !city.canPurchase(construction)
|
|| !city.canPurchase(construction)
|
||||||
|| constructionGoldCost > city.civInfo.gold )
|
|| (constructionGoldCost > city.civInfo.gold && !city.civInfo.gameInfo.gameParameters.godMode) )
|
||||||
button.disable()
|
button.disable()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.CheckBox
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
|
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.utils.Array
|
import com.badlogic.gdx.utils.Array
|
||||||
|
import com.unciv.UncivGame
|
||||||
import com.unciv.models.metadata.BaseRuleset
|
import com.unciv.models.metadata.BaseRuleset
|
||||||
import com.unciv.models.metadata.GameSpeed
|
import com.unciv.models.metadata.GameSpeed
|
||||||
import com.unciv.models.ruleset.RulesetCache
|
import com.unciv.models.ruleset.RulesetCache
|
||||||
@ -46,6 +47,8 @@ class GameOptionsTable(val previousScreen: IPreviousScreen, val updatePlayerPick
|
|||||||
checkboxTable.addBarbariansCheckbox()
|
checkboxTable.addBarbariansCheckbox()
|
||||||
checkboxTable.addOneCityChallengeCheckbox()
|
checkboxTable.addOneCityChallengeCheckbox()
|
||||||
checkboxTable.addNuclearWeaponsCheckbox()
|
checkboxTable.addNuclearWeaponsCheckbox()
|
||||||
|
if(UncivGame.Current.settings.extendedMapEditor)
|
||||||
|
checkboxTable.addGodmodeCheckbox()
|
||||||
checkboxTable.addIsOnlineMultiplayerCheckbox()
|
checkboxTable.addIsOnlineMultiplayerCheckbox()
|
||||||
checkboxTable.addModCheckboxes()
|
checkboxTable.addModCheckboxes()
|
||||||
add(checkboxTable).colspan(2).row()
|
add(checkboxTable).colspan(2).row()
|
||||||
@ -73,6 +76,10 @@ class GameOptionsTable(val previousScreen: IPreviousScreen, val updatePlayerPick
|
|||||||
addCheckbox("Enable nuclear weapons", gameParameters.nuclearWeaponsEnabled)
|
addCheckbox("Enable nuclear weapons", gameParameters.nuclearWeaponsEnabled)
|
||||||
{ gameParameters.nuclearWeaponsEnabled = it }
|
{ gameParameters.nuclearWeaponsEnabled = it }
|
||||||
|
|
||||||
|
private fun Table.addGodmodeCheckbox() =
|
||||||
|
addCheckbox("Scenario Editor", gameParameters.godMode)
|
||||||
|
{ gameParameters.godMode = it }
|
||||||
|
|
||||||
|
|
||||||
private fun Table.addIsOnlineMultiplayerCheckbox() =
|
private fun Table.addIsOnlineMultiplayerCheckbox() =
|
||||||
addCheckbox("Online Multiplayer", gameParameters.isOnlineMultiplayer)
|
addCheckbox("Online Multiplayer", gameParameters.isOnlineMultiplayer)
|
||||||
|
@ -29,7 +29,8 @@ class MapOptionsTable(val newGameScreen: NewGameScreen): Table() {
|
|||||||
add("{Map Type}:".toLabel())
|
add("{Map Type}:".toLabel())
|
||||||
val mapTypes = arrayListOf("Generated")
|
val mapTypes = arrayListOf("Generated")
|
||||||
if (MapSaver.getMaps().isNotEmpty()) mapTypes.add(MapType.custom)
|
if (MapSaver.getMaps().isNotEmpty()) mapTypes.add(MapType.custom)
|
||||||
if (MapSaver.getScenarios().isNotEmpty() && UncivGame.Current.settings.extendedMapEditor) mapTypes.add(MapType.scenario)
|
if (MapSaver.getScenarios().isNotEmpty() && UncivGame.Current.settings.extendedMapEditor)
|
||||||
|
mapTypes.add(MapType.scenario)
|
||||||
val mapTypeSelectBox = TranslatedSelectBox(mapTypes, "Generated", CameraStageBaseScreen.skin)
|
val mapTypeSelectBox = TranslatedSelectBox(mapTypes, "Generated", CameraStageBaseScreen.skin)
|
||||||
|
|
||||||
val mapFileSelectBox = getMapFileSelectBox()
|
val mapFileSelectBox = getMapFileSelectBox()
|
||||||
|
@ -184,6 +184,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
|||||||
|
|
||||||
private fun selectTechnology(tech: Technology?, center: Boolean = false, switchfromWorldScreen: Boolean = true) {
|
private fun selectTechnology(tech: Technology?, center: Boolean = false, switchfromWorldScreen: Boolean = true) {
|
||||||
|
|
||||||
|
val previousSelectedTech = selectedTech
|
||||||
selectedTech = tech
|
selectedTech = tech
|
||||||
descriptionLabel.setText(tech?.getDescription(civInfo.gameInfo.ruleSet))
|
descriptionLabel.setText(tech?.getDescription(civInfo.gameInfo.ruleSet))
|
||||||
|
|
||||||
@ -204,6 +205,11 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (civInfo.gameInfo.gameParameters.godMode && !civInfo.tech.isResearched(tech.name)
|
||||||
|
&& selectedTech == previousSelectedTech){
|
||||||
|
civInfo.tech.addTechnology(tech.name)
|
||||||
|
}
|
||||||
|
|
||||||
if (civTech.isResearched(tech.name) && tech.name != Constants.futureTech) {
|
if (civTech.isResearched(tech.name) && tech.name != Constants.futureTech) {
|
||||||
rightSideButton.setText("Pick a tech".tr())
|
rightSideButton.setText("Pick a tech".tr())
|
||||||
rightSideButton.disable()
|
rightSideButton.disable()
|
||||||
|
Reference in New Issue
Block a user