mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-10 04:43:29 +07:00
Sort Maintenace Using Fixed Point (#5764)
* Add new UniqueType.NoMaintenance to support Guided Missile * revert gradle Add UnitMaintenanceDiscount Rename UnitMaintenanceDiscount->UnitMaintenanceDiscountGlobal Rework maintenance equation to account for overlapping reductions Add maintenance variable to MapUnit * Add square brackets in string (apparently didn't check in?) More robust uniques check code so not assuming only one matching unique Use toPercent() * Proper toPercent() math * Use fixed point Long to help in sorting to avoid float bug? * Use fixed point Long to help in sorting to avoid float bug? Co-authored-by: temurakami <spellman23@gmail.com>
This commit is contained in:
parent
b1390cd6db
commit
4fe7315478
@ -52,7 +52,8 @@ class CivInfoStats(val civInfo: CivilizationInfo) {
|
||||
// Sort by descending maintenance, then drop most expensive X units to make them free
|
||||
// If more free than units left, returns empty sequence
|
||||
// There's something here that causes a bug and I'm not sure where, so let's try taking this apart piece by piece
|
||||
unitsToPayFor = unitsToPayFor.sortedByDescending { it.maintenance }.toList().asSequence()
|
||||
// Switching sort to use fixed point math. Perhaps error is due to floating comparisons
|
||||
unitsToPayFor = unitsToPayFor.sortedByDescending { it.maintenance*100000.0.toInt() }.toList().asSequence()
|
||||
unitsToPayFor = unitsToPayFor.drop(freeUnits)
|
||||
val numberOfUnitsToPayFor = max(0.0, unitsToPayFor.sumOf { it.maintenance.toDouble() }).toFloat()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user