mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-13 08:14:29 +07:00
Resolved #4977 - can no longer fast-tap to confuse the policy/construction screens
This commit is contained in:
parent
71220c5bfd
commit
00e962c9ac
@ -395,6 +395,9 @@ class CityConstructionsTable(private val cityScreen: CityScreen) {
|
||||
}
|
||||
|
||||
private fun addConstructionToQueue(construction: IConstruction, cityConstructions: CityConstructions) {
|
||||
// Some evil person decided to double tap real fast - #4977
|
||||
if (cannotAddConstructionToQueue(construction, cityScreen.city, cityScreen.city.cityConstructions))
|
||||
return
|
||||
if (construction is Building && construction.uniqueObjects.any { it.placeholderText == "Creates a [] improvement on a specific tile" }) {
|
||||
cityScreen.selectedTile
|
||||
improvementBuildingToConstruct = construction
|
||||
|
@ -40,7 +40,12 @@ class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: CivilizationInfo
|
||||
} else onBackButtonClicked { UncivGame.Current.setWorldScreen() }
|
||||
|
||||
rightSideButton.onClick(UncivSound.Policy) {
|
||||
viewingCiv.policies.adopt(pickedPolicy!!)
|
||||
val policy = pickedPolicy!!
|
||||
|
||||
// Evil people clicking on buttons too fast to confuse the screen - #4977
|
||||
if (!policyIsPickable(policy)) return@onClick
|
||||
|
||||
viewingCiv.policies.adopt(policy)
|
||||
|
||||
// If we've moved to another screen in the meantime (great person pick, victory screen) ignore this
|
||||
if (game.screen !is PolicyPickerScreen || !policies.canAdoptPolicy()) {
|
||||
@ -106,14 +111,21 @@ class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: CivilizationInfo
|
||||
scrollPane.updateVisualScroll()
|
||||
}
|
||||
|
||||
private fun pickPolicy(policy: Policy) {
|
||||
fun policyIsPickable(policy: Policy):Boolean {
|
||||
if (!worldScreen.isPlayersTurn
|
||||
|| worldScreen.viewingCiv.isSpectator() // viewingCiv var points to selectedCiv in case of spectator
|
||||
|| viewingCiv.isDefeated()
|
||||
|| viewingCiv.policies.isAdopted(policy.name)
|
||||
|| policy.policyBranchType == PolicyBranchType.BranchComplete
|
||||
|| !viewingCiv.policies.isAdoptable(policy)
|
||||
|| !viewingCiv.policies.canAdoptPolicy()) {
|
||||
|| worldScreen.viewingCiv.isSpectator() // viewingCiv var points to selectedCiv in case of spectator
|
||||
|| viewingCiv.isDefeated()
|
||||
|| viewingCiv.policies.isAdopted(policy.name)
|
||||
|| policy.policyBranchType == PolicyBranchType.BranchComplete
|
||||
|| !viewingCiv.policies.isAdoptable(policy)
|
||||
|| !viewingCiv.policies.canAdoptPolicy()
|
||||
)
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
private fun pickPolicy(policy: Policy) {
|
||||
if (!policyIsPickable(policy)) {
|
||||
rightSideButton.disable()
|
||||
} else {
|
||||
rightSideButton.enable()
|
||||
|
@ -58,10 +58,16 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
||||
|
||||
rightSideButton.setText("Pick a tech".tr())
|
||||
rightSideButton.onClick(UncivSound.Paper) {
|
||||
game.settings.addCompletedTutorialTask("Pick technology")
|
||||
if (freeTechPick) civTech.getFreeTechnology(selectedTech!!.name)
|
||||
if (freeTechPick) {
|
||||
val freeTech = selectedTech!!.name
|
||||
// More evil people fast-clicking to cheat - #4977
|
||||
if (researchableTechs.contains(freeTech)) return@onClick
|
||||
civTech.getFreeTechnology(selectedTech!!.name)
|
||||
}
|
||||
else civTech.techsToResearch = tempTechsToResearch
|
||||
|
||||
game.settings.addCompletedTutorialTask("Pick technology")
|
||||
|
||||
game.setWorldScreen()
|
||||
game.worldScreen.shouldUpdate = true
|
||||
dispose()
|
||||
|
Loading…
Reference in New Issue
Block a user