mirror of
https://github.com/yairm210/Unciv.git
synced 2025-10-04 17:58:32 -04: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) {
|
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" }) {
|
if (construction is Building && construction.uniqueObjects.any { it.placeholderText == "Creates a [] improvement on a specific tile" }) {
|
||||||
cityScreen.selectedTile
|
cityScreen.selectedTile
|
||||||
improvementBuildingToConstruct = construction
|
improvementBuildingToConstruct = construction
|
||||||
|
@ -40,7 +40,12 @@ class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: CivilizationInfo
|
|||||||
} else onBackButtonClicked { UncivGame.Current.setWorldScreen() }
|
} else onBackButtonClicked { UncivGame.Current.setWorldScreen() }
|
||||||
|
|
||||||
rightSideButton.onClick(UncivSound.Policy) {
|
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 we've moved to another screen in the meantime (great person pick, victory screen) ignore this
|
||||||
if (game.screen !is PolicyPickerScreen || !policies.canAdoptPolicy()) {
|
if (game.screen !is PolicyPickerScreen || !policies.canAdoptPolicy()) {
|
||||||
@ -106,14 +111,21 @@ class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: CivilizationInfo
|
|||||||
scrollPane.updateVisualScroll()
|
scrollPane.updateVisualScroll()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun pickPolicy(policy: Policy) {
|
fun policyIsPickable(policy: Policy):Boolean {
|
||||||
if (!worldScreen.isPlayersTurn
|
if (!worldScreen.isPlayersTurn
|
||||||
|| worldScreen.viewingCiv.isSpectator() // viewingCiv var points to selectedCiv in case of spectator
|
|| worldScreen.viewingCiv.isSpectator() // viewingCiv var points to selectedCiv in case of spectator
|
||||||
|| viewingCiv.isDefeated()
|
|| viewingCiv.isDefeated()
|
||||||
|| viewingCiv.policies.isAdopted(policy.name)
|
|| viewingCiv.policies.isAdopted(policy.name)
|
||||||
|| policy.policyBranchType == PolicyBranchType.BranchComplete
|
|| policy.policyBranchType == PolicyBranchType.BranchComplete
|
||||||
|| !viewingCiv.policies.isAdoptable(policy)
|
|| !viewingCiv.policies.isAdoptable(policy)
|
||||||
|| !viewingCiv.policies.canAdoptPolicy()) {
|
|| !viewingCiv.policies.canAdoptPolicy()
|
||||||
|
)
|
||||||
|
return false
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun pickPolicy(policy: Policy) {
|
||||||
|
if (!policyIsPickable(policy)) {
|
||||||
rightSideButton.disable()
|
rightSideButton.disable()
|
||||||
} else {
|
} else {
|
||||||
rightSideButton.enable()
|
rightSideButton.enable()
|
||||||
|
@ -58,10 +58,16 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
|||||||
|
|
||||||
rightSideButton.setText("Pick a tech".tr())
|
rightSideButton.setText("Pick a tech".tr())
|
||||||
rightSideButton.onClick(UncivSound.Paper) {
|
rightSideButton.onClick(UncivSound.Paper) {
|
||||||
game.settings.addCompletedTutorialTask("Pick technology")
|
if (freeTechPick) {
|
||||||
if (freeTechPick) civTech.getFreeTechnology(selectedTech!!.name)
|
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
|
else civTech.techsToResearch = tempTechsToResearch
|
||||||
|
|
||||||
|
game.settings.addCompletedTutorialTask("Pick technology")
|
||||||
|
|
||||||
game.setWorldScreen()
|
game.setWorldScreen()
|
||||||
game.worldScreen.shouldUpdate = true
|
game.worldScreen.shouldUpdate = true
|
||||||
dispose()
|
dispose()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user