Moddable quest weighting for city-states

This commit is contained in:
Yair Morgenstern 2022-11-19 23:54:16 +02:00
parent 2d5536e8be
commit e5fbb472b0
5 changed files with 302 additions and 230 deletions

View File

@ -2,74 +2,141 @@
{
"name": "Route",
"description": "Build a road to connect your capital to our city.",
"influence": 50
"influence": 50,
"weightForCityStateType": {
"Friendly": 2,
"Hostile": 0.2,
"Maritime": 1.2,
"Mercantile": 1.5
}
},
{
"name": "Clear Barbarian Camp",
"description": "We feel threatened by a Barbarian Camp near our city. Please take care of it.",
"type": "Global",
"influence": 50,
"minimumCivs": 1
"minimumCivs": 1,
"weightForCityStateType": {
"Cultured": 3,
"Maritime": 3,
"Mercantile": 3,
"Militaristic": 9,
"Religious": 3
}
},
{
"name": "Connect Resource",
"description": "In order to make our civilizations stronger, connect [tileResource] to your trade network."
"description": "In order to make our civilizations stronger, connect [tileResource] to your trade network.",
"weightForCityStateType": {
"Maritime": 2,
"Mercantile": 3
}
},
{
"name": "Construct Wonder",
"description": "We recommend you to start building [wonder] to show the whole world your civilization strength."
"description": "We recommend you to start building [wonder] to show the whole world your civilization strength.",
"weightForCityStateType": {
"Cultured": 3
}
},
{
"name": "Acquire Great Person",
"description": "Great People can change the course of a Civilization! You will be rewarded for acquiring a new [greatPerson]."
"description": "Great People can change the course of a Civilization! You will be rewarded for acquiring a new [greatPerson].",
"weightForCityStateType": {
"Cultured": 3
}
},
{
"name": "Conquer City State",
"description": "It's time to erase the City-State of [cityState] from the map. You will be greatly rewarded for conquering them!",
"influence": 80
"influence": 80,
"weightForCityStateType": {
"Hostile": 2,
"Friendly": 0.2,
"Militaristic": 2
}
},
{
"name": "Find Player",
"description": "You have yet to discover where [civName] set up their cities. You will be rewarded for finding their territories.",
"influence": 35
"influence": 35,
"weightForCityStateType": {
"Maritime": 3,
"Mercantile": 2
}
},
{
"name": "Find Natural Wonder",
"description": "Send your best explorers on a quest to discover Natural Wonders. Nobody knows the location of [naturalWonder] yet."
"description": "Send your best explorers on a quest to discover Natural Wonders. Nobody knows the location of [naturalWonder] yet.",
"weightForCityStateType": {
"Hostile": 0.3,
"Militaristic": 0.5
}
},
/* G&K */
{
"name": "Give Gold",
"description": "We are suffering great poverty after being robbed by [civName], and unless we receive a sum of Gold, it's only a matter of time before we collapse.",
"influence": 20,
"duration": 30
"duration": 30,
"weightForCityStateType": {
"Cultured": 3,
"Maritime": 3,
"Mercantile": 3.5,
"Militaristic": 2,
"Religious": 3
}
},
{
"name": "Pledge to Protect",
"description": "We need your protection to stop the aggressions of [civName]. By signing a Pledge of Protection, you'll confirm the bond that ties us.",
"influence": 20,
"duration": 30
"duration": 30,
"weightForCityStateType": {
"Cultured": 3.5,
"Maritime": 3,
"Mercantile": 3,
"Militaristic": 2,
"Religious": 3
}
},
{
"name": "Contest Culture",
"description": "The civilization with the largest Culture growth will gain a reward.",
"type": "Global",
"duration": 30,
"minimumCivs": 3
"minimumCivs": 3,
"weightForCityStateType": {
"Cultured": 2,
"Maritime": 0.5,
"Mercantile": 0.5,
"Militaristic": 0.5,
"Religious": 0.5
}
},
{
"name": "Contest Faith",
"description": "The civilization with the largest Faith growth will gain a reward.",
"type": "Global",
"duration": 30,
"minimumCivs": 3
"minimumCivs": 3,
"weightForCityStateType": {
"Cultured": 0.5,
"Maritime": 0.5,
"Mercantile": 0.5,
"Militaristic": 0.5,
"Religious": 2
}
},
{
"name": "Contest Technologies",
"description": "The civilization with the largest number of new Technologies researched will gain a reward.",
"type": "Global",
"duration": 30,
"minimumCivs": 3
"minimumCivs": 3,
"weightForCityStateType": {
"Religious": 0.5
}
},
{
"name": "Invest",
@ -77,21 +144,39 @@
"type": "Global",
"influence": 0,
"duration": 30,
"minimumCivs": 2
"minimumCivs": 2,
"weightForCityStateType": {
"Mercantile": 1.5
}
},
{
"name": "Bully City State",
"description": "We are tired of the pretensions of [cityState]. If someone were to put them in their place by Demanding Tribute from them, they would be rewarded.",
"duration": 30
"duration": 30,
"weightForCityStateType": {
"Hostile": 2,
"Irrational": 1.5,
"Friendly": 0.3
}
},
{
"name": "Denounce Civilization",
"description": "We have been forced to pay tribute to [civName]! We need you to tell the world of their ill deeds.",
"duration": 30
"duration": 30,
"weightForCityStateType": {
"Cultured": 1.5,
"Maritime": 2,
"Mercantile": 1.5,
"Militaristic": 1.5,
"Religious": 2.5
}
},
{
"name": "Spread Religion",
"description": "We have heard the tenets of [religionName] and are most curious. Will you send missionaries to teach us about your religion?"
"description": "We have heard the tenets of [religionName] and are most curious. Will you send missionaries to teach us about your religion?",
"weightForCityStateType": {
"Religious": 3
}
}
/* BNW */
/*

View File

@ -1,103 +1,188 @@
[
{
"name": "Route",
"description": "Build a road to connect your capital to our city.",
"influence": 50
},
{
"name": "Clear Barbarian Camp",
"description": "We feel threatened by a Barbarian Camp near our city. Please take care of it.",
"type": "Global",
"influence": 50,
"minimumCivs": 1
},
{
"name": "Connect Resource",
"description": "In order to make our civilizations stronger, connect [tileResource] to your trade network."
},
{
"name": "Construct Wonder",
"description": "We recommend you to start building [wonder] to show the whole world your civilization strength."
},
{
"name": "Acquire Great Person",
"description": "Great People can change the course of a Civilization! You will be rewarded for acquiring a new [greatPerson]."
},
{
"name": "Conquer City State",
"description": "It's time to erase the City-State of [cityState] from the map. You will be greatly rewarded for conquering them!",
"influence": 80
},
{
"name": "Find Player",
"description": "You have yet to discover where [civName] set up their cities. You will be rewarded for finding their territories.",
"influence": 35
},
{
"name": "Find Natural Wonder",
"description": "Send your best explorers on a quest to discover Natural Wonders. Nobody knows the location of [naturalWonder] yet."
},
/* G&K */
{
"name": "Give Gold",
"description": "We are suffering great poverty after being robbed by [civName], and unless we receive a sum of Gold, it's only a matter of time before we collapse.",
"influence": 20,
"duration": 30
},
{
"name": "Pledge to Protect",
"description": "We need your protection to stop the aggressions of [civName]. By signing a Pledge of Protection, you'll confirm the bond that ties us.",
"influence": 20,
"duration": 30
},
{
"name": "Contest Culture",
"description": "The civilization with the largest Culture growth will gain a reward.",
"type": "Global",
"duration": 30,
"minimumCivs": 3
},
{
"name": "Contest Faith",
"description": "The civilization with the largest Faith growth will gain a reward.",
"type": "Global",
"duration": 30,
"minimumCivs": 3
},
{
"name": "Contest Technologies",
"description": "The civilization with the largest number of new Technologies researched will gain a reward.",
"type": "Global",
"duration": 30,
"minimumCivs": 3
},
{
"name": "Invest",
"description": "Our people are rejoicing thanks to a tourism boom. For a certain amount of time, any Gold donation will yield [50]% extra Influence.",
"type": "Global",
"influence": 0,
"duration": 30,
"minimumCivs": 2
},
{
"name": "Bully City State",
"description": "We are tired of the pretensions of [cityState]. If someone were to put them in their place by Demanding Tribute from them, they would be rewarded.",
"duration": 30
},
{
"name": "Denounce Civilization",
"description": "We have been forced to pay tribute to [civName]! We need you to tell the world of their ill deeds.",
"duration": 30
},
{
"name": "Spread Religion",
"description": "We have heard the tenets of [religionName] and are most curious. Will you send missionaries to teach us about your religion?"
}
/* BNW */
/*
{
"name": "Trade Route",
"description": ""
}
*/
{
"name": "Route",
"description": "Build a road to connect your capital to our city.",
"influence": 50,
"weightForCityStateType": {
"Friendly": 2,
"Hostile": 0.2,
"Maritime": 1.2,
"Mercantile": 1.5
}
},
{
"name": "Clear Barbarian Camp",
"description": "We feel threatened by a Barbarian Camp near our city. Please take care of it.",
"type": "Global",
"influence": 50,
"minimumCivs": 1,
"weightForCityStateType": {
"Cultured": 3,
"Maritime": 3,
"Mercantile": 3,
"Militaristic": 9,
"Religious": 3
}
},
{
"name": "Connect Resource",
"description": "In order to make our civilizations stronger, connect [tileResource] to your trade network.",
"weightForCityStateType": {
"Maritime": 2,
"Mercantile": 3
}
},
{
"name": "Construct Wonder",
"description": "We recommend you to start building [wonder] to show the whole world your civilization strength.",
"weightForCityStateType": {
"Cultured": 3
}
},
{
"name": "Acquire Great Person",
"description": "Great People can change the course of a Civilization! You will be rewarded for acquiring a new [greatPerson].",
"weightForCityStateType": {
"Cultured": 3
}
},
{
"name": "Conquer City State",
"description": "It's time to erase the City-State of [cityState] from the map. You will be greatly rewarded for conquering them!",
"influence": 80,
"weightForCityStateType": {
"Hostile": 2,
"Friendly": 0.2,
"Militaristic": 2
}
},
{
"name": "Find Player",
"description": "You have yet to discover where [civName] set up their cities. You will be rewarded for finding their territories.",
"influence": 35,
"weightForCityStateType": {
"Maritime": 3,
"Mercantile": 2
}
},
{
"name": "Find Natural Wonder",
"description": "Send your best explorers on a quest to discover Natural Wonders. Nobody knows the location of [naturalWonder] yet.",
"weightForCityStateType": {
"Hostile": 0.3,
"Militaristic": 0.5
}
},
/* G&K */
{
"name": "Give Gold",
"description": "We are suffering great poverty after being robbed by [civName], and unless we receive a sum of Gold, it's only a matter of time before we collapse.",
"influence": 20,
"duration": 30,
"weightForCityStateType": {
"Cultured": 3,
"Maritime": 3,
"Mercantile": 3.5,
"Militaristic": 2,
"Religious": 3
}
},
{
"name": "Pledge to Protect",
"description": "We need your protection to stop the aggressions of [civName]. By signing a Pledge of Protection, you'll confirm the bond that ties us.",
"influence": 20,
"duration": 30,
"weightForCityStateType": {
"Cultured": 3.5,
"Maritime": 3,
"Mercantile": 3,
"Militaristic": 2,
"Religious": 3
}
},
{
"name": "Contest Culture",
"description": "The civilization with the largest Culture growth will gain a reward.",
"type": "Global",
"duration": 30,
"minimumCivs": 3,
"weightForCityStateType": {
"Cultured": 2,
"Maritime": 0.5,
"Mercantile": 0.5,
"Militaristic": 0.5,
"Religious": 0.5
}
},
{
"name": "Contest Faith",
"description": "The civilization with the largest Faith growth will gain a reward.",
"type": "Global",
"duration": 30,
"minimumCivs": 3,
"weightForCityStateType": {
"Cultured": 0.5,
"Maritime": 0.5,
"Mercantile": 0.5,
"Militaristic": 0.5,
"Religious": 2
}
},
{
"name": "Contest Technologies",
"description": "The civilization with the largest number of new Technologies researched will gain a reward.",
"type": "Global",
"duration": 30,
"minimumCivs": 3,
"weightForCityStateType": {
"Religious": 0.5
}
},
{
"name": "Invest",
"description": "Our people are rejoicing thanks to a tourism boom. For a certain amount of time, any Gold donation will yield [50]% extra Influence.",
"type": "Global",
"influence": 0,
"duration": 30,
"minimumCivs": 2,
"weightForCityStateType": {
"Mercantile": 1.5
}
},
{
"name": "Bully City State",
"description": "We are tired of the pretensions of [cityState]. If someone were to put them in their place by Demanding Tribute from them, they would be rewarded.",
"duration": 30,
"weightForCityStateType": {
"Hostile": 2,
"Irrational": 1.5,
"Friendly": 0.3
}
},
{
"name": "Denounce Civilization",
"description": "We have been forced to pay tribute to [civName]! We need you to tell the world of their ill deeds.",
"duration": 30,
"weightForCityStateType": {
"Cultured": 1.5,
"Maritime": 2,
"Mercantile": 1.5,
"Militaristic": 1.5,
"Religious": 2.5
}
},
{
"name": "Spread Religion",
"description": "We have heard the tenets of [religionName] and are most curious. Will you send missionaries to teach us about your religion?",
"weightForCityStateType": {
"Religious": 3
}
}
/* BNW */
/*
{
"name": "Trade Route",
"description": ""
}
*/
]

