Added golden ages!
This commit is contained in:
parent
3381cf84d4
commit
2d12f1fa80
6 changed files with 49 additions and 11 deletions
|
@ -82,6 +82,7 @@ public class CityBuildings
|
|||
if (gameBuilding.providesFreeBuilding != null && !builtBuildings.contains(gameBuilding.providesFreeBuilding))
|
||||
builtBuildings.add(gameBuilding.providesFreeBuilding);
|
||||
if (gameBuilding.freeTechs != 0) UnCivGame.Current.civInfo.tech.freeTechs += gameBuilding.freeTechs;
|
||||
if("EmpireEntersGoldenAge".equals(gameBuilding.unique)) CivilizationInfo.current().enterGoldenAge();
|
||||
}
|
||||
|
||||
inProgressBuildings.remove(currentBuilding);
|
||||
|
@ -168,7 +169,7 @@ public class CityBuildings
|
|||
@Override
|
||||
public boolean evaluate(Building arg0) { return canBuild(arg0); }
|
||||
})
|
||||
.select(new com.unciv.models.LinqCollection.Func<Building, String>() {
|
||||
.select(new LinqCollection.Func<Building, String>() {
|
||||
@Override
|
||||
public String GetBy(Building arg0) {
|
||||
return arg0.name;
|
||||
|
|
|
@ -133,6 +133,7 @@ public class CityInfo {
|
|||
|
||||
FullStats statPercentBonuses = cityBuildings.getStatPercentBonuses();
|
||||
if(isCapital() || isConnectedToCapital(RoadStatus.Railroad)) statPercentBonuses.production += 25;
|
||||
if(CivilizationInfo.current().isGoldenAge()) statPercentBonuses.production+=20;
|
||||
stats.food*=1+statPercentBonuses.food/100;
|
||||
stats.gold*=1+statPercentBonuses.gold/100;
|
||||
stats.production*=1+statPercentBonuses.production/100;
|
||||
|
@ -145,9 +146,9 @@ public class CityInfo {
|
|||
this.cityStats = stats;
|
||||
}
|
||||
|
||||
public float getCityHappiness(){ // needs to be a separate function because we need to know the global happiness state
|
||||
public int getCityHappiness(){ // needs to be a separate function because we need to know the global happiness state
|
||||
// in order to determine how much food is produced in a city!
|
||||
float happiness = -3 - population; // -3 happiness per city and -1 per population
|
||||
int happiness = -3 - population; // -3 happiness per city and -1 per population
|
||||
return happiness + (int)cityBuildings.getStats().happiness;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ public class CivilizationInfo {
|
|||
|
||||
public CivStats civStats = new CivStats();
|
||||
public int baseHappiness = 15;
|
||||
public int numberOfGoldenAges=0;
|
||||
public int turnsLeftForCurrentGoldenAge=0;
|
||||
public String civName = "Babylon";
|
||||
|
||||
public CivilizationTech tech = new CivilizationTech();
|
||||
|
@ -58,12 +60,20 @@ public class CivilizationInfo {
|
|||
});
|
||||
}
|
||||
|
||||
public boolean isGoldenAge(){return turnsLeftForCurrentGoldenAge>0;}
|
||||
public int happinessRequiredForNextGoldenAge(){
|
||||
return (int) ((500+numberOfGoldenAges*250)*(1+cities.size()/100.0)); //https://forums.civfanatics.com/resources/complete-guide-to-happiness-vanilla.25584/
|
||||
}
|
||||
|
||||
public void nextTurn()
|
||||
{
|
||||
notifications.clear();
|
||||
CivStats nextTurnStats = getStatsForNextTurn();
|
||||
civStats.add(nextTurnStats);
|
||||
|
||||
if(!isGoldenAge())
|
||||
civStats.happiness += getHappinessForNextTurn();
|
||||
|
||||
if(cities.size() > 0) tech.nextTurn((int)nextTurnStats.science);
|
||||
|
||||
for (CityInfo city : cities) city.nextTurn();
|
||||
|
@ -71,7 +81,19 @@ public class CivilizationInfo {
|
|||
for(TileInfo tile : tileMap.values()) tile.nextTurn();
|
||||
|
||||
for (CityInfo city : cities) city.updateCityStats();
|
||||
turns += 1;
|
||||
turns++;
|
||||
if(isGoldenAge()) turnsLeftForCurrentGoldenAge--;
|
||||
|
||||
if(civStats.happiness > happinessRequiredForNextGoldenAge()){
|
||||
enterGoldenAge();
|
||||
numberOfGoldenAges++;
|
||||
}
|
||||
}
|
||||
|
||||
public void enterGoldenAge(){
|
||||
civStats.happiness-=happinessRequiredForNextGoldenAge();
|
||||
turnsLeftForCurrentGoldenAge = 10;
|
||||
if(getBuildingUniques().contains("GoldenAgeLengthIncrease")) turnsLeftForCurrentGoldenAge*=1.5;
|
||||
}
|
||||
|
||||
public CivStats getStatsForNextTurn() {
|
||||
|
@ -79,7 +101,7 @@ public class CivilizationInfo {
|
|||
for (CityInfo city : cities) {
|
||||
statsForTurn.add(city.cityStats);
|
||||
}
|
||||
statsForTurn.happiness = getHappinessForNextTurn();
|
||||
statsForTurn.happiness=0;
|
||||
return statsForTurn;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,9 +41,7 @@ public class CivilizationTech{
|
|||
public void nextTurn(int scienceForNewTurn){
|
||||
String CurrentTechnology = currentTechnology();
|
||||
|
||||
if (!techsInProgress.containsKey(CurrentTechnology))
|
||||
techsInProgress.put(CurrentTechnology, 0);
|
||||
techsInProgress.put(CurrentTechnology, techsInProgress.get(CurrentTechnology) + scienceForNewTurn);
|
||||
techsInProgress.put(CurrentTechnology, researchOfTech(CurrentTechnology) + scienceForNewTurn);
|
||||
if (techsInProgress.get(CurrentTechnology) >= getCurrentTechnology().cost) // We finished it!
|
||||
{
|
||||
techsInProgress.remove(CurrentTechnology);
|
||||
|
@ -53,4 +51,9 @@ public class CivilizationTech{
|
|||
}
|
||||
}
|
||||
|
||||
public String getAmountResearchedText(){
|
||||
if(currentTechnology()==null) return "";
|
||||
return "("+researchOfTech(currentTechnology())+"/"+getCurrentTechnology().cost+")";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -86,9 +86,12 @@ public class TileInfo
|
|||
if (stats.food < 2) stats.food = 2;
|
||||
if (stats.production < 1) stats.production = 1;
|
||||
}
|
||||
|
||||
if (stats.production < 0) stats.production = 0;
|
||||
|
||||
if("Jungle".equals(terrainFeature) && city.getBuildingUniques().contains("JunglesProvideScience")) stats.science+=2;
|
||||
if(stats.gold!=0 && CivilizationInfo.current().isGoldenAge())
|
||||
stats.gold++;
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ public class WorldScreen extends com.unciv.game.utils.CameraStageBaseScreen {
|
|||
|
||||
private void updateCivTable() {
|
||||
CivTable.clear();
|
||||
CivTable.row().pad(20);
|
||||
CivTable.row().pad(15);
|
||||
CivStats currentStats = game.civInfo.civStats;
|
||||
|
||||
TextButton CivilopediaButton = new TextButton("Menu",skin);
|
||||
|
@ -193,8 +193,16 @@ public class WorldScreen extends com.unciv.game.utils.CameraStageBaseScreen {
|
|||
CivTable.add(new Label("Gold: " + Math.round(currentStats.gold)
|
||||
+ "(" +(nextTurnStats.gold >0?"+":"") + Math.round(nextTurnStats.gold) +")", skin));
|
||||
|
||||
CivTable.add(new Label("Science: +" + Math.round(nextTurnStats.science), skin));
|
||||
CivTable.add(new Label("Happiness: " + Math.round(nextTurnStats.happiness), skin));
|
||||
Label scienceLabel = new Label("Science: +" + Math.round(nextTurnStats.science)
|
||||
+"\r\n"+game.civInfo.tech.getAmountResearchedText(), skin);
|
||||
scienceLabel.setAlignment(Align.center);
|
||||
CivTable.add(scienceLabel);
|
||||
String happinessText = "Happiness: " + Math.round(game.civInfo.getHappinessForNextTurn());
|
||||
if(game.civInfo.isGoldenAge()) happinessText+="\r\n GOLDEN AGE ("+game.civInfo.turnsLeftForCurrentGoldenAge+")";
|
||||
else happinessText+= "\r\n ("+(int)game.civInfo.civStats.happiness+"/"+game.civInfo.happinessRequiredForNextGoldenAge()+")";
|
||||
Label happinessLabel = new Label(happinessText, skin);
|
||||
happinessLabel.setAlignment(Align.center);
|
||||
CivTable.add(happinessLabel);
|
||||
CivTable.add(new Label("Culture: " + Math.round(currentStats.culture) + "(+" + Math.round(nextTurnStats.culture) +")", skin));
|
||||
|
||||
CivTable.pack();
|
||||
|
|
Loading…
Reference in a new issue