Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for city level stockpiles to actually function #12710

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

SeventhM
Copy link
Collaborator

Currently stockpiles for cities don't actually exist. Previously, I believe (but never checked) that they would function as if they were civwide regardless, which doesn't match up with the clear and obvious intent. During the last few PRs, I've since changed it so that under some circumstances, gaining a citywide stockpile from a city context would do nothing. This PR aims to do 2 things

  1. Go the extra mile to try to enforce citywide resources as being "citywide" from these contexts
  2. Provide at least the barebones needed for a functioning citywide stockpile

As of writing this PR description, I'm not entirely sure the best way into the resource logic to add citywide stockpile resources, so I haven't immediately focused on adding it

@yairm210
Copy link
Owner

Oh wow!
Yes, "city" and "stockpile" are 2 different categories, we don't have "city stockpile", but this is definitely a thing we would want :D

Comment on lines 214 to 221
fun gainStockpiledResource(resourceName: String, amount: Int) {
resourceStockpiles.add(resourceName, amount)
}

fun gainStockpiledResource(resource: TileResource, amount: Int) {
if (resource.isCityWide) resourceStockpiles.add(resource.name, amount)
else civ.gainStockpiledResource(resource.name, amount)
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very weird that in the first function you don't check if it's citywide or not, you get 2 different behaviours for civwide resources in the 2 identically named functions

} else 0
if (stat is TileResource) {
if (!stat.isStockpiled) return 0
if (stat.isCityWide) return resourceStockpiles[stat.name]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we do when it's civ-wide? Fall down to "civ.getReserve(stat)" below?
I'd rather this was explicit in the "stat is TileResource", that it become a "return when()" so we see that we treat all TileResources cases exhaustively

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had it like that originally, but wasn't sure if it should be explicit

Comment on lines +438 to +439
val resource = city.civ.gameInfo.ruleset.tileResources[resourceName] ?: continue
city.gainStockpiledResource(resource, -amount)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This, to me, indicates that the gainStockpiledResource(String) should do the resource lookup, and then call the gainStockpiledResource(Resource) function

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not entirely ideal unless we decide to add additional logic here, since the counter itself only cares about the resource name (for the sake of serialization)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, if this is what's wanted, the actual thing is to delete the function for strings (I added it for clarity, but the counter is still public rn, actually). Currently, the city version for strings can already be safely deleted

@yairm210
Copy link
Owner

Interesting question: What happens when a city is conquered / bought / etc?
I think it should retain the stockpiles (as is currently the case)
If there's a demand for resources that we don't want to keep between civs we can always create a unique for it later

@SeventhM
Copy link
Collaborator Author

Interesting question: What happens when a city is conquered / bought / etc? I think it should retain the stockpiles (as is currently the case) If there's a demand for resources that we don't want to keep between civs we can always create a unique for it later

Yeah, I would think the default behavior should be to retain the stockpiles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants