mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 06:51:30 -04:00
City state type is now an enum
Attitude is now Influence and is an Int, not a float Can no longer trade with city states (All as per original Civ)
This commit is contained in:
parent
f2333b5839
commit
de9ae3da54
@ -17,7 +17,7 @@ class UnCivGame(val version: String) : Game() {
|
|||||||
* This exists so that when debugging we can see the entire map.
|
* This exists so that when debugging we can see the entire map.
|
||||||
* Remember to turn this to false before commit and upload!
|
* Remember to turn this to false before commit and upload!
|
||||||
*/
|
*/
|
||||||
val viewEntireMapForDebug = false
|
val viewEntireMapForDebug = true
|
||||||
|
|
||||||
// For when you need to test something in an advanced game and don't have time to faff around
|
// For when you need to test something in an advanced game and don't have time to faff around
|
||||||
val superchargedForDebug = false
|
val superchargedForDebug = false
|
||||||
|
@ -35,6 +35,10 @@ enum class PlayerType{
|
|||||||
Human
|
Human
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class CityStateType{
|
||||||
|
Cultured
|
||||||
|
}
|
||||||
|
|
||||||
class TradeRequest(val requestingCiv:String,
|
class TradeRequest(val requestingCiv:String,
|
||||||
/** Their offers are what they offer us, and our offers are what they want in return */
|
/** Their offers are what they offer us, and our offers are what they want in return */
|
||||||
val trade: Trade)
|
val trade: Trade)
|
||||||
@ -58,7 +62,6 @@ class CivilizationInfo {
|
|||||||
@Deprecated("As of 2.11.1") var difficulty = "Chieftain"
|
@Deprecated("As of 2.11.1") var difficulty = "Chieftain"
|
||||||
var playerType = PlayerType.AI
|
var playerType = PlayerType.AI
|
||||||
var civName = ""
|
var civName = ""
|
||||||
var cityStateType = ""
|
|
||||||
var tech = TechManager()
|
var tech = TechManager()
|
||||||
var policies = PolicyManager()
|
var policies = PolicyManager()
|
||||||
var goldenAges = GoldenAgeManager()
|
var goldenAges = GoldenAgeManager()
|
||||||
@ -82,7 +85,6 @@ class CivilizationInfo {
|
|||||||
constructor(civName: String) {
|
constructor(civName: String) {
|
||||||
this.civName = civName
|
this.civName = civName
|
||||||
tech.techsResearched.add("Agriculture") // can't be .addTechnology because the civInfo isn't assigned yet
|
tech.techsResearched.add("Agriculture") // can't be .addTechnology because the civInfo isn't assigned yet
|
||||||
cityStateType = GameBasics.Nations[civName]!!.cityStateType
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clone(): CivilizationInfo {
|
fun clone(): CivilizationInfo {
|
||||||
@ -101,7 +103,6 @@ class CivilizationInfo {
|
|||||||
toReturn.exploredTiles.addAll(exploredTiles)
|
toReturn.exploredTiles.addAll(exploredTiles)
|
||||||
toReturn.notifications.addAll(notifications)
|
toReturn.notifications.addAll(notifications)
|
||||||
toReturn.citiesCreated = citiesCreated
|
toReturn.citiesCreated = citiesCreated
|
||||||
toReturn.cityStateType = cityStateType
|
|
||||||
return toReturn
|
return toReturn
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +123,7 @@ class CivilizationInfo {
|
|||||||
return translatedNation
|
return translatedNation
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isCityState(): Boolean = (cityStateType != "")
|
fun isCityState(): Boolean = getNation().isCityState()
|
||||||
fun getDiplomacyManager(civInfo: CivilizationInfo) = diplomacy[civInfo.civName]!!
|
fun getDiplomacyManager(civInfo: CivilizationInfo) = diplomacy[civInfo.civName]!!
|
||||||
fun getKnownCivs() = diplomacy.values.map { it.otherCiv() }
|
fun getKnownCivs() = diplomacy.values.map { it.otherCiv() }
|
||||||
|
|
||||||
@ -145,7 +146,7 @@ class CivilizationInfo {
|
|||||||
//City states culture bonus
|
//City states culture bonus
|
||||||
for (otherCivName in diplomacy.keys) {
|
for (otherCivName in diplomacy.keys) {
|
||||||
val otherCiv = gameInfo.getCivilization(otherCivName)
|
val otherCiv = gameInfo.getCivilization(otherCivName)
|
||||||
if (otherCiv.isCityState() && otherCiv.diplomacy[civName]!!.attitude > 60) {
|
if (otherCiv.isCityState() && otherCiv.diplomacy[civName]!!.influence > 60) {
|
||||||
var cultureBonus = Stats()
|
var cultureBonus = Stats()
|
||||||
cultureBonus.add(Stat.Culture, 5.0f * getEra().ordinal)
|
cultureBonus.add(Stat.Culture, 5.0f * getEra().ordinal)
|
||||||
if (statMap.containsKey("City States"))
|
if (statMap.containsKey("City States"))
|
||||||
|
@ -28,14 +28,14 @@ class DiplomacyManager() {
|
|||||||
* The JSON serialize/deserialize REFUSES to deserialize hashmap keys as Enums, so I'm forced to use strings instead =(
|
* The JSON serialize/deserialize REFUSES to deserialize hashmap keys as Enums, so I'm forced to use strings instead =(
|
||||||
* This is so sad Alexa play Despacito */
|
* This is so sad Alexa play Despacito */
|
||||||
var flagsCountdown = HashMap<String,Int>()
|
var flagsCountdown = HashMap<String,Int>()
|
||||||
var attitude: Float = 0f //positive means our civ is friendly to the other civ
|
var influence: Int = 0 // For city states
|
||||||
|
|
||||||
fun clone(): DiplomacyManager {
|
fun clone(): DiplomacyManager {
|
||||||
val toReturn = DiplomacyManager()
|
val toReturn = DiplomacyManager()
|
||||||
toReturn.otherCivName=otherCivName
|
toReturn.otherCivName=otherCivName
|
||||||
toReturn.diplomaticStatus=diplomaticStatus
|
toReturn.diplomaticStatus=diplomaticStatus
|
||||||
toReturn.trades.addAll(trades.map { it.clone() })
|
toReturn.trades.addAll(trades.map { it.clone() })
|
||||||
toReturn.attitude = attitude
|
toReturn.influence = influence
|
||||||
toReturn.flagsCountdown.putAll(flagsCountdown)
|
toReturn.flagsCountdown.putAll(flagsCountdown)
|
||||||
toReturn.hasOpenBorders=hasOpenBorders
|
toReturn.hasOpenBorders=hasOpenBorders
|
||||||
return toReturn
|
return toReturn
|
||||||
@ -145,12 +145,10 @@ class DiplomacyManager() {
|
|||||||
if(flagsCountdown[flag]==0) flagsCountdown.remove(flag)
|
if(flagsCountdown[flag]==0) flagsCountdown.remove(flag)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attitude > 1f) {
|
if (influence > 0) {
|
||||||
attitude -= 1f
|
influence -= 1
|
||||||
} else if (attitude < -1f) {
|
} else if (influence < 0) {
|
||||||
attitude += 1f
|
influence += 1
|
||||||
} else {
|
|
||||||
attitude = 0f
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -119,10 +119,10 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci
|
|||||||
if (currentTrade.theirOffers.isEmpty()) {
|
if (currentTrade.theirOffers.isEmpty()) {
|
||||||
for (trade in currentTrade.ourOffers) {
|
for (trade in currentTrade.ourOffers) {
|
||||||
if (trade.type == TradeType.Gold) {
|
if (trade.type == TradeType.Gold) {
|
||||||
otherCivilization.getDiplomacyManager(ourCivilization).attitude += trade.amount / 10
|
otherCivilization.getDiplomacyManager(ourCivilization).influence += trade.amount / 10
|
||||||
}
|
}
|
||||||
if (trade.type == TradeType.Gold_Per_Turn) {
|
if (trade.type == TradeType.Gold_Per_Turn) {
|
||||||
otherCivilization.getDiplomacyManager(ourCivilization).attitude += trade.amount * trade.duration / 10
|
otherCivilization.getDiplomacyManager(ourCivilization).influence += trade.amount * trade.duration / 10
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.unciv.models.gamebasics
|
package com.unciv.models.gamebasics
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.unciv.logic.civilization.CityStateType
|
||||||
import com.unciv.models.stats.INamed
|
import com.unciv.models.stats.INamed
|
||||||
import com.unciv.ui.utils.colorFromRGB
|
import com.unciv.ui.utils.colorFromRGB
|
||||||
|
|
||||||
@ -13,7 +14,7 @@ class Nation : INamed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var leaderName=""
|
var leaderName=""
|
||||||
var cityStateType=""
|
var cityStateType: CityStateType?=null
|
||||||
var declaringWar=""
|
var declaringWar=""
|
||||||
var attacked=""
|
var attacked=""
|
||||||
var defeated=""
|
var defeated=""
|
||||||
@ -34,6 +35,8 @@ class Nation : INamed {
|
|||||||
if(secondaryColor==null) return Color.BLACK
|
if(secondaryColor==null) return Color.BLACK
|
||||||
return colorFromRGB(secondaryColor!![0], secondaryColor!![1], secondaryColor!![2])
|
return colorFromRGB(secondaryColor!![0], secondaryColor!![1], secondaryColor!![2])
|
||||||
}
|
}
|
||||||
fun isCityState(): Boolean = (cityStateType != "")
|
|
||||||
|
fun isCityState()=cityStateType != null
|
||||||
|
|
||||||
lateinit var cities: List<String>
|
lateinit var cities: List<String>
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||||
import com.unciv.UnCivGame
|
import com.unciv.UnCivGame
|
||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
import com.unciv.logic.trade.TradeLogic
|
|
||||||
import com.unciv.models.gamebasics.tr
|
import com.unciv.models.gamebasics.tr
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
import com.unciv.ui.worldscreen.optionstable.PopupTable
|
import com.unciv.ui.worldscreen.optionstable.PopupTable
|
||||||
@ -71,19 +70,20 @@ class DiplomacyScreen:CameraStageBaseScreen() {
|
|||||||
val currentPlayerCiv = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization()
|
val currentPlayerCiv = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization()
|
||||||
val diplomacyTable = Table()
|
val diplomacyTable = Table()
|
||||||
diplomacyTable.defaults().pad(10f)
|
diplomacyTable.defaults().pad(10f)
|
||||||
var leaderName: String
|
val leaderName: String
|
||||||
if (civ.isCityState()) {
|
if (civ.isCityState()) {
|
||||||
leaderName = "City State [" + civ.civName + "]"
|
leaderName = "City State [" + civ.civName + "]"
|
||||||
} else {
|
} else {
|
||||||
leaderName = "[" + civ.getNation().leaderName + "] of [" + civ.civName + "]"
|
leaderName = "[" + civ.getNation().leaderName + "] of [" + civ.civName + "]"
|
||||||
}
|
}
|
||||||
leaderName = leaderName + " : Attitude " + civ.getDiplomacyManager(currentPlayerCiv).attitude.toInt().toString()
|
|
||||||
diplomacyTable.add(leaderName.toLabel())
|
diplomacyTable.add(leaderName.toLabel())
|
||||||
diplomacyTable.addSeparator()
|
diplomacyTable.addSeparator()
|
||||||
|
|
||||||
val tradeButton = TextButton("Trade".tr(), skin)
|
if(!civ.isCityState()) {
|
||||||
tradeButton.onClick { setTrade(civ) }
|
val tradeButton = TextButton("Trade".tr(), skin)
|
||||||
diplomacyTable.add(tradeButton).row()
|
tradeButton.onClick { setTrade(civ) }
|
||||||
|
diplomacyTable.add(tradeButton).row()
|
||||||
|
}
|
||||||
|
|
||||||
val civDiplomacy = currentPlayerCiv.getDiplomacyManager(civ)
|
val civDiplomacy = currentPlayerCiv.getDiplomacyManager(civ)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user