Repository navigation
Conversation
| // multiple citizens lost causes multiple unhappy faces. | ||
| if (turnsOfUnhappinessDueToPopRushing > 0) { | ||
| // Only decrement if greater than 0, only add unhappiness if greater than 0 after decrement | ||
| if (turnsOfUnhappinessDueToPopRushing > 0 && --turnsOfUnhappinessDueToPopRushing > 0) { |
There was a problem hiding this comment.
I don't think we want to update the state here. RecalculateCitizenMoods should only do what it says on the tin.
I'd look into extending HandleCityUpdates(..) in class Player, or perhaps going up a level and doing a new segment in the per-player section of AdvanceTurn in TurnHandling.cs.
On a more stylistic note: I find that doing comparisons and variable updates on the same line of source code makes the overall logic harder to parse and understand at a glance.
There was a problem hiding this comment.
Ah yes I see this needs to be a bit more surgical. RecalculateCitizenMoods can be called from multiple function paths here so we definitely don't want to decrement on every call. Okay, I'll think about how to organize this more cleanly and propose a different fix!
This reverts commit 6e41f06.
…calculateCitizenMoods method in AdvanceTurn
|
I think something like this might be the cleanest solution. Updating the unhappiness penalty decrements in So I think the most tractable solution is to have a small helper also in the Happy to entertain any perspectives different than mine. |
But a ternary conditional move saves DOZENS of cycles compared to a branch misprediction!! cough cough sorry, that was the C / C++ Green Goblin side of me.. |
|
Well... |
Response to @Billytifft's bug report of unhappiness due to forced labor never decrementing.
#1004 (comment)
Quick fix potentially abusing short-circuiting logic, heh. I did some homework to make sure I understood how the mechanic worked (it's already good to go as-is), I'm still learning new things about this game!