From f046dcd9ee14fb8bed12b876e35a81a52ab7d42f Mon Sep 17 00:00:00 2001 From: PavelCibulka Date: Mon, 30 Oct 2017 15:43:58 +0100 Subject: [PATCH 1/2] Update TaxLevel.java --- src/hu/openig/model/TaxLevel.java | 65 +++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 8 deletions(-) diff --git a/src/hu/openig/model/TaxLevel.java b/src/hu/openig/model/TaxLevel.java index 119dd54d7..3e9d63d0f 100644 --- a/src/hu/openig/model/TaxLevel.java +++ b/src/hu/openig/model/TaxLevel.java @@ -34,12 +34,61 @@ public enum TaxLevel { /** Slavery. */ SLAVERY ; - /** The taxation percent. */ - public final int percent; - /** - * Constructor. - */ - TaxLevel() { - this.percent = 100 * ordinal() / 9; - } + + private static final float NO_TAX_MORALE = 5f; + private static final int MAX_LEVEL = 9; + private static final int MAX_TAX = 100; + private static final float MAX_TAX_MORALE_SAME = -100f / 3f; + private static final float MAX_TAX_MORALE_OTHER = -40f; + private static final int BASE_LEVEL = 3; + private static final int BASE_TAX = MAX_TAX * BASE_LEVEL / MAX_LEVEL; + private static final float BASE_TAX_MORALE_SAME = -5.5f; + private static final float BASE_TAX_MORALE_OTHER = -8.25f; + + /** + * The taxation percent. + */ + public final int percent; + /** + * Same race morale change. + */ + private final float sameMorale; + /** + * Different race morale change. + */ + private final float otherMorale; + + /** + * Constructor. + */ + TaxLevel() { + this.percent = MAX_TAX * ordinal() / MAX_LEVEL; + + if (this.percent == 0) { + this.sameMorale = NO_TAX_MORALE; + this.otherMorale = NO_TAX_MORALE; + } else if (this.percent <= BASE_TAX) { + this.sameMorale = BASE_TAX_MORALE_SAME * this.percent / BASE_TAX; + this.otherMorale = BASE_TAX_MORALE_OTHER * this.percent / BASE_TAX; + } else { + this.sameMorale = BASE_TAX_MORALE_SAME + + (MAX_TAX_MORALE_SAME - BASE_TAX_MORALE_SAME) + * (this.percent - BASE_TAX) / (MAX_TAX - BASE_TAX); + this.otherMorale = BASE_TAX_MORALE_OTHER + + (MAX_TAX_MORALE_OTHER - BASE_TAX_MORALE_OTHER) + * (this.percent - BASE_TAX) / (MAX_TAX - BASE_TAX); + } + } + + /** + * @param sameRace If planet race is Empire's main race. + * @return Morale change for this tax level and selected race. + */ + public float getMoraleChange(boolean sameRace) { + if (sameRace) { + return sameMorale; + } else { + return otherMorale; + } + } } From 503f158cce55d9aabea39293b74246342dfafbbf Mon Sep 17 00:00:00 2001 From: PavelCibulka Date: Mon, 30 Oct 2017 15:45:10 +0100 Subject: [PATCH 2/2] Update Simulator.java --- src/hu/openig/mechanics/Simulator.java | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/hu/openig/mechanics/Simulator.java b/src/hu/openig/mechanics/Simulator.java index c32c54f9b..fd7554515 100644 --- a/src/hu/openig/mechanics/Simulator.java +++ b/src/hu/openig/mechanics/Simulator.java @@ -33,7 +33,6 @@ import hu.openig.model.ResearchState; import hu.openig.model.ResearchSubCategory; import hu.openig.model.ResearchType; -import hu.openig.model.TaxLevel; import hu.openig.model.Trait; import hu.openig.model.TraitKind; import hu.openig.model.World; @@ -420,22 +419,7 @@ static boolean progressPlanet(World world, Planet planet, boolean dayChange, if (world.config.continuousMoney || dayChange) { // FIXME morale computation double newMorale = 50 + moraleBoost; - if (planet.tax == TaxLevel.NONE) { - newMorale += 5; - } else - if (planet.tax.ordinal() <= TaxLevel.MODERATE.ordinal()) { - if (!planet.owner.race.equals(planet.race)) { - newMorale -= planet.tax.percent / 4f; - } else { - newMorale -= planet.tax.percent / 6f; - } - } else { - if (!planet.owner.race.equals(planet.race)) { - newMorale -= planet.tax.percent / 2.5f; - } else { - newMorale -= planet.tax.percent / 3f; - } - } + newMorale += planet.tax.getMoraleChange(planet.owner.race.equals(planet.race)); if (ps.houseAvailable < planet.population()) { newMorale += (ps.houseAvailable - planet.population()) * 75f / planet.population(); } else {