Organized unique wonder abilities by adding "unique" string to building

Added Machu Pichu, Angkor Wat and Aqueduct unique abilities
Expanded civilopidia entry for buildings
Merged CityPopulation into CityInfo because the division was arbitrary
This commit is contained in:
Yair Morgenstern
2017-12-04 19:10:25 +02:00
parent d47d59146f
commit 4bb4187ab1
10 changed files with 52 additions and 53 deletions

View File

@ -21,7 +21,7 @@ android {
applicationId "com.unciv.game"
minSdkVersion 9
targetSdkVersion 25
versionCode 5
versionCode 6
versionName "0.9"
}
buildTypes {

View File

@ -45,6 +45,7 @@ public class CityInfo {
// (per game XML files) at 6*(t+0.4813)^1.3
// The second seems to be more based, so I'll go with that
double a = 6*Math.pow(tilesClaimed+1.4813,1.3);
if(CivilizationInfo.current().getCivTags().contains("NewTileCostReduction")) a *= 0.75; //Speciality of Angkor Wat
return (int)Math.round(a);
}
@ -107,9 +108,12 @@ public class CityInfo {
stats.production += getFreePopulation();
stats.food -= cityPopulation.Population * 2;
if(!isCapital() && isConnectedToCapital()) // Calculated by http://civilization.wikia.com/wiki/Trade_route_(Civ5)
stats.gold+= CivilizationInfo.current().getCapital().cityPopulation.Population * 0.15
if(!isCapital() && isConnectedToCapital()) { // Calculated by http://civilization.wikia.com/wiki/Trade_route_(Civ5)
double goldFromTradeRoute = CivilizationInfo.current().getCapital().cityPopulation.Population * 0.15
+ cityPopulation.Population * 1.1 - 1;
if(CivilizationInfo.current().getCivTags().contains("TradeRouteGoldIncrease")) goldFromTradeRoute*=1.25; // Machu Pichu speciality
stats.gold += goldFromTradeRoute;
}
stats.add(cityBuildings.getStats());

View File

@ -1,34 +0,0 @@
package com.unciv.civinfo;
public class CityPopulation
{
public int Population = 1;
public int FoodStored = 0;
public int FoodToNextPopulation()
{
// civ v math,civilization.wikia
return 15 + 6 * (Population - 1) + (int)Math.floor(Math.pow(Population - 1, 1.8f));
}
/**
* @param FoodProduced
* @return whether a growth occured
*/
public boolean NextTurn(int FoodProduced)
{
FoodStored += FoodProduced;
if (FoodStored < 0) // starvation!
{
Population--;
FoodStored = 0;
}
if (FoodStored >= FoodToNextPopulation()) // growth!
{
FoodStored -= FoodToNextPopulation();
Population++;
return true;
}
return false;
}
}

View File

@ -4,16 +4,18 @@ import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Predicate;
import com.unciv.game.UnCivGame;
import com.unciv.models.LinqCollection;
import com.unciv.models.gamebasics.Building;
import com.unciv.models.gamebasics.GameBasics;
import com.unciv.models.stats.CivStats;
import java.util.Collection;
import java.util.HashSet;
/**
* Created by LENOVO on 10/18/2017.
*/
public class CivilizationInfo {
public static CivilizationInfo current(){return UnCivGame.Current.civInfo; }
public static CivilizationInfo current(){ return UnCivGame.Current.civInfo; }
public CivStats civStats = new CivStats();
public int baseHappiness = 15;
@ -79,5 +81,19 @@ public class CivilizationInfo {
return statsForTurn;
}
public LinqCollection<String> getCivTags(){
return cities.selectMany(new LinqCollection.Func<CityInfo, Collection<? extends String>>() {
@Override
public Collection<? extends String> GetBy(CityInfo arg0) {
return arg0.cityBuildings.getBuiltBuildings().select(new LinqCollection.Func<Building, String>() {
@Override
public String GetBy(Building arg0) {
return arg0.unique;
}
});
}
});
}
}

View File

@ -217,7 +217,7 @@ public class WorldScreen extends CameraStageBaseScreen {
LinqHashMap<TileInfo, Float> distanceToTiles = game.civInfo.tileMap.getDistanceToTiles(unitTile.position,unitTile.unit.CurrentMovement);
if(distanceToTiles.containsKey(selectedTile)) {
unitTile.unit.CurrentMovement -= distanceToTiles.get(selectedTile);
unitTile.unit.CurrentMovement = round(unitTile.unit.CurrentMovement,3);
//unitTile.unit.CurrentMovement = round(unitTile.unit.CurrentMovement,3);
if(unitTile.unit.CurrentMovement < 0.1) unitTile.unit.CurrentMovement=0; // silly floats which are "almost zero"
group.tileInfo.unit = unitTile.unit;
unitTile.unit = null;

View File

@ -107,7 +107,7 @@ public class TechPickerScreen extends PickerScreen {
for (int i = 0; i < 10; i++) {
topTable.row().pad(5);
for (int j = 0; j < 6; j++) {
for (int j = 0; j < 8; j++) {
final Technology tech = techMatrix[j][i];
if (tech == null) topTable.add(); // empty cell
else {

View File

@ -41,6 +41,12 @@ public class LinqCollection <T> extends ArrayList<T> {
return newCollection;
}
public <T2> LinqCollection<T2> selectMany(Func<T,Collection<? extends T2>> multiSelector){
LinqCollection<T2> newCollection = new LinqCollection<T2>();
for(T t:this) newCollection.addAll(multiSelector.GetBy(t));
return newCollection;
}
public T getRandom(){
if(size()==0) return null;
return get((int) (Math.random() * (size())));

View File

@ -1,5 +1,6 @@
package com.unciv.models.gamebasics;
import com.unciv.models.LinqCollection;
import com.unciv.models.stats.FullStats;
import com.unciv.models.stats.NamedStats;
@ -19,17 +20,23 @@ public class Building extends NamedStats implements ICivilopedia {
// Uniques
public String providesFreeBuilding;
public int freeTechs;
public int newTileCostReduction;
public String unique; // for wonders which have individual functions that are totally unique
/** The bonus stats that a resource gets when this building is built */
public FullStats resourceBonusStats;
public String getDescription() {
FullStats stats = new FullStats(this);
StringBuilder stringBuilder = new StringBuilder();
if(isWonder) stringBuilder.append("Wonder\r\n");
stringBuilder.append(description + "\r\n" + stats);
return stringBuilder.toString();
FullStats stats = new FullStats(this);
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Cost: "+cost+"\r\n");
if (isWonder) stringBuilder.append("Wonder\r\n");
if (requiredTech != null) stringBuilder.append("Requires "+requiredTech+" to be researched\r\n");
if (requiredBuilding != null) stringBuilder.append("Requires a "+requiredBuilding+" to be built in this city\r\n");
if (requiredBuildingInAllCities != null) stringBuilder.append("Requires a "+requiredBuildingInAllCities+" to be built in all cities\r\n");
if(providesFreeBuilding!=null) stringBuilder.append("Provides a free "+providesFreeBuilding+" in this city\r\n");
if(maintainance!=0) stringBuilder.append("Maintainance cost: "+maintainance+" gold\r\n");
stringBuilder.append(description + "\r\n" + stats);
return stringBuilder.toString();
}
}

View File

@ -34,7 +34,7 @@ public class TileImprovement extends NamedStats implements ICivilopedia {
stringBuilder.append("\r\n"+statsString+" for "+ StringUtils.join(", ",statsToResourceNames.get(statsString)));
}
if(techRequired !=null) stringBuilder.append("\r\ntech required: "+ techRequired);
if(techRequired !=null) stringBuilder.append("\r\nTech required: "+ techRequired);
return stringBuilder.toString();
}

View File

@ -29,12 +29,12 @@ public class FullStats extends CivStats // also used for hex stats, since it's b
public String toString() {
StringBuilder valuableParts = new StringBuilder();
if (production != 0) valuableParts.append(display(production,"production"));
if (food != 0) valuableParts.append(display(food,"food"));
if (gold != 0) valuableParts.append(display(gold,"gold"));
if (science != 0) valuableParts.append(display(science,"science"));
if (happiness != 0) valuableParts.append(display(happiness,"Happpiness"));
if (culture != 0) valuableParts.append(display(culture,"culture"));
if (production != 0) valuableParts.append(display(production,"Production"));
if (food != 0) valuableParts.append(display(food,"Food"));
if (gold != 0) valuableParts.append(display(gold,"Gold"));
if (science != 0) valuableParts.append(display(science,"Science"));
if (happiness != 0) valuableParts.append(display(happiness,"Happiness"));
if (culture != 0) valuableParts.append(display(culture,"Culture"));
if (valuableParts.length() == 0) return "";
valuableParts.delete(0,1);
return valuableParts.toString();