mirror of
https://github.com/yairm210/Unciv.git
synced 2025-08-03 16:49:15 +07:00
Acquire Great Person Quest implemented (#3210)
* Acquire Great Person Quest implemented * List to sequence to list
This commit is contained in:
@ -19,11 +19,11 @@
|
||||
{
|
||||
"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": "You will be rewarded for conquering the city state of [cityState]!",
|
||||
|
@ -197,6 +197,7 @@ class CivilizationInfo {
|
||||
|
||||
//region Units
|
||||
fun getCivUnits(): Sequence<MapUnit> = units.asSequence()
|
||||
fun getCivGreatPeople(): Sequence<MapUnit> = getCivUnits().filter { mapUnit -> mapUnit.hasUnique("Great Person - []") }
|
||||
|
||||
fun addUnit(mapUnit: MapUnit, updateCivInfo:Boolean=true){
|
||||
val newList = ArrayList(units)
|
||||
|
@ -250,6 +250,7 @@ class QuestManager {
|
||||
when (quest.name) {
|
||||
QuestName.ConnectResource.value -> data1 = getResourceForQuest(assignee)!!.name
|
||||
QuestName.ConstructWonder.value -> data1 = getWonderToBuildForQuest(assignee)!!.name
|
||||
QuestName.GreatPerson.value -> data1 = getGreatPersonForQuest(assignee)!!.name
|
||||
}
|
||||
|
||||
val newQuest = AssignedQuest(
|
||||
@ -287,6 +288,7 @@ class QuestManager {
|
||||
QuestName.Route.value -> civInfo.hasEverBeenFriendWith(challenger) && !civInfo.isCapitalConnectedToCity(challenger.getCapital())
|
||||
QuestName.ConnectResource.value -> civInfo.hasEverBeenFriendWith(challenger) && getResourceForQuest(challenger) != null
|
||||
QuestName.ConstructWonder.value -> civInfo.hasEverBeenFriendWith(challenger) && getWonderToBuildForQuest(challenger) != null
|
||||
QuestName.GreatPerson.value -> civInfo.hasEverBeenFriendWith(challenger) && getGreatPersonForQuest(challenger) != null
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
@ -298,6 +300,7 @@ class QuestManager {
|
||||
QuestName.Route.value -> civInfo.isCapitalConnectedToCity(assignee.getCapital())
|
||||
QuestName.ConnectResource.value -> assignee.detailedCivResources.map { it.resource }.contains(civInfo.gameInfo.ruleSet.tileResources[assignedQuest.data1])
|
||||
QuestName.ConstructWonder.value -> assignee.cities.any { it.cityConstructions.isBuilt(assignedQuest.data1) }
|
||||
QuestName.GreatPerson.value -> assignee.getCivGreatPeople().any { it.baseUnit.getReplacedUnit(civInfo.gameInfo.ruleSet).name == assignedQuest.data1 }
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
@ -367,6 +370,30 @@ class QuestManager {
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Great Person [BaseUnit] that is not owned by both the [challenger] and the [civInfo]
|
||||
*/
|
||||
private fun getGreatPersonForQuest(challenger: CivilizationInfo): BaseUnit? {
|
||||
val ruleSet = civInfo.gameInfo.ruleSet
|
||||
|
||||
val challengerGreatPeople = challenger.getCivGreatPeople().map { it.baseUnit.getReplacedUnit(ruleSet) }
|
||||
val cityStateGreatPeople = civInfo.getCivGreatPeople().map { it.baseUnit.getReplacedUnit(ruleSet) }
|
||||
|
||||
val greatPeople = ruleSet.units.values
|
||||
.asSequence()
|
||||
.filter { baseUnit -> baseUnit.uniques.any { it.equalsPlaceholderText("Great Person - []") } }
|
||||
.map { it.getReplacedUnit(ruleSet) }
|
||||
.distinct()
|
||||
.filter { !challengerGreatPeople.contains(it) && !cityStateGreatPeople.contains(it) }
|
||||
.toList()
|
||||
|
||||
if (greatPeople.isNotEmpty())
|
||||
return greatPeople.random()
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
//endregion
|
||||
}
|
||||
|
||||
|
@ -195,4 +195,9 @@ class BaseUnit : INamed, IConstruction {
|
||||
}
|
||||
|
||||
override fun toString(): String = name
|
||||
|
||||
fun getReplacedUnit(ruleset: Ruleset): BaseUnit {
|
||||
return if (replaces == null) this
|
||||
else ruleset.units[replaces!!]!!
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user