View File

@ -11,7 +11,6 @@ import com.unciv.logic.city.CityInfo
import com.unciv.logic.city.INonPerpetualConstruction
import com.unciv.logic.city.PerpetualConstruction
import com.unciv.logic.civilization.AlertType
import com.unciv.logic.civilization.CityStateType
import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.civilization.NotificationIcon
import com.unciv.logic.civilization.PlayerType
@ -289,7 +288,7 @@ object NextTurnAutomation {
if (civInfo.wantsToFocusOn(Victory.Focus.Culture)) {
for (cityState in civInfo.getKnownCivs()
.filter { it.isCityState() && it.cityStateType == CityStateType.Cultured }) {
.filter { it.isCityState() && it.cityStateFunctions.canGiveStat(Stat.Culture) }) {
val diploManager = cityState.getDiplomacyManager(civInfo)
if (diploManager.getInfluence() < 40) { // we want to gain influence with them
tryGainInfluence(civInfo, cityState)

View File

@ -641,115 +641,13 @@ class QuestManager : IsPartOfGameInfoSerialization {
*/
private fun getQuestWeight(questName: String): Float {
var weight = 1f
val trait = civInfo.cityStateType
val personality = civInfo.cityStatePersonality
when (questName) {
QuestName.Route.value -> {
when (personality) {
CityStatePersonality.Friendly -> weight *= 2f
CityStatePersonality.Hostile -> weight *= .2f
else -> {}
}
when (trait) {
CityStateType.Maritime -> weight *= 1.2f
CityStateType.Mercantile -> weight *= 1.5f
else -> {}
}
}
QuestName.ConnectResource.value -> {
when (trait) {
CityStateType.Maritime -> weight *= 2f
CityStateType.Mercantile -> weight *= 3f
else -> {}
}
}
QuestName.ConstructWonder.value -> {
if (trait == CityStateType.Cultured)
weight *= 3f
}
QuestName.GreatPerson.value -> {
if (trait == CityStateType.Cultured)
weight *= 3f
}
QuestName.ConquerCityState.value -> {
if (trait == CityStateType.Militaristic)
weight *= 2f
when (personality) {
CityStatePersonality.Hostile -> weight *= 2f
CityStatePersonality.Neutral -> weight *= .4f
else -> {}
}
}
QuestName.FindPlayer.value -> {
when (trait) {
CityStateType.Maritime -> weight *= 3f
CityStateType.Mercantile -> weight *= 2f
else -> {}
}
}
QuestName.FindNaturalWonder.value -> {
if (trait == CityStateType.Militaristic)
weight *= .5f
if (personality == CityStatePersonality.Hostile)
weight *= .3f
}
QuestName.ClearBarbarianCamp.value -> {
weight *= 3f
if (trait == CityStateType.Militaristic)
weight *= 3f
}
QuestName.GiveGold.value -> {
weight *= when (trait) {
CityStateType.Militaristic -> 2f
CityStateType.Mercantile -> 3.5f
else -> 3f
}
}
QuestName.PledgeToProtect.value -> {
weight *= when (trait) {
CityStateType.Militaristic -> 2f
CityStateType.Cultured -> 3.5f
else -> 3f
}
}
QuestName.BullyCityState.value -> {
when (personality) {
CityStatePersonality.Hostile -> weight *= 2f
CityStatePersonality.Irrational -> weight *= 1.5f
CityStatePersonality.Friendly -> weight *= .3f
CityStatePersonality.Neutral -> {}
}
}
QuestName.DenounceCiv.value -> {
weight *= when (trait) {
CityStateType.Religious -> 2.5f
CityStateType.Maritime -> 2f
else -> 1.5f
}
}
QuestName.SpreadReligion.value -> {
if (trait == CityStateType.Religious)
weight *= 3f
}
QuestName.ContestCulture.value -> {
if (trait == CityStateType.Cultured)
weight *= 2f
}
QuestName.ContestFaith.value -> {
weight *= when (trait) {
CityStateType.Religious -> 2f
else -> .5f
}
}
QuestName.ContestTech.value -> {
if (trait == CityStateType.Religious)
weight *= .5f
}
QuestName.Invest.value -> {
if (trait == CityStateType.Mercantile)
weight *= 1.5f
}
}
val quest = civInfo.gameInfo.ruleSet.quests[questName] ?: return 0f
val personalityWeight = quest.weightForCityStateType[civInfo.cityStatePersonality.name]
if (personalityWeight != null) weight *= personalityWeight
val traitWeight = quest.weightForCityStateType[civInfo.cityStateType.name]
if (traitWeight != null) weight *= traitWeight
return weight
}

View File

@ -50,7 +50,12 @@ class Quest : INamed {
* quests [type]. */
var minimumCivs: Int = 1
/** Certain city states are more likely to give certain quests
* This is based on both personality and city-state type
* Both are mapped here as 'how much to multiply the weight of this quest for this kind of city-state' */
var weightForCityStateType = HashMap<String, Float>()
/** Checks if [this] is a Global quest */
fun isGlobal(): Boolean = type == QuestType.Global
fun isIndividual(): Boolean = !isGlobal()
}
}