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:
Yair Morgenstern 2019-04-30 19:52:27 +03:00
parent f2333b5839
commit de9ae3da54
6 changed files with 26 additions and 24 deletions

View file

@ -17,7 +17,7 @@ class UnCivGame(val version: String) : Game() {
* This exists so that when debugging we can see the entire map.
* 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
val superchargedForDebug = false

View file

@ -35,6 +35,10 @@ enum class PlayerType{
Human
}
enum class CityStateType{
Cultured
}
class TradeRequest(val requestingCiv:String,
/** Their offers are what they offer us, and our offers are what they want in return */
val trade: Trade)
@ -58,7 +62,6 @@ class CivilizationInfo {
@Deprecated("As of 2.11.1") var difficulty = "Chieftain"
var playerType = PlayerType.AI
var civName = ""
var cityStateType = ""
var tech = TechManager()
var policies = PolicyManager()
var goldenAges = GoldenAgeManager()
@ -82,7 +85,6 @@ class CivilizationInfo {
constructor(civName: String) {
this.civName = civName
tech.techsResearched.add("Agriculture") // can't be .addTechnology because the civInfo isn't assigned yet
cityStateType = GameBasics.Nations[civName]!!.cityStateType
}
fun clone(): CivilizationInfo {
@ -101,7 +103,6 @@ class CivilizationInfo {
toReturn.exploredTiles.addAll(exploredTiles)
toReturn.notifications.addAll(notifications)
toReturn.citiesCreated = citiesCreated
toReturn.cityStateType = cityStateType
return toReturn
}
@ -122,7 +123,7 @@ class CivilizationInfo {
return translatedNation
}
fun isCityState(): Boolean = (cityStateType != "")
fun isCityState(): Boolean = getNation().isCityState()
fun getDiplomacyManager(civInfo: CivilizationInfo) = diplomacy[civInfo.civName]!!
fun getKnownCivs() = diplomacy.values.map { it.otherCiv() }
@ -145,7 +146,7 @@ class CivilizationInfo {
//City states culture bonus
for (otherCivName in diplomacy.keys) {
val otherCiv = gameInfo.getCivilization(otherCivName)
if (otherCiv.isCityState() && otherCiv.diplomacy[civName]!!.attitude > 60) {
if (otherCiv.isCityState() && otherCiv.diplomacy[civName]!!.influence > 60) {
var cultureBonus = Stats()
cultureBonus.add(Stat.Culture, 5.0f * getEra().ordinal)
if (statMap.containsKey("City States"))

View file

@ -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 =(
* This is so sad Alexa play Despacito */
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 {
val toReturn = DiplomacyManager()
toReturn.otherCivName=otherCivName
toReturn.diplomaticStatus=diplomaticStatus
toReturn.trades.addAll(trades.map { it.clone() })
toReturn.attitude = attitude
toReturn.influence = influence
toReturn.flagsCountdown.putAll(flagsCountdown)
toReturn.hasOpenBorders=hasOpenBorders
return toReturn
@ -145,12 +145,10 @@ class DiplomacyManager() {
if(flagsCountdown[flag]==0) flagsCountdown.remove(flag)
}
if (attitude > 1f) {
attitude -= 1f
} else if (attitude < -1f) {
attitude += 1f
} else {
attitude = 0f
if (influence > 0) {
influence -= 1
} else if (influence < 0) {
influence += 1
}
}

View file

@ -119,10 +119,10 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci
if (currentTrade.theirOffers.isEmpty()) {
for (trade in currentTrade.ourOffers) {
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) {
otherCivilization.getDiplomacyManager(ourCivilization).attitude += trade.amount * trade.duration / 10
otherCivilization.getDiplomacyManager(ourCivilization).influence += trade.amount * trade.duration / 10
}
}
}

View file

@ -1,6 +1,7 @@
package com.unciv.models.gamebasics
import com.badlogic.gdx.graphics.Color
import com.unciv.logic.civilization.CityStateType
import com.unciv.models.stats.INamed
import com.unciv.ui.utils.colorFromRGB
@ -13,7 +14,7 @@ class Nation : INamed {
}
var leaderName=""
var cityStateType=""
var cityStateType: CityStateType?=null
var declaringWar=""
var attacked=""
var defeated=""
@ -34,6 +35,8 @@ class Nation : INamed {
if(secondaryColor==null) return Color.BLACK
return colorFromRGB(secondaryColor!![0], secondaryColor!![1], secondaryColor!![2])
}
fun isCityState(): Boolean = (cityStateType != "")
fun isCityState()=cityStateType != null
lateinit var cities: List<String>
}

View file

@ -7,7 +7,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
import com.unciv.UnCivGame
import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.trade.TradeLogic
import com.unciv.models.gamebasics.tr
import com.unciv.ui.utils.*
import com.unciv.ui.worldscreen.optionstable.PopupTable
@ -71,19 +70,20 @@ class DiplomacyScreen:CameraStageBaseScreen() {
val currentPlayerCiv = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization()
val diplomacyTable = Table()
diplomacyTable.defaults().pad(10f)
var leaderName: String
val leaderName: String
if (civ.isCityState()) {
leaderName = "City State [" + civ.civName + "]"
} else {
leaderName = "[" + civ.getNation().leaderName + "] of [" + civ.civName + "]"
}
leaderName = leaderName + " : Attitude " + civ.getDiplomacyManager(currentPlayerCiv).attitude.toInt().toString()
diplomacyTable.add(leaderName.toLabel())
diplomacyTable.addSeparator()
val tradeButton = TextButton("Trade".tr(), skin)
tradeButton.onClick { setTrade(civ) }
diplomacyTable.add(tradeButton).row()
if(!civ.isCityState()) {
val tradeButton = TextButton("Trade".tr(), skin)
tradeButton.onClick { setTrade(civ) }
diplomacyTable.add(tradeButton).row()
}
val civDiplomacy = currentPlayerCiv.getDiplomacyManager(civ)