mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 15:27:50 +07:00
Multiple IDE-suggested fixes
This commit is contained in:
@ -21,8 +21,8 @@ android {
|
||||
applicationId "com.unciv.game"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 26
|
||||
versionCode 38
|
||||
versionName "1.4.5"
|
||||
versionCode 39
|
||||
versionName "1.4.6"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
@ -1,6 +1,6 @@
|
||||
buildscript {
|
||||
|
||||
ext.kotlinVersion = '1.2.21'
|
||||
ext.kotlinVersion = '1.2.31'
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.unciv.ui
|
||||
package com.unciv
|
||||
|
||||
import com.badlogic.gdx.Game
|
||||
import com.badlogic.gdx.Gdx
|
||||
@ -10,6 +10,7 @@ import com.unciv.logic.map.TileMap
|
||||
import com.unciv.models.gamebasics.*
|
||||
import com.unciv.models.gamebasics.Unit
|
||||
import com.unciv.models.stats.INamed
|
||||
import com.unciv.ui.GameSettings
|
||||
import com.unciv.ui.utils.GameSaver
|
||||
import com.unciv.ui.worldscreen.WorldScreen
|
||||
|
||||
@ -22,9 +23,9 @@ class UnCivGame : Game() {
|
||||
setupGameBasics()
|
||||
|
||||
Current = this
|
||||
if (GameSaver.GetSave("Autosave").exists()) {
|
||||
if (GameSaver.getSave("Autosave").exists()) {
|
||||
try {
|
||||
GameSaver.LoadGame(this, "Autosave")
|
||||
GameSaver.loadGame(this, "Autosave")
|
||||
gameInfo.getPlayerCivilization().civName="Babylon"
|
||||
gameInfo.tileMap.values.forEach {
|
||||
if (it.owner == "Player") it.owner = "Babylon"
|
@ -15,7 +15,7 @@ class Battle(val gameInfo:GameInfo) {
|
||||
&& it.unit!!.owner == attacker.getCivilization().civName
|
||||
&& it.unit!!.getBaseUnit().unitType == UnitType.Melee
|
||||
}
|
||||
if(numberOfAttackersSurroundingDefender >1) modifiers.put("Flanking",0.15f)
|
||||
if(numberOfAttackersSurroundingDefender >1) modifiers["Flanking"] = 0.15f
|
||||
}
|
||||
|
||||
return modifiers
|
||||
@ -24,7 +24,7 @@ class Battle(val gameInfo:GameInfo) {
|
||||
fun getDefenceModifiers(attacker: ICombatant, defender: ICombatant): HashMap<String, Float> {
|
||||
val modifiers = HashMap<String,Float>()
|
||||
val tileDefenceBonus = defender.getTile().getDefensiveBonus()
|
||||
if(tileDefenceBonus > 0) modifiers.put("Terrain",tileDefenceBonus)
|
||||
if(tileDefenceBonus > 0) modifiers["Terrain"] = tileDefenceBonus
|
||||
return modifiers
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ class CityExpansionManager {
|
||||
|
||||
for (i in 2..3) {
|
||||
val tiles = cityInfo.civInfo.gameInfo.tileMap.getTilesInDistance(cityInfo.cityLocation, i).filter { it.owner == null }
|
||||
if (tiles.size == 0) continue
|
||||
if (tiles.isEmpty()) continue
|
||||
val chosenTile = tiles.maxBy { cityInfo.rankTile(it) }
|
||||
chosenTile!!.owner = cityInfo.civInfo.civName
|
||||
tilesClaimed++
|
||||
|
@ -84,7 +84,7 @@ class CityInfo {
|
||||
name = CityNames[civInfo.cities.size]
|
||||
this.cityLocation = cityLocation
|
||||
civInfo.cities.add(this)
|
||||
civInfo.gameInfo.addNotification(name + " has been founded!", cityLocation)
|
||||
civInfo.gameInfo.addNotification("$name has been founded!", cityLocation)
|
||||
if (civInfo.policies.isAdopted("Legalism") && civInfo.cities.size <= 4) cityConstructions.addCultureBuilding()
|
||||
if (civInfo.cities.size == 1) {
|
||||
cityConstructions.builtBuildings.add("Palace")
|
||||
|
@ -2,7 +2,7 @@ package com.unciv.logic.civilization
|
||||
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.Policy
|
||||
import com.unciv.ui.UnCivGame
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.ui.pickerscreens.GreatPersonPickerScreen
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@ import com.unciv.models.gamebasics.Terrain
|
||||
import com.unciv.models.gamebasics.TileImprovement
|
||||
import com.unciv.models.gamebasics.TileResource
|
||||
import com.unciv.models.stats.Stats
|
||||
import com.unciv.ui.UnCivGame
|
||||
import com.unciv.UnCivGame
|
||||
|
||||
class TileInfo {
|
||||
@Transient lateinit var tileMap: TileMap
|
||||
@ -58,7 +58,7 @@ class TileInfo {
|
||||
|
||||
fun getOwner(): CivilizationInfo? {
|
||||
return if (owner == null) null
|
||||
else tileMap.gameInfo!!.civilizations.first { it.civName == owner }
|
||||
else tileMap.gameInfo.civilizations.first { it.civName == owner }
|
||||
}
|
||||
|
||||
fun getTerrainFeature(): Terrain? {
|
||||
@ -148,7 +148,7 @@ class TileInfo {
|
||||
}
|
||||
SB.appendln(this.baseTerrain)
|
||||
if (terrainFeature != null) SB.appendln(terrainFeature!!)
|
||||
if (hasViewableResource(tileMap.gameInfo!!.getPlayerCivilization())) SB.appendln(resource!!)
|
||||
if (hasViewableResource(tileMap.gameInfo.getPlayerCivilization())) SB.appendln(resource!!)
|
||||
if (roadStatus !== RoadStatus.None && !isCityCenter) SB.appendln(roadStatus)
|
||||
if (improvement != null) SB.appendln(improvement!!)
|
||||
if (improvementInProgress != null) SB.appendln("$improvementInProgress in ${this.turnsToImprovement} turns")
|
||||
|
@ -5,7 +5,7 @@ import com.unciv.logic.city.IConstruction
|
||||
import com.unciv.models.stats.NamedStats
|
||||
import com.unciv.models.stats.Stats
|
||||
import com.unciv.ui.ScienceVictoryScreen
|
||||
import com.unciv.ui.UnCivGame
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.ui.VictoryScreen
|
||||
import com.unciv.ui.pickerscreens.PolicyPickerScreen
|
||||
|
||||
@ -14,28 +14,28 @@ class Building : NamedStats(), IConstruction, ICivilopedia {
|
||||
override val description: String
|
||||
get() = getDescription(false, listOf())
|
||||
|
||||
@JvmField var requiredTech: String? = null
|
||||
var requiredTech: String? = null
|
||||
|
||||
@JvmField var cost: Int = 0
|
||||
@JvmField var maintenance = 0
|
||||
@JvmField var percentStatBonus: Stats? = null
|
||||
@JvmField var specialistSlots: Stats? = null
|
||||
@JvmField var greatPersonPoints: Stats? = null
|
||||
var cost: Int = 0
|
||||
var maintenance = 0
|
||||
var percentStatBonus: Stats? = null
|
||||
var specialistSlots: Stats? = null
|
||||
var greatPersonPoints: Stats? = null
|
||||
/** Extra cost percentage when purchasing */
|
||||
@JvmField var hurryCostModifier: Int = 0
|
||||
@JvmField var isWonder = false
|
||||
@JvmField var requiredBuilding: String? = null
|
||||
@JvmField var requiredBuildingInAllCities: String? = null
|
||||
var hurryCostModifier: Int = 0
|
||||
var isWonder = false
|
||||
var requiredBuilding: String? = null
|
||||
var requiredBuildingInAllCities: String? = null
|
||||
/** A strategic resource that will be consumed by this building */
|
||||
@JvmField var requiredResource: String? = null
|
||||
var requiredResource: String? = null
|
||||
/** City can only be built if one of these resources is nearby - it must be improved! */
|
||||
@JvmField var requiredNearbyImprovedResources: List<String>? = null
|
||||
@JvmField var cannotBeBuiltWith: String? = null
|
||||
var requiredNearbyImprovedResources: List<String>? = null
|
||||
var cannotBeBuiltWith: String? = null
|
||||
|
||||
// Uniques
|
||||
@JvmField var providesFreeBuilding: String? = null
|
||||
@JvmField var freeTechs: Int = 0
|
||||
@JvmField var unique: String? = null // for wonders which have individual functions that are totally unique
|
||||
var providesFreeBuilding: String? = null
|
||||
var freeTechs: Int = 0
|
||||
var unique: String? = null // for wonders which have individual functions that are totally unique
|
||||
|
||||
|
||||
/**
|
||||
@ -82,7 +82,7 @@ class Building : NamedStats(), IConstruction, ICivilopedia {
|
||||
fun getDescription(forBuildingPickerScreen: Boolean, adoptedPolicies: List<String>): String {
|
||||
val stats = getStats(adoptedPolicies)
|
||||
val stringBuilder = StringBuilder()
|
||||
if (!forBuildingPickerScreen) stringBuilder.appendln("Cost: " + cost)
|
||||
if (!forBuildingPickerScreen) stringBuilder.appendln("Cost: $cost")
|
||||
if (isWonder) stringBuilder.appendln("Wonder")
|
||||
if (!forBuildingPickerScreen && requiredTech != null)
|
||||
stringBuilder.appendln("Requires $requiredTech to be researched")
|
||||
|
@ -1,14 +0,0 @@
|
||||
package com.unciv.models.gamebasics;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class StringUtils {
|
||||
public static String join(String delimiter, Collection<String> collection) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (String str : collection) {
|
||||
if (stringBuilder.length() != 0) stringBuilder.append(delimiter);
|
||||
stringBuilder.append(str);
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
@ -1,11 +1,9 @@
|
||||
package com.unciv.models.gamebasics
|
||||
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.models.stats.Stats
|
||||
import com.unciv.models.stats.NamedStats
|
||||
|
||||
import java.util.ArrayList
|
||||
import java.util.HashMap
|
||||
import com.unciv.models.stats.Stats
|
||||
import java.util.*
|
||||
|
||||
class TileImprovement : NamedStats(), ICivilopedia {
|
||||
|
||||
@ -42,7 +40,7 @@ class TileImprovement : NamedStats(), ICivilopedia {
|
||||
stringBuilder.appendln(it.key + " for " + it.value.joinToString(", "))
|
||||
}
|
||||
|
||||
if (techRequired != null) stringBuilder.appendln("Tech required: " + techRequired)
|
||||
if (techRequired != null) stringBuilder.appendln("Tech required: $techRequired")
|
||||
|
||||
return stringBuilder.toString()
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ class TileResource : NamedStats(), ICivilopedia {
|
||||
stringBuilder.appendln(this.clone().toString())
|
||||
stringBuilder.appendln("Can be found on " + terrainsCanBeFoundOn.joinToString())
|
||||
stringBuilder.appendln()
|
||||
stringBuilder.appendln("Improved by " + improvement)
|
||||
stringBuilder.appendln("Bonus stats for improvement: " + improvementStats)
|
||||
stringBuilder.appendln("Improved by $improvement")
|
||||
stringBuilder.appendln("Bonus stats for improvement: $improvementStats")
|
||||
return stringBuilder.toString()
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.models.gamebasics.Building
|
||||
import com.unciv.ui.UnCivGame
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.ui.pickerscreens.ConstructionPickerScreen
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
|
@ -7,7 +7,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.Policy
|
||||
import com.unciv.models.gamebasics.StringUtils
|
||||
import com.unciv.ui.cityscreen.addClickListener
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
@ -86,7 +85,7 @@ class PolicyPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen(
|
||||
pickedPolicy = policy
|
||||
var policyText = policy.name + "\r\n" + policy.description + "\r\n"
|
||||
if (!policy.name.endsWith("Complete") && policy.requires!!.isNotEmpty())
|
||||
policyText += "Requires " + StringUtils.join(", ", policy.requires)
|
||||
policyText += "Requires " + policy.requires!!.joinToString()
|
||||
descriptionLabel.setText(policyText)
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
||||
if(!isViewable) hexagon.color = hexagon.color.lerp(Color.BLACK,0.6f)
|
||||
|
||||
|
||||
if (tileInfo.hasViewableResource(tileInfo.tileMap!!.gameInfo!!.getPlayerCivilization()) && resourceImage == null) { // Need to add the resource image!
|
||||
if (tileInfo.hasViewableResource(tileInfo.tileMap.gameInfo.getPlayerCivilization()) && resourceImage == null) { // Need to add the resource image!
|
||||
val fileName = "ResourceIcons/" + tileInfo.resource + "_(Civ5).png"
|
||||
resourceImage = ImageGetter.getImage(fileName)
|
||||
resourceImage!!.setSize(20f, 20f)
|
||||
|
@ -6,7 +6,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.ui.UnCivGame
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.ui.cityscreen.CityScreen
|
||||
import com.unciv.ui.cityscreen.addClickListener
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
|
@ -15,7 +15,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.badlogic.gdx.utils.viewport.ExtendViewport
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.ui.UnCivGame
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.ui.cityscreen.addClickListener
|
||||
|
||||
open class CameraStageBaseScreen : Screen {
|
||||
@ -59,7 +59,7 @@ open class CameraStageBaseScreen : Screen {
|
||||
fun displayTutorials(name: String) {
|
||||
if (game.gameInfo.tutorial.contains(name)) return
|
||||
game.gameInfo.tutorial.add(name)
|
||||
val texts = GameBasics.Tutorials.get(name)!!
|
||||
val texts = GameBasics.Tutorials[name]!!
|
||||
tutorialTexts.addAll(texts)
|
||||
if (!isTutorialShowing) displayTutorial()
|
||||
}
|
||||
|
@ -4,21 +4,21 @@ import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.files.FileHandle
|
||||
import com.badlogic.gdx.utils.Json
|
||||
import com.unciv.logic.GameInfo
|
||||
import com.unciv.ui.UnCivGame
|
||||
import com.unciv.UnCivGame
|
||||
|
||||
object GameSaver {
|
||||
val saveFilesFolder = "SaveFiles"
|
||||
private const val saveFilesFolder = "SaveFiles"
|
||||
|
||||
fun GetSave(GameName: String): FileHandle {
|
||||
return Gdx.files.local(saveFilesFolder + "/" + GameName)
|
||||
fun getSave(GameName: String): FileHandle {
|
||||
return Gdx.files.local("$saveFilesFolder/$GameName")
|
||||
}
|
||||
|
||||
fun SaveGame(game: UnCivGame, GameName: String) {
|
||||
GetSave(GameName).writeString(Json().toJson(game.gameInfo), false)
|
||||
fun saveGame(game: UnCivGame, GameName: String) {
|
||||
getSave(GameName).writeString(Json().toJson(game.gameInfo), false)
|
||||
}
|
||||
|
||||
fun LoadGame(game: UnCivGame, GameName: String) {
|
||||
game.gameInfo = Json().fromJson(GameInfo::class.java, GetSave(GameName).readString())
|
||||
fun loadGame(game: UnCivGame, GameName: String) {
|
||||
game.gameInfo = Json().fromJson(GameInfo::class.java, getSave(GameName).readString())
|
||||
game.gameInfo.setTransients()
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,15 @@
|
||||
package com.unciv.ui.utils
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.Drawable
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
||||
|
||||
import java.util.HashMap
|
||||
import java.util.*
|
||||
|
||||
object ImageGetter {
|
||||
var textureRegionByFileName = HashMap<String, TextureRegion>()
|
||||
val WhiteDot = "skin/whiteDot.png"
|
||||
private var textureRegionByFileName = HashMap<String, TextureRegion>()
|
||||
const val WhiteDot = "skin/whiteDot.png"
|
||||
|
||||
fun getImage(fileName: String): Image {
|
||||
return Image(getTextureRegion(fileName))
|
||||
@ -25,10 +22,6 @@ object ImageGetter {
|
||||
return drawable
|
||||
}
|
||||
|
||||
fun getSingleColorDrawable(color: Color): Drawable {
|
||||
return getDrawable(WhiteDot).tint(color)
|
||||
}
|
||||
|
||||
private fun getTextureRegion(fileName: String): TextureRegion {
|
||||
try {
|
||||
if (!textureRegionByFileName.containsKey(fileName))
|
||||
|
@ -5,7 +5,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.unciv.logic.battle.*
|
||||
import com.unciv.logic.map.UnitType
|
||||
import com.unciv.ui.UnCivGame
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.ui.cityscreen.addClickListener
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.disable
|
||||
|
@ -118,7 +118,7 @@ class WorldScreen : CameraStageBaseScreen() {
|
||||
|
||||
game.gameInfo.nextTurn()
|
||||
unitTable.currentlyExecutingAction = null
|
||||
GameSaver.SaveGame(game, "Autosave")
|
||||
GameSaver.saveGame(game, "Autosave")
|
||||
update()
|
||||
displayTutorials("NextTurn")
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import com.unciv.logic.map.MapUnit
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.models.gamebasics.Building
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.ui.UnCivGame
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.ui.cityscreen.addClickListener
|
||||
import com.unciv.ui.pickerscreens.ImprovementPickerScreen
|
||||
import com.unciv.ui.pickerscreens.TechPickerScreen
|
||||
|
@ -53,3 +53,7 @@ task afterEclipseImport(description: "Post processing after project generation",
|
||||
printer.print(classpath)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(path: ':core')
|
||||
}
|
@ -2,9 +2,9 @@ package com.unciv.game.desktop;
|
||||
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
|
||||
import com.unciv.ui.UnCivGame;
|
||||
import com.unciv.UnCivGame;
|
||||
|
||||
public class DesktopLauncher {
|
||||
class DesktopLauncher {
|
||||
public static void main (String[] arg) {
|
||||
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
|
||||
new LwjglApplication(new UnCivGame(), config);
|
||||
|
@ -6,7 +6,7 @@ import org.robovm.apple.uikit.UIApplication;
|
||||
import com.badlogic.gdx.backends.iosrobovm.IOSApplication;
|
||||
import com.badlogic.gdx.backends.iosrobovm.IOSApplicationConfiguration;
|
||||
|
||||
public class IOSLauncher extends IOSApplication.Delegate {
|
||||
class IOSLauncher extends IOSApplication.Delegate {
|
||||
@Override
|
||||
protected IOSApplication createApplication() {
|
||||
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
|
||||
|
Reference in New Issue
Block a user