question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make it easier to buy units and buildings from production menu

See original GitHub issue

Right now, when one wants to buy units or buildings in the city they have to: Select the thing, click “build” or “produce” (or similar), after it is selected for production they can click on “Buy”.

How about adding a buy button to the select screen of a unit/building in the city?

I’m guessing you could add the logic in the https://github.com/yairm210/UnCiv/blob/master/core/src/com/unciv/ui/pickerscreens/ConstructionPickerScreen.kt

similar to:

for (building in GameBasics.Buildings.values) {
    if (!building.isBuildable(cityConstructions) && building.name!=cityConstructions.currentConstruction) continue
    val productionTextButton = getProductionButton(building.name,
            building.name + "\r\n" + cityConstructions.turnsToConstruction(building.name) + " {turns}".tr(),
            building.getDescription(true, currentPlayerCiv.policies.getAdoptedPolicies()),
            "Build [${building.name}]".tr())
    if (building.isWonder)
        wonders.addActor(productionTextButton)
    else
+        if (building !is SpecialConstruction &&
+                !(building is Building && building.isWonder)) {
+            row()
+            val buildingGoldCost = building.getGoldCost(city.civInfo.policies.getAdoptedPolicies())
+            val buildingBuyButton = TextButton("Buy for [$buildingGoldCost] gold".tr(), +CameraStageBaseScreen.skin)
+            buildingBuyButton.onClick("coin") {
+                city.cityConstructions.purchaseBuilding(city.cityConstructions.currentConstruction)
+                update()
+            }
+            if (buildingGoldCost > city.civInfo.gold) {
+                buildingBuyButton.disable()
+            }
            regularBuildings.addActor(productionTextButton)
+            regularBuildings.addActor(buildingBuyButton)
+        }
}

for (unit in GameBasics.Units.values.filter { it.isBuildable(cityConstructions)}) {
+    if (unit !is SpecialConstruction &&
+            !(unit is Building && unit.isWonder)) {
+        row()
+        val buildingGoldCost = unit.getGoldCost(city.civInfo.policies.getAdoptedPolicies())
+        val buildingBuyButton = TextButton("Buy for [$buildingGoldCost] gold".tr(), +CameraStageBaseScreen.skin)
+        buildingBuyButton.onClick("coin") {
+            city.cityConstructions.purchaseBuilding(city.cityConstructions.currentConstruction)
+            update()
+        }
+        if (buildingGoldCost > city.civInfo.gold) {
+            buildingBuyButton.disable()
+        }
        units.addActor(getProductionButton(unit.name,
            unit.name + "\r\n" + cityConstructions.turnsToConstruction(unit.name) + " {turns}".tr(),
            unit.getDescription(true), "Train [${unit.name}]".tr()))
+        regularBuildings.addActor(buildingBuyButton)
+    }
}

I’m aware this doesn’t work as of now, especially because of this line: city.cityConstructions.purchaseBuilding(city.cityConstructions.currentConstruction)

and I’m not sure what the difference between add() and addActor() is, but I hope my idea comes across and my code is semi-usable

Best and keep it up! 👍

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
yairm210commented, Jan 19, 2019

So instead, I decided to remodel the entire left side of the city screen to look like the original civ.

Should enter 2.12.2 =D

Sneak peek: image

1reaction
yairm210commented, Jan 17, 2019

Interesting, I’ll check it out!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a way to purchase partially completed units?
No. You will purchase a new unit, and the unit in production will continue to be produced. If you change production, you'll have...
Read more >
Beginner's Guide to Unit Production - Paradox Forum
In this week's video, I discuss producing units by building them in colony centers, buying them from NPC factions, and using operations to ......
Read more >
[Civ5] I was wondering about the cost efficiency of purchasing ...
I only included unique buildings/units with different Production ... Buildings) and some make certain items cheaper to buy (e.g. Level 1 ...
Read more >
Quick way to Select Production buildings and use them
My Idea : Double Click on one of your production buildings make all of buildings of same type selected then you can Select...
Read more >
Victoria 3: How To Manage Your Construction - TheGamer
The best way to increase both of these variables is through Government Administration buildings, and since Taxation Capacity is a state-specific ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found