Find Natural Wonder Quest implemented (#3211)

* Find Natural Wonder Quest implemented

* List to sequence to list
This commit is contained in:
Federico Luongo
2020-10-06 12:59:54 +02:00
committed by GitHub
parent fa59d4888a
commit 1dd82f6f58
3 changed files with 20 additions and 4 deletions

View File

@ -23,7 +23,7 @@
{
"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]!",
@ -33,11 +33,11 @@
"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 */
/*
{

View File

@ -251,6 +251,7 @@ class QuestManager {
QuestName.ConnectResource.value -> data1 = getResourceForQuest(assignee)!!.name
QuestName.ConstructWonder.value -> data1 = getWonderToBuildForQuest(assignee)!!.name
QuestName.GreatPerson.value -> data1 = getGreatPersonForQuest(assignee)!!.name
QuestName.FindNaturalWonder.value -> data1 = getNaturalWonderToFindForQuest(assignee)!!
}
val newQuest = AssignedQuest(
@ -289,6 +290,7 @@ class QuestManager {
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
QuestName.FindNaturalWonder.value -> civInfo.hasEverBeenFriendWith(challenger) && getNaturalWonderToFindForQuest(challenger) != null
else -> true
}
}
@ -301,6 +303,7 @@ class QuestManager {
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 }
QuestName.FindNaturalWonder.value -> assignee.naturalWonders.contains(assignedQuest.data1)
else -> false
}
}
@ -371,6 +374,18 @@ class QuestManager {
return null
}
/**
* Returns a random [NaturalWonder] not yet discovered by [challenger].
*/
private fun getNaturalWonderToFindForQuest(challenger: CivilizationInfo): String? {
val naturalWondersToFind = civInfo.gameInfo.tileMap.naturalWonders.subtract(challenger.naturalWonders)
if (naturalWondersToFind.isNotEmpty())
return naturalWondersToFind.random()
return null
}
/**
* Returns a Great Person [BaseUnit] that is not owned by both the [challenger] and the [civInfo]
*/
@ -387,7 +402,7 @@ class QuestManager {
.distinct()
.filter { !challengerGreatPeople.contains(it) && !cityStateGreatPeople.contains(it) }
.toList()
if (greatPeople.isNotEmpty())
return greatPeople.random()

View File

@ -18,6 +18,7 @@ class TileMap {
@Transient var bottomY = 0
@delegate:Transient val maxLatitude: Float by lazy { if (values.isEmpty()) 0f else values.map { abs(it.latitude) }.max()!! }
@delegate:Transient val maxLongitude: Float by lazy { if (values.isEmpty()) 0f else values.map { abs(it.longitude) }.max()!! }
@delegate:Transient val naturalWonders: List<String> by lazy { tileList.asSequence().filter { it.isNaturalWonder() }.map { it.naturalWonder!! }.distinct().toList() }
var mapParameters = MapParameters()