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

Tax level to morale #1010

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions src/hu/openig/mechanics/Simulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
65 changes: 57 additions & 8 deletions src/hu/openig/model/TaxLevel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}