mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 22:06:05 -04:00
Quest fixes (#5629)
* quest fixes * strings * better placeholder for competitions
This commit is contained in:
parent
cafbf0d155
commit
0a0881d5bd
@ -631,6 +631,8 @@ By expending your [unit] you gained [Stats]! =
|
|||||||
Clearing a [forest] has created [amount] Production for [cityName] =
|
Clearing a [forest] has created [amount] Production for [cityName] =
|
||||||
[civName] assigned you a new quest: [questName]. =
|
[civName] assigned you a new quest: [questName]. =
|
||||||
[civName] rewarded you with [influence] influence for completing the [questName] quest. =
|
[civName] rewarded you with [influence] influence for completing the [questName] quest. =
|
||||||
|
[civName] no longer needs your help with the [questName] quest. =
|
||||||
|
The [questName] quest for [civName] has ended. It was won by [civNames]. =
|
||||||
The resistance in [cityName] has ended! =
|
The resistance in [cityName] has ended! =
|
||||||
Our [name] took [tileDamage] tile damage and was destroyed =
|
Our [name] took [tileDamage] tile damage and was destroyed =
|
||||||
Our [name] took [tileDamage] tile damage =
|
Our [name] took [tileDamage] tile damage =
|
||||||
|
@ -16,6 +16,7 @@ import com.unciv.models.ruleset.unique.UniqueType
|
|||||||
import com.unciv.models.ruleset.unit.BaseUnit
|
import com.unciv.models.ruleset.unit.BaseUnit
|
||||||
import com.unciv.models.translations.fillPlaceholders
|
import com.unciv.models.translations.fillPlaceholders
|
||||||
import com.unciv.models.translations.getPlaceholderParameters
|
import com.unciv.models.translations.getPlaceholderParameters
|
||||||
|
import com.unciv.models.translations.tr
|
||||||
import com.unciv.ui.utils.randomWeighted
|
import com.unciv.ui.utils.randomWeighted
|
||||||
import com.unciv.ui.utils.toPercent
|
import com.unciv.ui.utils.toPercent
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
@ -242,12 +243,11 @@ class QuestManager {
|
|||||||
if (quests.isEmpty())
|
if (quests.isEmpty())
|
||||||
return
|
return
|
||||||
|
|
||||||
val topScore = quests.map { getScoreForQuest(it) }.maxOrNull()!!
|
val topScore = quests.maxOf { getScoreForQuest(it) }
|
||||||
|
val winners = quests.filter { getScoreForQuest(it) == topScore }
|
||||||
for (quest in quests) {
|
winners.forEach { giveReward(it) }
|
||||||
if (getScoreForQuest(quest) >= topScore)
|
for (loser in quests.filterNot { it in winners })
|
||||||
giveReward(quest)
|
notifyExpired(loser, winners)
|
||||||
}
|
|
||||||
|
|
||||||
assignedQuests.removeAll(quests)
|
assignedQuests.removeAll(quests)
|
||||||
}
|
}
|
||||||
@ -278,11 +278,15 @@ class QuestManager {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isObsolete(assignedQuest))
|
if (isObsolete(assignedQuest)) {
|
||||||
|
notifyExpired(assignedQuest)
|
||||||
return true
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
if (assignedQuest.isExpired())
|
if (assignedQuest.isExpired()) {
|
||||||
|
notifyExpired(assignedQuest)
|
||||||
return true
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -433,6 +437,21 @@ class QuestManager {
|
|||||||
city.cityStats.update()
|
city.cityStats.update()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Notifies the assignee of [assignedQuest] that the quest is now obsolete or expired.
|
||||||
|
* Optionally displays the [winners] of global quests. */
|
||||||
|
private fun notifyExpired(assignedQuest: AssignedQuest, winners: List<AssignedQuest> = emptyList()) {
|
||||||
|
val assignee = civInfo.gameInfo.getCivilization(assignedQuest.assignee)
|
||||||
|
if (winners.isEmpty()) {
|
||||||
|
assignee.addNotification(
|
||||||
|
"[${civInfo.civName}] no longer needs your help with the [${assignedQuest.questName}] quest.",
|
||||||
|
civInfo.getCapital().location, civInfo.civName, "OtherIcons/Quest")
|
||||||
|
} else {
|
||||||
|
assignee.addNotification(
|
||||||
|
"The [${assignedQuest.questName}] quest for [${civInfo.civName}] has ended. It was won by [${winners.joinToString { it.assignee.tr() }}].",
|
||||||
|
civInfo.getCapital().location, civInfo.civName, "OtherIcons/Quest")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns the score for the [assignedQuest] */
|
/** Returns the score for the [assignedQuest] */
|
||||||
private fun getScoreForQuest(assignedQuest: AssignedQuest): Int {
|
private fun getScoreForQuest(assignedQuest: AssignedQuest): Int {
|
||||||
val assignee = civInfo.gameInfo.getCivilization(assignedQuest.assignee)
|
val assignee = civInfo.gameInfo.getCivilization(assignedQuest.assignee)
|
||||||
@ -451,9 +470,9 @@ class QuestManager {
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
return when (questName){
|
return when (questName){
|
||||||
QuestName.ContestCulture.value -> "Current leader is ${leadingQuest.assignee} with ${getScoreForQuest(leadingQuest)} [Culture] generated."
|
QuestName.ContestCulture.value -> "Current leader is [${leadingQuest.assignee}] with [${getScoreForQuest(leadingQuest)}] [Culture] generated."
|
||||||
QuestName.ContestFaith.value -> "Current leader is ${leadingQuest.assignee} with ${getScoreForQuest(leadingQuest)} [Faith] generated."
|
QuestName.ContestFaith.value -> "Current leader is [${leadingQuest.assignee}] with [${getScoreForQuest(leadingQuest)}] [Faith] generated."
|
||||||
QuestName.ContestTech.value -> "Current leader is ${leadingQuest.assignee} with ${getScoreForQuest(leadingQuest)} Technologies discovered."
|
QuestName.ContestTech.value -> "Current leader is [${leadingQuest.assignee}] with [${getScoreForQuest(leadingQuest)}] Technologies discovered."
|
||||||
else -> ""
|
else -> ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user