Skip to content

Commit

Permalink
From #44 growth is a percentage directly applied to influence source
Browse files Browse the repository at this point in the history
power.
  • Loading branch information
guillaume-alvarez committed Apr 4, 2015
1 parent 7e37b7c commit f18589a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 25 deletions.
21 changes: 3 additions & 18 deletions core/src/com/galvarez/ttw/model/InfluenceSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -361,35 +361,20 @@ private void updateInfluencedTiles(Entity e) {
private void accumulatePower(Entity empire) {
InfluenceSource source = sources.get(empire);

int increase = source.growth + source.influencedTiles.size();
int increase = source.growth * source.power / 100;
if (increase > 0) {
Diplomacy diplomacy = relations.get(empire);
List<Entity> tributes = diplomacy.getEmpires(State.TRIBUTE);
int remains = increase;
for (Entity other : tributes) {
int tribute = min(remains, increase / tributes.size());
sources.get(other).powerAdvancement += tribute;
sources.get(other).power += tribute;
remains -= tribute;
}
increase = remains;
}

source.powerAdvancement += increase;
if (source.powerAdvancement < 0) {
source.power--;
source.powerAdvancement = getRequiredPowerAdvancement(source) + source.powerAdvancement;
} else {
int required = getRequiredPowerAdvancement(source);
if (source.powerAdvancement >= required) {
source.powerAdvancement -= required;
source.power++;
}
}
}

public int getRequiredPowerAdvancement(InfluenceSource source) {
// TODO the base power should depend on the empire
return source.power + 1;
source.power += increase;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ public final class InfluenceSource extends Component {

public final Set<MapPosition> influencedTiles = new HashSet<>();

/** In percents. */
public int growth;

public int powerAdvancement = 0;

public final List<Entity> secondarySources = new ArrayList<>();

public final Modifiers modifiers = new Modifiers();
Expand Down
7 changes: 2 additions & 5 deletions core/src/com/galvarez/ttw/screens/overworld/MenuBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,8 @@ public void buildSelectionMenu(final MapPosition tile, Entity e) {
if (e != null) {
addDescription(e);
InfluenceSource infSource = e.getComponent(InfluenceSource.class);
if (infSource != null) {
int percent = 100 * infSource.powerAdvancement
/ world.getSystem(InfluenceSystem.class).getRequiredPowerAdvancement(infSource);
selectionMenu.addLabel("Power: " + infSource.power + " (+" + percent + "%)");
}
if (infSource != null)
selectionMenu.addLabel("Power: " + infSource.power + " (+" + infSource.growth + "%/turn)");
}

Entity source = influence.getMainInfluenceSource(world);
Expand Down

0 comments on commit f18589a

Please sign in to comment.