Tile stats from inside city now show what they would produce if assigned to this city (important for buildings that improve tiles eg. jungle/university)

This commit is contained in:
Yair Morgenstern 2017-12-13 22:06:40 +02:00
parent 561b1b5fdc
commit 86d8378021
3 changed files with 11 additions and 11 deletions

View File

@ -114,8 +114,8 @@ public class CityInfo {
// Working ppl
for (TileInfo cell : getTilesInRange())
if (name.equals(cell.workingCity) || cell.isCityCenter())
stats.add(cell.getTileStats());
if (name.equals(cell.workingCity))
stats.add(cell.getTileStats(this));
//idle ppl
stats.production += getFreePopulation();
@ -218,9 +218,7 @@ public class CityInfo {
TileInfo toWork = null;
for (TileInfo tileInfo : getTilesInRange()) {
if (tileInfo.workingCity !=null) continue;
FullStats stats = tileInfo.getTileStats();
double value = stats.food + stats.production * 0.5;
double value = rankTile(tileInfo);
if (value > maxValue) {
maxValue = value;
toWork = tileInfo;
@ -232,7 +230,7 @@ public class CityInfo {
}
private double rankTile(TileInfo tile){
FullStats stats = tile.getTileStats();
FullStats stats = tile.getTileStats(this);
double rank=0;
if(stats.food <2) rank+=stats.food;
else rank += 2 + (stats.food -2)/2; // 1 point for each food up to 2, from there on half a point

View File

@ -51,7 +51,9 @@ public class TileInfo
private boolean isResearched(String techName) { return UnCivGame.Current.civInfo.tech.isResearched(techName); }
public FullStats getTileStats()
public FullStats getTileStats(){return getTileStats(getCity());}
public FullStats getTileStats(CityInfo city)
{
FullStats stats = new FullStats(getBaseTerrain());
@ -61,7 +63,6 @@ public class TileInfo
else stats.add(terrainFeature);
}
CityInfo city = getCity();
TileResource resource = getTileResource();
if (hasViewableResource())
{
@ -89,7 +90,8 @@ public class TileInfo
if (stats.production < 0) stats.production = 0;
if("Jungle".equals(terrainFeature) && city.getBuildingUniques().contains("JunglesProvideScience")) stats.science+=2;
if("Jungle".equals(terrainFeature) && city!=null
&& city.getBuildingUniques().contains("JunglesProvideScience")) stats.science+=2;
if(stats.gold!=0 && CivilizationInfo.current().isGoldenAge())
stats.gold++;

View File

@ -267,8 +267,8 @@ public class CityScreen extends com.unciv.game.utils.CameraStageBaseScreen {
if(selectedTile == null) return;
TileTable.clearChildren();
CityInfo City =game.civInfo.getCurrentCity();
FullStats stats = selectedTile.getTileStats();
CityInfo city =game.civInfo.getCurrentCity();
FullStats stats = selectedTile.getTileStats(city);
TileTable.pad(20);
TileTable.columnDefaults(0).padRight(10);