Improvements on tiles can advance

Cannot create adjacent cities
Standardized function and parameter names
This commit is contained in:
Yair Morgenstern
2017-11-30 22:25:20 +02:00
parent 214f64effb
commit 2f9d6af693
17 changed files with 204 additions and 206 deletions

1
.gitignore vendored
View File

@ -125,3 +125,4 @@ Thumbs.db
/ios-moe/xcode/native/ /ios-moe/xcode/native/
gradle.properties gradle.properties
SaveFiles/ SaveFiles/
android/android-release.apk

View File

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

View File

@ -29,7 +29,7 @@ public class CityBuildings
public HashMap<String, Integer> InProgressBuildings = new HashMap<String, Integer>(); public HashMap<String, Integer> InProgressBuildings = new HashMap<String, Integer>();
public String CurrentBuilding = Worker; // default starting building! public String CurrentBuilding = Worker; // default starting building!
public CityInfo GetCity(){return UnCivGame.Current.civInfo.tileMap.get(cityLocation).GetCity(); } public CityInfo GetCity(){return UnCivGame.Current.civInfo.tileMap.get(cityLocation).getCity(); }
public boolean IsBuilt(String buildingName) { return BuiltBuildings.contains(buildingName); } public boolean IsBuilt(String buildingName) { return BuiltBuildings.contains(buildingName); }
public boolean IsBuilding(String buildingName) { return CurrentBuilding.equals(buildingName); } public boolean IsBuilding(String buildingName) { return CurrentBuilding.equals(buildingName); }
@ -50,7 +50,7 @@ public class CityBuildings
if (InProgressBuildings.get(CurrentBuilding) >= GetGameBuilding(CurrentBuilding).Cost) if (InProgressBuildings.get(CurrentBuilding) >= GetGameBuilding(CurrentBuilding).Cost)
{ {
if (CurrentBuilding.equals(Worker) || CurrentBuilding.equals(Settler)) if (CurrentBuilding.equals(Worker) || CurrentBuilding.equals(Settler))
UnCivGame.Current.civInfo.tileMap.get(cityLocation).Unit = new Unit(CurrentBuilding,2); UnCivGame.Current.civInfo.tileMap.get(cityLocation).unit = new Unit(CurrentBuilding,2);
else else
{ {
@ -58,7 +58,7 @@ public class CityBuildings
Building gameBuilding = GetGameBuilding(CurrentBuilding); Building gameBuilding = GetGameBuilding(CurrentBuilding);
if (gameBuilding.ProvidesFreeBuilding != null && !BuiltBuildings.contains(gameBuilding.ProvidesFreeBuilding)) if (gameBuilding.ProvidesFreeBuilding != null && !BuiltBuildings.contains(gameBuilding.ProvidesFreeBuilding))
BuiltBuildings.add(gameBuilding.ProvidesFreeBuilding); BuiltBuildings.add(gameBuilding.ProvidesFreeBuilding);
if (gameBuilding.FreeTechs != 0) UnCivGame.Current.civInfo.Tech.FreeTechs += gameBuilding.FreeTechs; if (gameBuilding.FreeTechs != 0) UnCivGame.Current.civInfo.tech.FreeTechs += gameBuilding.FreeTechs;
} }
InProgressBuildings.remove(CurrentBuilding); InProgressBuildings.remove(CurrentBuilding);
@ -80,22 +80,22 @@ public class CityBuildings
{ {
CivilizationInfo civInfo = UnCivGame.Current.civInfo; CivilizationInfo civInfo = UnCivGame.Current.civInfo;
if(IsBuilt(building.Name)) return false; if(IsBuilt(building.Name)) return false;
// if (building.Name.equals("Worker") || building.Name.equals("Settler")) return false; // if (building.name.equals("Worker") || building.name.equals("Settler")) return false;
if(building.ResourceRequired) { if(building.ResourceRequired) {
boolean containsResourceWithImprovement = GetCity().getTilesInRange() boolean containsResourceWithImprovement = GetCity().getTilesInRange()
.any(new Predicate<TileInfo>() { .any(new Predicate<TileInfo>() {
@Override @Override
public boolean evaluate(TileInfo tile) { public boolean evaluate(TileInfo tile) {
return tile.Resource != null return tile.resource != null
&& building.Name.equals(tile.GetTileResource().Building) && building.Name.equals(tile.getTileResource().Building)
&& tile.GetTileResource().Improvement.equals(tile.Improvement); && tile.getTileResource().Improvement.equals(tile.improvement);
} }
}); });
if(!containsResourceWithImprovement) return false; if(!containsResourceWithImprovement) return false;
} }
if (building.RequiredTech != null && !civInfo.Tech.IsResearched(building.RequiredTech)) return false; if (building.RequiredTech != null && !civInfo.tech.IsResearched(building.RequiredTech)) return false;
if (building.IsWonder && civInfo.Cities if (building.IsWonder && civInfo.cities
.any(new Predicate<CityInfo>() { .any(new Predicate<CityInfo>() {
@Override @Override
public boolean evaluate(CityInfo arg0) { public boolean evaluate(CityInfo arg0) {
@ -105,7 +105,7 @@ public class CityBuildings
}) ) return false; }) ) return false;
if (building.RequiredBuilding != null && !IsBuilt(building.RequiredBuilding)) return false; if (building.RequiredBuilding != null && !IsBuilt(building.RequiredBuilding)) return false;
if (building.RequiredBuildingInAllCities != null || if (building.RequiredBuildingInAllCities != null ||
civInfo.Cities.any(new Predicate<CityInfo>() { civInfo.cities.any(new Predicate<CityInfo>() {
@Override @Override
public boolean evaluate(CityInfo arg0) { public boolean evaluate(CityInfo arg0) {
return arg0.cityBuildings.IsBuilt(building.RequiredBuildingInAllCities); return arg0.cityBuildings.IsBuilt(building.RequiredBuildingInAllCities);

View File

@ -12,7 +12,7 @@ import java.util.ArrayList;
public class CityInfo { public class CityInfo {
public final Vector2 cityLocation; public final Vector2 cityLocation;
public String Name; public String name;
public CityBuildings cityBuildings; public CityBuildings cityBuildings;
public CityPopulation cityPopulation; public CityPopulation cityPopulation;
@ -25,7 +25,7 @@ public class CityInfo {
return getTileMap().getTilesInDistance(cityLocation,3).where(new Predicate<TileInfo>() { return getTileMap().getTilesInDistance(cityLocation,3).where(new Predicate<TileInfo>() {
@Override @Override
public boolean evaluate(TileInfo arg0) { public boolean evaluate(TileInfo arg0) {
return UnCivGame.Current.civInfo.civName.equals(arg0.Owner); return UnCivGame.Current.civInfo.civName.equals(arg0.owner);
} }
}); });
} }
@ -47,27 +47,27 @@ public class CityInfo {
} }
CityInfo(CivilizationInfo civInfo, Vector2 cityLocation) { CityInfo(CivilizationInfo civInfo, Vector2 cityLocation) {
Name = CityNames[civInfo.Cities.size()]; name = CityNames[civInfo.cities.size()];
this.cityLocation = cityLocation; this.cityLocation = cityLocation;
cityBuildings = new CityBuildings(this); cityBuildings = new CityBuildings(this);
cityPopulation = new CityPopulation(); cityPopulation = new CityPopulation();
for(TileInfo tileInfo : civInfo.tileMap.getTilesInDistance(cityLocation,1)) { for(TileInfo tileInfo : civInfo.tileMap.getTilesInDistance(cityLocation,1)) {
tileInfo.Owner = civInfo.civName; tileInfo.owner = civInfo.civName;
} }
civInfo.tileMap.get(cityLocation).WorkingCity = this.Name; civInfo.tileMap.get(cityLocation).workingCity = this.name;
autoAssignWorker(); autoAssignWorker();
civInfo.Cities.add(this); civInfo.cities.add(this);
} }
ArrayList<String> getLuxuryResources() { ArrayList<String> getLuxuryResources() {
ArrayList<String> LuxuryResources = new ArrayList<String>(); ArrayList<String> LuxuryResources = new ArrayList<String>();
for (TileInfo tileInfo : getTilesInRange()) { for (TileInfo tileInfo : getTilesInRange()) {
TileResource resource = tileInfo.GetTileResource(); TileResource resource = tileInfo.getTileResource();
if (resource != null && resource.ResourceType == ResourceType.Luxury && resource.Improvement.equals(tileInfo.Improvement)) if (resource != null && resource.ResourceType == ResourceType.Luxury && resource.Improvement.equals(tileInfo.improvement))
LuxuryResources.add(tileInfo.Resource); LuxuryResources.add(tileInfo.resource);
} }
return LuxuryResources; return LuxuryResources;
} }
@ -77,7 +77,7 @@ public class CityInfo {
return getTilesInRange().count(new Predicate<TileInfo>() { return getTilesInRange().count(new Predicate<TileInfo>() {
@Override @Override
public boolean evaluate(TileInfo arg0) { public boolean evaluate(TileInfo arg0) {
return Name.equals(arg0.WorkingCity); return name.equals(arg0.workingCity);
} }
})-1; // 1 is the city center })-1; // 1 is the city center
} }
@ -99,8 +99,8 @@ public class CityInfo {
// Working ppl // Working ppl
for (TileInfo cell : getTilesInRange()) for (TileInfo cell : getTilesInRange())
if (Name.equals(cell.WorkingCity) || cell.IsCityCenter()) if (name.equals(cell.workingCity) || cell.isCityCenter())
stats.add(cell.GetTileStats()); stats.add(cell.getTileStats());
//idle ppl //idle ppl
stats.Production += getFreePopulation(); stats.Production += getFreePopulation();
@ -123,10 +123,6 @@ public class CityInfo {
cityBuildings.NextTurn(stats.Production); cityBuildings.NextTurn(stats.Production);
for (TileInfo tileInfo : getTilesInRange()) {
tileInfo.NextTurn();
}
cultureStored+=stats.Culture; cultureStored+=stats.Culture;
if(cultureStored>=getCultureToNextTile()){ if(cultureStored>=getCultureToNextTile()){
addNewTile(); addNewTile();
@ -143,7 +139,7 @@ public class CityInfo {
tiles = tiles.where(new Predicate<TileInfo>() { tiles = tiles.where(new Predicate<TileInfo>() {
@Override @Override
public boolean evaluate(TileInfo arg0) { public boolean evaluate(TileInfo arg0) {
return arg0.Owner == null; return arg0.owner == null;
} }
}); });
if(tiles.size()==0) continue; if(tiles.size()==0) continue;
@ -157,7 +153,7 @@ public class CityInfo {
TileChosen = tile; TileChosen = tile;
} }
} }
TileChosen.Owner = UnCivGame.Current.civInfo.civName; TileChosen.owner = UnCivGame.Current.civInfo.civName;
return; return;
} }
} }
@ -166,8 +162,8 @@ public class CityInfo {
double maxValue = 0; double maxValue = 0;
TileInfo toWork = null; TileInfo toWork = null;
for (TileInfo tileInfo : getTilesInRange()) { for (TileInfo tileInfo : getTilesInRange()) {
if (tileInfo.WorkingCity!=null) continue; if (tileInfo.workingCity !=null) continue;
FullStats stats = tileInfo.GetTileStats(); FullStats stats = tileInfo.getTileStats();
double value = stats.Food + stats.Production * 0.5; double value = stats.Food + stats.Production * 0.5;
if (value > maxValue) { if (value > maxValue) {
@ -175,11 +171,11 @@ public class CityInfo {
toWork = tileInfo; toWork = tileInfo;
} }
} }
toWork.WorkingCity = Name; toWork.workingCity = name;
} }
private double rankTile(TileInfo tile){ private double rankTile(TileInfo tile){
FullStats stats = tile.GetTileStats(); FullStats stats = tile.getTileStats();
double rank=0; double rank=0;
if(stats.Food<2) rank+=stats.Food; 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 else rank += 2 + (stats.Food-2)/2; // 1 point for each food up to 2, from there on half a point
@ -187,7 +183,7 @@ public class CityInfo {
rank+=stats.Production; rank+=stats.Production;
rank+=stats.Science; rank+=stats.Science;
rank+=stats.Culture; rank+=stats.Culture;
if(tile.Improvement==null) rank+=0.5; // Improvement potential! if(tile.improvement ==null) rank+=0.5; // improvement potential!
return rank; return rank;
} }
} }

View File

@ -18,50 +18,50 @@ public class CivilizationInfo {
public int baseHappiness = 15; public int baseHappiness = 15;
public String civName = "Babylon"; public String civName = "Babylon";
public CivilizationTech Tech = new CivilizationTech(); public CivilizationTech tech = new CivilizationTech();
public int turns = 1; public int turns = 1;
public LinqCollection<CityInfo> Cities = new LinqCollection<CityInfo>(); public LinqCollection<CityInfo> cities = new LinqCollection<CityInfo>();
public TileMap tileMap = new TileMap(20); public TileMap tileMap = new TileMap(20);
public int CurrentCity=0; //index! public int currentCity =0; //index!
public CivilizationInfo(){ public CivilizationInfo(){
} }
public CityInfo GetCurrentCity() { return Cities.get(CurrentCity); } public CityInfo getCurrentCity() { return cities.get(currentCity); }
public int TurnsToTech(String TechName) { public int turnsToTech(String TechName) {
return (int) Math.ceil((float)(GameBasics.Technologies.get(TechName).Cost - Tech.ResearchOfTech(TechName)) return (int) Math.ceil((float)(GameBasics.Technologies.get(TechName).Cost - tech.ResearchOfTech(TechName))
/ GetStatsForNextTurn().Science); / getStatsForNextTurn().Science);
} }
public void addCity(Vector2 location){ public void addCity(Vector2 location){
CityInfo city = new CityInfo(this,location); CityInfo city = new CityInfo(this,location);
if(Cities.size()==1) city.cityBuildings.BuiltBuildings.add("Palace"); if(cities.size()==1) city.cityBuildings.BuiltBuildings.add("Palace");
} }
public void NextTurn()//out boolean displayTech) public void nextTurn()//out boolean displayTech)
{ {
CivStats nextTurnStats = GetStatsForNextTurn(); CivStats nextTurnStats = getStatsForNextTurn();
civStats.add(nextTurnStats); civStats.add(nextTurnStats);
if(Cities.size() > 0) Tech.NextTurn(nextTurnStats.Science); if(cities.size() > 0) tech.NextTurn(nextTurnStats.Science);
for (CityInfo city : Cities.as(CityInfo.class)) city.nextTurn(); for (CityInfo city : cities) city.nextTurn();
for(TileInfo tile : tileMap.values()) if(tile.Unit!=null) tile.Unit.CurrentMovement = tile.Unit.MaxMovement; for(TileInfo tile : tileMap.values()) tile.nextTurn();
turns += 1; turns += 1;
} }
public CivStats GetStatsForNextTurn() { public CivStats getStatsForNextTurn() {
CivStats statsForTurn = new CivStats() {{ CivStats statsForTurn = new CivStats() {{
Happiness = baseHappiness; Happiness = baseHappiness;
}}; }};
HashSet<String> LuxuryResources = new HashSet<String>(); HashSet<String> LuxuryResources = new HashSet<String>();
for (CityInfo city : Cities) { for (CityInfo city : cities) {
statsForTurn.add(city.getCityStats()); statsForTurn.add(city.getCityStats());
LuxuryResources.addAll(city.getLuxuryResources()); LuxuryResources.addAll(city.getLuxuryResources());
} }

View File

@ -9,59 +9,65 @@ import com.unciv.models.gamebasics.TileImprovement;
import com.unciv.models.gamebasics.TileResource; import com.unciv.models.gamebasics.TileResource;
import com.unciv.models.stats.FullStats; import com.unciv.models.stats.FullStats;
enum RoadStatus{
None,
Road,
Railroad
}
public class TileInfo public class TileInfo
{ {
public Unit Unit; public Unit unit;
public Vector2 Position; public Vector2 position;
public String BaseTerrain; public String baseTerrain;
public String TerrainFeature; public String terrainFeature;
public String Resource; public String resource;
// public boolean IsWorked = false; public String improvement;
public String Improvement; public String improvementInProgress;
public String ImprovementInProgress; public String owner; // owning civ name
public String Owner; // owning civ name public String workingCity; // Working City name
public String WorkingCity; // Working City Name public RoadStatus roadStatus = RoadStatus.None;
public int TurnsToImprovement; public int turnsToImprovement;
public Terrain GetBaseTerrain(){return GameBasics.Terrains.get(BaseTerrain);} public Terrain getBaseTerrain(){return GameBasics.Terrains.get(baseTerrain);}
public CityInfo GetCity(){ public CityInfo getCity(){
if(WorkingCity == null) return null; if(workingCity == null) return null;
return CivilizationInfo.current().Cities.first(new Predicate<CityInfo>() { return CivilizationInfo.current().cities.first(new Predicate<CityInfo>() {
@Override @Override
public boolean evaluate(CityInfo arg0) { public boolean evaluate(CityInfo arg0) {
return arg0.Name.equals(WorkingCity); return arg0.name.equals(workingCity);
} }
});} });}
public Terrain GetTerrainFeature(){return TerrainFeature==null ? null : GameBasics.Terrains.get(TerrainFeature);} public Terrain getTerrainFeature(){return terrainFeature ==null ? null : GameBasics.Terrains.get(terrainFeature);}
public Terrain GetLastTerrain() { public Terrain getLastTerrain() {
return TerrainFeature == null ? GetBaseTerrain() : GetTerrainFeature(); return terrainFeature == null ? getBaseTerrain() : getTerrainFeature();
} }
public TileResource GetTileResource(){return Resource==null ? null : GameBasics.TileResources.get(Resource);} public TileResource getTileResource(){return resource ==null ? null : GameBasics.TileResources.get(resource);}
public boolean IsCityCenter(){return GetCity()!=null && Position.equals(GetCity().cityLocation);} public boolean isCityCenter(){return getCity()!=null && position.equals(getCity().cityLocation);}
public TileImprovement GetTileImprovement(){return Improvement==null ? null : GameBasics.TileImprovements.get(Improvement);} public TileImprovement getTileImprovement(){return improvement ==null ? null : GameBasics.TileImprovements.get(improvement);}
private boolean IsResearched(String techName) { return UnCivGame.Current.civInfo.Tech.IsResearched(techName); } private boolean isResearched(String techName) { return UnCivGame.Current.civInfo.tech.IsResearched(techName); }
public FullStats GetTileStats() public FullStats getTileStats()
{ {
FullStats stats = new FullStats(GetBaseTerrain()); FullStats stats = new FullStats(getBaseTerrain());
if(TerrainFeature!=null){ if(terrainFeature !=null){
Terrain terrainFeature = GetTerrainFeature(); Terrain terrainFeature = getTerrainFeature();
if(terrainFeature.OverrideStats) stats = new FullStats(terrainFeature); if(terrainFeature.OverrideStats) stats = new FullStats(terrainFeature);
else stats.add(terrainFeature); else stats.add(terrainFeature);
} }
TileResource resource = GetTileResource(); TileResource resource = getTileResource();
CityInfo City = GetCity(); CityInfo City = getCity();
if (HasViewableResource()) if (hasViewableResource())
{ {
stats.add(resource); stats.add(resource);
if(resource.Building!=null && City!=null && City.cityBuildings.IsBuilt(resource.Building)) if(resource.Building!=null && City!=null && City.cityBuildings.IsBuilt(resource.Building))
@ -70,17 +76,17 @@ public class TileInfo
} }
} }
TileImprovement improvement = GetTileImprovement(); TileImprovement improvement = getTileImprovement();
if (improvement != null) if (improvement != null)
{ {
if (resource != null && resource.Improvement.equals(improvement.Name)) if (resource != null && resource.Improvement.equals(improvement.Name))
stats.add(resource.ImprovementStats); stats.add(resource.ImprovementStats);
else stats.add(improvement); else stats.add(improvement);
if (IsResearched(improvement.ImprovingTech)) stats.add(improvement.ImprovingTechStats); if (isResearched(improvement.ImprovingTech)) stats.add(improvement.ImprovingTechStats);
} }
if (City != null && City.cityLocation.equals(Position)) { if (City != null && City.cityLocation.equals(position)) {
if (stats.Food < 2) stats.Food = 2; if (stats.Food < 2) stats.Food = 2;
if (stats.Production < 1) stats.Production = 1; if (stats.Production < 1) stats.Production = 1;
} }
@ -88,51 +94,53 @@ public class TileInfo
return stats; return stats;
} }
public boolean CanBuildImprovement(TileImprovement improvement) public boolean canBuildImprovement(TileImprovement improvement)
{ {
Terrain topTerrain = TerrainFeature==null ? GetBaseTerrain() : GetTerrainFeature(); Terrain topTerrain = terrainFeature ==null ? getBaseTerrain() : getTerrainFeature();
if (improvement.TechRequired != null && !IsResearched(improvement.TechRequired)) return false; if (improvement.TechRequired != null && !isResearched(improvement.TechRequired)) return false;
if (improvement.TerrainsCanBeBuiltOn.contains(topTerrain.Name)) return true; if (improvement.TerrainsCanBeBuiltOn.contains(topTerrain.Name)) return true;
if (topTerrain.Unbuildable) return false; if (topTerrain.Unbuildable) return false;
return Resource != null && GetTileResource().Improvement.equals(improvement.Name); return resource != null && getTileResource().Improvement.equals(improvement.Name);
} }
public void StartWorkingOnImprovement(TileImprovement improvement) public void startWorkingOnImprovement(TileImprovement improvement)
{ {
ImprovementInProgress = improvement.Name; improvementInProgress = improvement.Name;
TurnsToImprovement = improvement.TurnsToBuild; turnsToImprovement = improvement.TurnsToBuild;
} }
public void StopWorkingOnImprovement() public void stopWorkingOnImprovement()
{ {
ImprovementInProgress = null; improvementInProgress = null;
} }
public void NextTurn() public void nextTurn()
{ {
if (ImprovementInProgress == null || Unit==null || !Unit.Name.equals("Worker")) return; if(unit !=null) unit.CurrentMovement = unit.MaxMovement;
TurnsToImprovement -= 1;
if(TurnsToImprovement == 0)
{
if (ImprovementInProgress.startsWith("Remove")) TerrainFeature = null;
else Improvement = ImprovementInProgress;
ImprovementInProgress = null; if (improvementInProgress == null || unit ==null || !unit.Name.equals("Worker")) return;
turnsToImprovement -= 1;
if(turnsToImprovement == 0)
{
if (improvementInProgress.startsWith("Remove")) terrainFeature = null;
else improvement = improvementInProgress;
improvementInProgress = null;
} }
} }
public String toString() { public String toString() {
StringBuilder SB = new StringBuilder(this.BaseTerrain); StringBuilder SB = new StringBuilder(this.baseTerrain);
if (TerrainFeature != null) SB.append(",\r\n" + TerrainFeature); if (terrainFeature != null) SB.append(",\r\n" + terrainFeature);
if (HasViewableResource()) SB.append(",\r\n" + Resource); if (hasViewableResource()) SB.append(",\r\n" + resource);
if (Improvement != null) SB.append(",\r\n" + Improvement); if (improvement != null) SB.append(",\r\n" + improvement);
if (ImprovementInProgress != null) SB.append(",\r\n" + ImprovementInProgress+" in "+this.TurnsToImprovement+" turns"); if (improvementInProgress != null) SB.append(",\r\n" + improvementInProgress +" in "+this.turnsToImprovement +" turns");
if(Unit!=null) SB.append(",\r\n" + Unit.Name+ "("+Unit.CurrentMovement+"/"+Unit.MaxMovement+")"); if(unit !=null) SB.append(",\r\n" + unit.Name+ "("+ unit.CurrentMovement+"/"+ unit.MaxMovement+")");
return SB.toString(); return SB.toString();
} }
public boolean HasViewableResource() { public boolean hasViewableResource() {
return Resource != null && (GetTileResource().RevealedBy==null || IsResearched(GetTileResource().RevealedBy)); return resource != null && (getTileResource().RevealedBy==null || isResearched(getTileResource().RevealedBy));
} }
} }

View File

@ -1,6 +1,5 @@
package com.unciv.civinfo; package com.unciv.civinfo;
import com.badlogic.gdx.math.Vector;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Predicate; import com.badlogic.gdx.utils.Predicate;
import com.unciv.game.HexMath; import com.unciv.game.HexMath;
@ -24,36 +23,36 @@ public class TileMap{
private void addRandomTile(Vector2 position) { private void addRandomTile(Vector2 position) {
final TileInfo tileInfo = new TileInfo(); final TileInfo tileInfo = new TileInfo();
tileInfo.Position = position; tileInfo.position = position;
LinqCollection<Terrain> Terrains = GameBasics.Terrains.linqValues(); LinqCollection<Terrain> Terrains = GameBasics.Terrains.linqValues();
final Terrain baseTerrain = Terrains.where(new Predicate<Terrain>() { final Terrain baseTerrain = Terrains.where(new Predicate<Terrain>() {
@Override @Override
public boolean evaluate(Terrain arg0) { public boolean evaluate(Terrain arg0) {
return arg0.Type.equals("BaseTerrain") && !arg0.Name.equals("Lakes"); return arg0.Type.equals("baseTerrain") && !arg0.Name.equals("Lakes");
} }
}).getRandom(); }).getRandom();
tileInfo.BaseTerrain = baseTerrain.Name; tileInfo.baseTerrain = baseTerrain.Name;
if (baseTerrain.CanHaveOverlay) { if (baseTerrain.CanHaveOverlay) {
if (Math.random() > 0.7f) { if (Math.random() > 0.7f) {
Terrain SecondaryTerrain = Terrains.where(new Predicate<Terrain>() { Terrain SecondaryTerrain = Terrains.where(new Predicate<Terrain>() {
@Override @Override
public boolean evaluate(Terrain arg0) { public boolean evaluate(Terrain arg0) {
return arg0.Type.equals("TerrainFeature") && arg0.OccursOn.contains(baseTerrain.Name); return arg0.Type.equals("terrainFeature") && arg0.OccursOn.contains(baseTerrain.Name);
} }
}).getRandom(); }).getRandom();
if (SecondaryTerrain != null) tileInfo.TerrainFeature = SecondaryTerrain.Name; if (SecondaryTerrain != null) tileInfo.terrainFeature = SecondaryTerrain.Name;
} }
} }
LinqCollection<TileResource> TileResources = GameBasics.TileResources.linqValues(); LinqCollection<TileResource> TileResources = GameBasics.TileResources.linqValues();
// Resources are placed according to TerrainFeature, if exists, otherwise according to BaseLayer. // Resources are placed according to terrainFeature, if exists, otherwise according to BaseLayer.
TileResources = TileResources.where(new Predicate<TileResource>() { TileResources = TileResources.where(new Predicate<TileResource>() {
@Override @Override
public boolean evaluate(TileResource arg0) { public boolean evaluate(TileResource arg0) {
return arg0.TerrainsCanBeFoundOn.contains(tileInfo.GetLastTerrain().Name); return arg0.TerrainsCanBeFoundOn.contains(tileInfo.getLastTerrain().Name);
} }
}); });
@ -65,7 +64,7 @@ public class TileMap{
} else if (Math.random() < 1 / 10f) { } else if (Math.random() < 1 / 10f) {
resource = GetRandomResource(TileResources, ResourceType.Luxury); resource = GetRandomResource(TileResources, ResourceType.Luxury);
} }
if (resource != null) tileInfo.Resource = resource.Name; if (resource != null) tileInfo.resource = resource.Name;
tiles.put(position.toString(),tileInfo); tiles.put(position.toString(),tileInfo);
} }

View File

@ -65,14 +65,14 @@ public class CityScreen extends CameraStageBaseScreen {
private void updateCityPickerTable() { private void updateCityPickerTable() {
CityPickerTable.clear(); CityPickerTable.clear();
CityPickerTable.row().pad(20); CityPickerTable.row().pad(20);
if(game.civInfo.Cities.size()>1) { if(game.civInfo.cities.size()>1) {
TextButton prevCityButton = new TextButton("<", skin); TextButton prevCityButton = new TextButton("<", skin);
prevCityButton.addListener(new ClickListener() { prevCityButton.addListener(new ClickListener() {
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
com.unciv.civinfo.CivilizationInfo ci = game.civInfo; com.unciv.civinfo.CivilizationInfo ci = game.civInfo;
if (ci.CurrentCity == 0) ci.CurrentCity = ci.Cities.size()-1; if (ci.currentCity == 0) ci.currentCity = ci.cities.size()-1;
else ci.CurrentCity--; else ci.currentCity--;
game.setScreen(new CityScreen(game)); game.setScreen(new CityScreen(game));
dispose(); dispose();
} }
@ -80,18 +80,18 @@ public class CityScreen extends CameraStageBaseScreen {
CityPickerTable.add(prevCityButton); CityPickerTable.add(prevCityButton);
} }
Label currentCityLabel = new Label(game.civInfo.GetCurrentCity().Name, skin); Label currentCityLabel = new Label(game.civInfo.getCurrentCity().name, skin);
currentCityLabel.setFontScale(2); currentCityLabel.setFontScale(2);
CityPickerTable.add(currentCityLabel); CityPickerTable.add(currentCityLabel);
if(game.civInfo.Cities.size()>1) { if(game.civInfo.cities.size()>1) {
TextButton nextCityButton = new TextButton(">", skin); TextButton nextCityButton = new TextButton(">", skin);
nextCityButton.addListener(new ClickListener() { nextCityButton.addListener(new ClickListener() {
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
com.unciv.civinfo.CivilizationInfo ci = game.civInfo; com.unciv.civinfo.CivilizationInfo ci = game.civInfo;
if (ci.CurrentCity == ci.Cities.size()-1) ci.CurrentCity = 0; if (ci.currentCity == ci.cities.size()-1) ci.currentCity = 0;
else ci.CurrentCity++; else ci.currentCity++;
game.setScreen(new CityScreen(game)); game.setScreen(new CityScreen(game));
dispose(); dispose();
} }
@ -109,7 +109,7 @@ public class CityScreen extends CameraStageBaseScreen {
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
game.setWorldScreen(); game.setWorldScreen();
game.worldScreen.setCenterPosition(game.civInfo.GetCurrentCity().cityLocation); game.worldScreen.setCenterPosition(game.civInfo.getCurrentCity().cityLocation);
dispose(); dispose();
} }
}); });
@ -119,7 +119,7 @@ public class CityScreen extends CameraStageBaseScreen {
} }
private void addTiles() { private void addTiles() {
final CityInfo cityInfo = game.civInfo.GetCurrentCity(); final CityInfo cityInfo = game.civInfo.getCurrentCity();
Group allTiles = new Group(); Group allTiles = new Group();
@ -134,19 +134,19 @@ public class CityScreen extends CameraStageBaseScreen {
}); });
if(!cityInfo.getTilesInRange().contains(tileInfo)) group.setColor(0,0,0,0.3f); if(!cityInfo.getTilesInRange().contains(tileInfo)) group.setColor(0,0,0,0.3f);
else if(!tileInfo.IsCityCenter()) { else if(!tileInfo.isCityCenter()) {
group.addPopulationIcon(); group.addPopulationIcon();
group.populationImage.addListener(new ClickListener() { group.populationImage.addListener(new ClickListener() {
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
if(tileInfo.WorkingCity==null && cityInfo.getFreePopulation() > 0) tileInfo.WorkingCity = cityInfo.Name; if(tileInfo.workingCity ==null && cityInfo.getFreePopulation() > 0) tileInfo.workingCity = cityInfo.name;
else if(cityInfo.Name.equals(tileInfo.WorkingCity)) tileInfo.WorkingCity = null; else if(cityInfo.name.equals(tileInfo.workingCity)) tileInfo.workingCity = null;
updateCityTable(); updateCityTable();
} }
}); });
} }
Vector2 positionalVector = HexMath.Hex2WorldCoords(tileInfo.Position.cpy().sub(cityInfo.cityLocation)); Vector2 positionalVector = HexMath.Hex2WorldCoords(tileInfo.position.cpy().sub(cityInfo.cityLocation));
int groupSize = 50; int groupSize = 50;
group.setPosition(stage.getWidth()/2 + positionalVector.x*0.8f * groupSize, group.setPosition(stage.getWidth()/2 + positionalVector.x*0.8f * groupSize,
stage.getHeight()/2 + positionalVector.y*0.8f * groupSize); stage.getHeight()/2 + positionalVector.y*0.8f * groupSize);
@ -185,7 +185,7 @@ public class CityScreen extends CameraStageBaseScreen {
} }
private void updateCityTable() { private void updateCityTable() {
CityInfo cityInfo = game.civInfo.GetCurrentCity(); CityInfo cityInfo = game.civInfo.getCurrentCity();
FullStats stats = cityInfo.getCityStats(); FullStats stats = cityInfo.getCityStats();
CityStatsTable.pad(20); CityStatsTable.pad(20);
CityStatsTable.columnDefaults(0).padRight(10); CityStatsTable.columnDefaults(0).padRight(10);
@ -211,7 +211,7 @@ public class CityScreen extends CameraStageBaseScreen {
CityStatsTable.row(); CityStatsTable.row();
} }
String CurrentBuilding = game.civInfo.GetCurrentCity().cityBuildings.CurrentBuilding; String CurrentBuilding = game.civInfo.getCurrentCity().cityBuildings.CurrentBuilding;
String BuildingText = "Pick building"; String BuildingText = "Pick building";
if(CurrentBuilding != null) BuildingText = CurrentBuilding+"\r\n" if(CurrentBuilding != null) BuildingText = CurrentBuilding+"\r\n"
@ -236,8 +236,8 @@ public class CityScreen extends CameraStageBaseScreen {
if(selectedTile == null) return; if(selectedTile == null) return;
TileTable.clearChildren(); TileTable.clearChildren();
CityInfo City =game.civInfo.GetCurrentCity(); CityInfo City =game.civInfo.getCurrentCity();
FullStats stats = selectedTile.GetTileStats(); FullStats stats = selectedTile.getTileStats();
TileTable.pad(20); TileTable.pad(20);
TileTable.columnDefaults(0).padRight(10); TileTable.columnDefaults(0).padRight(10);

View File

@ -5,7 +5,6 @@ import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.ui.Container; import com.badlogic.gdx.scenes.scene2d.ui.Container;
import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.utils.Align;
import com.unciv.civinfo.TileInfo; import com.unciv.civinfo.TileInfo;
public class TileGroup extends Group { public class TileGroup extends Group {
@ -22,7 +21,7 @@ public class TileGroup extends Group {
TileGroup(TileInfo tileInfo){ TileGroup(TileInfo tileInfo){
this.tileInfo = tileInfo; this.tileInfo = tileInfo;
String terrainFileName = "TerrainIcons/" + tileInfo.GetLastTerrain().Name.replace(' ','_') + "_(Civ5).png"; String terrainFileName = "TerrainIcons/" + tileInfo.getLastTerrain().Name.replace(' ','_') + "_(Civ5).png";
terrainImage = ImageGetter.getImageByFilename(terrainFileName); terrainImage = ImageGetter.getImageByFilename(terrainFileName);
terrainImage.setSize(50,50); terrainImage.setSize(50,50);
addActor(terrainImage); addActor(terrainImage);
@ -43,8 +42,8 @@ public class TileGroup extends Group {
void update() { void update() {
if (tileInfo.HasViewableResource() && resourceImage == null) { // Need to add the resource image! if (tileInfo.hasViewableResource() && resourceImage == null) { // Need to add the resource image!
String fileName = "ResourceIcons/" + tileInfo.Resource + "_(Civ5).png"; String fileName = "ResourceIcons/" + tileInfo.resource + "_(Civ5).png";
Image image = ImageGetter.getImageByFilename(fileName); Image image = ImageGetter.getImageByFilename(fileName);
image.setSize(20,20); image.setSize(20,20);
image.moveBy(terrainImage.getWidth()-image.getWidth(), 0); // bottom right image.moveBy(terrainImage.getWidth()-image.getWidth(), 0); // bottom right
@ -52,25 +51,25 @@ public class TileGroup extends Group {
addActor(image); addActor(image);
} }
if (tileInfo.Unit != null && unitImage == null) { if (tileInfo.unit != null && unitImage == null) {
unitImage = ImageGetter.getImageByFilename("StatIcons/" + tileInfo.Unit.Name + "_(Civ5).png"); unitImage = ImageGetter.getImageByFilename("StatIcons/" + tileInfo.unit.Name + "_(Civ5).png");
addActor(unitImage); addActor(unitImage);
unitImage.setSize(20, 20); // not moved - is at bottom left unitImage.setSize(20, 20); // not moved - is at bottom left
} }
if (tileInfo.Unit == null && unitImage != null) { if (tileInfo.unit == null && unitImage != null) {
unitImage.remove(); unitImage.remove();
unitImage = null; unitImage = null;
} }
if(unitImage!=null){ if(unitImage!=null){
if(tileInfo.Unit.CurrentMovement==0) unitImage.setColor(Color.GRAY); if(tileInfo.unit.CurrentMovement==0) unitImage.setColor(Color.GRAY);
else unitImage.setColor(Color.WHITE); else unitImage.setColor(Color.WHITE);
} }
if (tileInfo.Improvement != null && improvementImage == null) { if (tileInfo.improvement != null && improvementImage == null) {
improvementImage = ImageGetter.getImageByFilename("ImprovementIcons/" + tileInfo.Improvement.replace(' ','_') + "_(Civ5).png"); improvementImage = ImageGetter.getImageByFilename("ImprovementIcons/" + tileInfo.improvement.replace(' ','_') + "_(Civ5).png");
addActor(improvementImage); addActor(improvementImage);
improvementImage.setSize(20, 20); improvementImage.setSize(20, 20);
improvementImage.moveBy(terrainImage.getWidth()-improvementImage.getWidth(), improvementImage.moveBy(terrainImage.getWidth()-improvementImage.getWidth(),
@ -78,7 +77,7 @@ public class TileGroup extends Group {
} }
if(populationImage!=null){ if(populationImage!=null){
if(tileInfo.WorkingCity!=null) populationImage.setColor(Color.WHITE); if(tileInfo.workingCity !=null) populationImage.setColor(Color.WHITE);
else populationImage.setColor(Color.GRAY); else populationImage.setColor(Color.GRAY);
} }
} }

View File

@ -40,7 +40,7 @@ public class UnCivGame extends Game {
public void startNewGame(){ public void startNewGame(){
civInfo = new CivilizationInfo(); civInfo = new CivilizationInfo();
civInfo.tileMap.get(Vector2.Zero).Unit = new Unit("Settler",2); civInfo.tileMap.get(Vector2.Zero).unit = new Unit("Settler",2);
worldScreen = new WorldScreen(this); worldScreen = new WorldScreen(this);
setWorldScreen(); setWorldScreen();

View File

@ -17,7 +17,6 @@ import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Predicate; import com.badlogic.gdx.utils.Predicate;
import com.unciv.civinfo.CityInfo;
import com.unciv.civinfo.TileInfo; import com.unciv.civinfo.TileInfo;
import com.unciv.game.pickerscreens.GameSaver; import com.unciv.game.pickerscreens.GameSaver;
import com.unciv.game.pickerscreens.ImprovementPickerScreen; import com.unciv.game.pickerscreens.ImprovementPickerScreen;
@ -123,7 +122,7 @@ public class WorldScreen extends CameraStageBaseScreen {
} }
private void updateTechButton() { private void updateTechButton() {
TechButton.setVisible(game.civInfo.Cities.size()!=0); TechButton.setVisible(game.civInfo.cities.size()!=0);
TechButton.clearListeners(); TechButton.clearListeners();
TechButton.addListener(new ClickListener(){ TechButton.addListener(new ClickListener(){
@Override @Override
@ -133,9 +132,9 @@ public class WorldScreen extends CameraStageBaseScreen {
} }
}); });
if (game.civInfo.Tech.CurrentTechnology() == null) TechButton.setText("Choose a tech!"); if (game.civInfo.tech.CurrentTechnology() == null) TechButton.setText("Choose a tech!");
else TechButton.setText(game.civInfo.Tech.CurrentTechnology() + "\r\n" else TechButton.setText(game.civInfo.tech.CurrentTechnology() + "\r\n"
+ game.civInfo.TurnsToTech(game.civInfo.Tech.CurrentTechnology()) + " turns"); + game.civInfo.turnsToTech(game.civInfo.tech.CurrentTechnology()) + " turns");
TechButton.setSize(TechButton.getPrefWidth(), TechButton.getPrefHeight()); TechButton.setSize(TechButton.getPrefWidth(), TechButton.getPrefHeight());
TechButton.setPosition(10, CivTable.getY() - TechButton.getHeight()-5); TechButton.setPosition(10, CivTable.getY() - TechButton.getHeight()-5);
@ -161,7 +160,7 @@ public class WorldScreen extends CameraStageBaseScreen {
CivTable.add(new Label("Turns: " + game.civInfo.turns+"/400", skin)); CivTable.add(new Label("Turns: " + game.civInfo.turns+"/400", skin));
CivStats nextTurnStats = game.civInfo.GetStatsForNextTurn(); CivStats nextTurnStats = game.civInfo.getStatsForNextTurn();
CivTable.add(new Label("Gold: " + currentStats.Gold + "(" +(nextTurnStats.Gold>0?"+":"") + nextTurnStats.Gold+")", skin)); CivTable.add(new Label("Gold: " + currentStats.Gold + "(" +(nextTurnStats.Gold>0?"+":"") + nextTurnStats.Gold+")", skin));
@ -181,13 +180,13 @@ public class WorldScreen extends CameraStageBaseScreen {
nextTurnButton.addListener(new ClickListener() { nextTurnButton.addListener(new ClickListener() {
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
if (game.civInfo.Tech.CurrentTechnology() == null if (game.civInfo.tech.CurrentTechnology() == null
&& game.civInfo.Cities.size()!=0) { && game.civInfo.cities.size()!=0) {
game.setScreen(new TechPickerScreen(game)); game.setScreen(new TechPickerScreen(game));
dispose(); dispose();
return; return;
} }
game.civInfo.NextTurn(); game.civInfo.nextTurn();
GameSaver.SaveGame(game,"Autosave"); GameSaver.SaveGame(game,"Autosave");
update(); update();
} }
@ -213,12 +212,12 @@ public class WorldScreen extends CameraStageBaseScreen {
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
selectedTile = tileInfo; selectedTile = tileInfo;
if(unitTile != null && group.tileInfo.Unit == null ) { if(unitTile != null && group.tileInfo.unit == null ) {
int distance = HexMath.GetDistance(unitTile.Position, group.tileInfo.Position); int distance = HexMath.GetDistance(unitTile.position, group.tileInfo.position);
if (distance <= unitTile.Unit.CurrentMovement) { if (distance <= unitTile.unit.CurrentMovement) {
unitTile.Unit.CurrentMovement -= distance; unitTile.unit.CurrentMovement -= distance;
group.tileInfo.Unit = unitTile.Unit; group.tileInfo.unit = unitTile.unit;
unitTile.Unit = null; unitTile.unit = null;
unitTile = null; unitTile = null;
selectedTile = group.tileInfo; selectedTile = group.tileInfo;
} }
@ -229,12 +228,12 @@ public class WorldScreen extends CameraStageBaseScreen {
}); });
Vector2 positionalVector = HexMath.Hex2WorldCoords(tileInfo.Position); Vector2 positionalVector = HexMath.Hex2WorldCoords(tileInfo.position);
int groupSize = 50; int groupSize = 50;
group.setPosition(stage.getWidth() / 2 + positionalVector.x * 0.8f * groupSize, group.setPosition(stage.getWidth() / 2 + positionalVector.x * 0.8f * groupSize,
stage.getHeight() / 2 + positionalVector.y * 0.8f * groupSize); stage.getHeight() / 2 + positionalVector.y * 0.8f * groupSize);
group.setSize(groupSize, groupSize); group.setSize(groupSize, groupSize);
tileGroups.put(tileInfo.Position.toString(), group); tileGroups.put(tileInfo.position.toString(), group);
allTiles.addActor(group); allTiles.addActor(group);
topX = Math.max(topX, group.getX() + groupSize); topX = Math.max(topX, group.getX() + groupSize);
topY = Math.max(topY, group.getY() + groupSize); topY = Math.max(topY, group.getY() + groupSize);
@ -279,7 +278,7 @@ public class WorldScreen extends CameraStageBaseScreen {
private void updateTileTable() { private void updateTileTable() {
if(selectedTile == null) return; if(selectedTile == null) return;
TileTable.clearChildren(); TileTable.clearChildren();
FullStats stats = selectedTile.GetTileStats(); FullStats stats = selectedTile.getTileStats();
TileTable.pad(20); TileTable.pad(20);
TileTable.columnDefaults(0).padRight(10); TileTable.columnDefaults(0).padRight(10);
@ -305,11 +304,11 @@ public class WorldScreen extends CameraStageBaseScreen {
TileTable.row(); TileTable.row();
} }
if(selectedTile.Unit!=null){ if(selectedTile.unit !=null){
TextButton moveUnitButton = new TextButton("Move to", skin); TextButton moveUnitButton = new TextButton("Move to", skin);
if(unitTile == selectedTile) moveUnitButton = new TextButton("Stop movement",skin); if(unitTile == selectedTile) moveUnitButton = new TextButton("Stop movement",skin);
moveUnitButton.getLabel().setFontScale(buttonScale); moveUnitButton.getLabel().setFontScale(buttonScale);
if(selectedTile.Unit.CurrentMovement == 0){ if(selectedTile.unit.CurrentMovement == 0){
moveUnitButton.setColor(Color.GRAY); moveUnitButton.setColor(Color.GRAY);
moveUnitButton.setTouchable(Touchable.disabled); moveUnitButton.setTouchable(Touchable.disabled);
} }
@ -325,7 +324,7 @@ public class WorldScreen extends CameraStageBaseScreen {
// Set all tiles transparent except those in unit range // Set all tiles transparent except those in unit range
for(TileGroup TG : tileGroups.linqValues()) TG.setColor(0,0,0,0.3f); for(TileGroup TG : tileGroups.linqValues()) TG.setColor(0,0,0,0.3f);
for(Vector2 vector : HexMath.GetVectorsInDistance(unitTile.Position, unitTile.Unit.CurrentMovement)){ for(Vector2 vector : HexMath.GetVectorsInDistance(unitTile.position, unitTile.unit.CurrentMovement)){
if(tileGroups.containsKey(vector.toString())) if(tileGroups.containsKey(vector.toString()))
tileGroups.get(vector.toString()).setColor(Color.WHITE); tileGroups.get(vector.toString()).setColor(Color.WHITE);
} }
@ -336,25 +335,25 @@ public class WorldScreen extends CameraStageBaseScreen {
TileTable.add(moveUnitButton).colspan(2) TileTable.add(moveUnitButton).colspan(2)
.size(moveUnitButton.getWidth() * buttonScale, moveUnitButton.getHeight() * buttonScale); .size(moveUnitButton.getWidth() * buttonScale, moveUnitButton.getHeight() * buttonScale);
if(selectedTile.Unit.Name.equals("Settler")){ if(selectedTile.unit.Name.equals("Settler")){
TextButton foundCityButton = new TextButton("Found City", skin); TextButton foundCityButton = new TextButton("Found City", skin);
foundCityButton.getLabel().setFontScale(buttonScale); foundCityButton.getLabel().setFontScale(buttonScale);
foundCityButton.addListener(new ClickListener(){ foundCityButton.addListener(new ClickListener(){
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
game.civInfo.addCity(selectedTile.Position); game.civInfo.addCity(selectedTile.position);
selectedTile.Unit = null; // Remove settler! selectedTile.unit = null; // Remove settler!
update(); update();
} }
}); });
if(game.civInfo.tileMap.getTilesInDistance(selectedTile.Position,2).any(new Predicate<TileInfo>() { if(game.civInfo.tileMap.getTilesInDistance(selectedTile.position,2).any(new Predicate<TileInfo>() {
@Override @Override
public boolean evaluate(TileInfo arg0) { public boolean evaluate(TileInfo arg0) {
return arg0.IsCityCenter(); return arg0.isCityCenter();
} }
})){ })){
foundCityButton.setDisabled(true); foundCityButton.setTouchable(Touchable.disabled);
foundCityButton.setColor(Color.GRAY); foundCityButton.setColor(Color.GRAY);
} }
@ -363,9 +362,9 @@ public class WorldScreen extends CameraStageBaseScreen {
.size(foundCityButton.getWidth() * buttonScale, foundCityButton.getHeight() * buttonScale); .size(foundCityButton.getWidth() * buttonScale, foundCityButton.getHeight() * buttonScale);
} }
if(selectedTile.Unit.Name.equals("Worker")) { if(selectedTile.unit.Name.equals("Worker")) {
String improvementButtonText = selectedTile.ImprovementInProgress == null ? String improvementButtonText = selectedTile.improvementInProgress == null ?
"Construct\r\nimprovement" : selectedTile.ImprovementInProgress+"\r\nin progress"; "Construct\r\nimprovement" : selectedTile.improvementInProgress +"\r\nin progress";
TextButton improvementButton = new TextButton(improvementButtonText, skin); TextButton improvementButton = new TextButton(improvementButtonText, skin);
improvementButton.getLabel().setFontScale(buttonScale); improvementButton.getLabel().setFontScale(buttonScale);
improvementButton.addListener(new ClickListener() { improvementButton.addListener(new ClickListener() {
@ -375,11 +374,11 @@ public class WorldScreen extends CameraStageBaseScreen {
dispose(); dispose();
} }
}); });
if(selectedTile.Unit.CurrentMovement==0 || if(selectedTile.unit.CurrentMovement==0 ||
!GameBasics.TileImprovements.linqValues().any(new Predicate<TileImprovement>() { !GameBasics.TileImprovements.linqValues().any(new Predicate<TileImprovement>() {
@Override @Override
public boolean evaluate(TileImprovement arg0) { public boolean evaluate(TileImprovement arg0) {
return selectedTile.CanBuildImprovement(arg0); return selectedTile.canBuildImprovement(arg0);
} }
})){ })){
improvementButton.setColor(Color.GRAY); improvementButton.setColor(Color.GRAY);
@ -414,8 +413,8 @@ public class WorldScreen extends CameraStageBaseScreen {
// tiles adjacent to city tiles // tiles adjacent to city tiles
for(TileInfo tileInfo : game.civInfo.tileMap.values()) for(TileInfo tileInfo : game.civInfo.tileMap.values())
if(game.civInfo.civName.equals(tileInfo.Owner)) if(game.civInfo.civName.equals(tileInfo.owner))
for(Vector2 adjacentLocation : HexMath.GetAdjacentVectors(tileInfo.Position)) for(Vector2 adjacentLocation : HexMath.GetAdjacentVectors(tileInfo.position))
ViewableVectorStrings.add(adjacentLocation.toString()); ViewableVectorStrings.add(adjacentLocation.toString());
// Tiles within 2 tiles of units // Tiles within 2 tiles of units
@ -423,10 +422,10 @@ public class WorldScreen extends CameraStageBaseScreen {
.where(new Predicate<TileInfo>() { .where(new Predicate<TileInfo>() {
@Override @Override
public boolean evaluate(TileInfo arg0) { public boolean evaluate(TileInfo arg0) {
return arg0.Unit!=null; return arg0.unit !=null;
} }
})) }))
for(Vector2 vector : HexMath.GetVectorsInDistance(tile.Position,2)) for(Vector2 vector : HexMath.GetVectorsInDistance(tile.position,2))
ViewableVectorStrings.add(vector.toString()); ViewableVectorStrings.add(vector.toString());
for(String string : ViewableVectorStrings) for(String string : ViewableVectorStrings)
@ -442,7 +441,7 @@ public class WorldScreen extends CameraStageBaseScreen {
TileGroup TG = tileGroups.linqValues().first(new Predicate<WorldTileGroup>() { TileGroup TG = tileGroups.linqValues().first(new Predicate<WorldTileGroup>() {
@Override @Override
public boolean evaluate(WorldTileGroup arg0) { public boolean evaluate(WorldTileGroup arg0) {
return arg0.tileInfo.Position.equals(vector) ; return arg0.tileInfo.position.equals(vector) ;
} }
}); });
float x = TG.getX()-stage.getWidth()/2; float x = TG.getX()-stage.getWidth()/2;

View File

@ -1,13 +1,10 @@
package com.unciv.game; package com.unciv.game;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Container; import com.badlogic.gdx.scenes.scene2d.ui.Container;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.Predicate;
import com.unciv.civinfo.CityInfo; import com.unciv.civinfo.CityInfo;
import com.unciv.civinfo.CivilizationInfo;
import com.unciv.civinfo.TileInfo; import com.unciv.civinfo.TileInfo;
@ -27,11 +24,11 @@ public class WorldTileGroup extends TileGroup {
void update(WorldScreen worldScreen) { void update(WorldScreen worldScreen) {
super.update(); super.update();
if(tileInfo.WorkingCity != null && populationImage==null) addPopulationIcon(); if(tileInfo.workingCity != null && populationImage==null) addPopulationIcon();
if(tileInfo.WorkingCity == null && populationImage!=null) removePopulationIcon(); if(tileInfo.workingCity == null && populationImage!=null) removePopulationIcon();
if (tileInfo.Owner != null && hexagon == null) { if (tileInfo.owner != null && hexagon == null) {
hexagon = ImageGetter.getImageByFilename("TerrainIcons/Hexagon.png"); hexagon = ImageGetter.getImageByFilename("TerrainIcons/Hexagon.png");
float imageScale = terrainImage.getWidth() * 1.3f / hexagon.getWidth(); float imageScale = terrainImage.getWidth() * 1.3f / hexagon.getWidth();
hexagon.setScale(imageScale); hexagon.setScale(imageScale);
@ -42,8 +39,8 @@ public class WorldTileGroup extends TileGroup {
} }
final CityInfo city = tileInfo.GetCity(); final CityInfo city = tileInfo.getCity();
if (tileInfo.IsCityCenter()) { if (tileInfo.isCityCenter()) {
if (cityButton == null) { if (cityButton == null) {
cityButton = new Container<TextButton>(); cityButton = new Container<TextButton>();
cityButton.setActor(new TextButton("", worldScreen.skin)); cityButton.setActor(new TextButton("", worldScreen.skin));
@ -54,7 +51,7 @@ public class WorldTileGroup extends TileGroup {
cityButton.getActor().addListener(new ClickListener() { cityButton.getActor().addListener(new ClickListener() {
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
game.civInfo.CurrentCity = game.civInfo.Cities.indexOf(city); game.civInfo.currentCity = game.civInfo.cities.indexOf(city);
game.setScreen(new CityScreen(game)); game.setScreen(new CityScreen(game));
} }
}); });
@ -63,7 +60,7 @@ public class WorldTileGroup extends TileGroup {
setZIndex(getParent().getChildren().size); setZIndex(getParent().getChildren().size);
} }
String cityButtonText = city.Name+" ("+city.cityPopulation.Population+")" String cityButtonText = city.name +" ("+city.cityPopulation.Population+")"
+ "\r\n" + city.cityBuildings.CurrentBuilding + " in " + "\r\n" + city.cityBuildings.CurrentBuilding + " in "
+ city.cityBuildings.TurnsToBuilding(city.cityBuildings.CurrentBuilding); + city.cityBuildings.TurnsToBuilding(city.cityBuildings.CurrentBuilding);
TextButton button = cityButton.getActor(); TextButton button = cityButton.getActor();

View File

@ -30,7 +30,7 @@ public class BuildingPickerScreen extends PickerScreen {
rightSideButton.addListener(new ClickListener(){ rightSideButton.addListener(new ClickListener(){
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
game.civInfo.GetCurrentCity().cityBuildings.CurrentBuilding = selectedBuilding.Name; game.civInfo.getCurrentCity().cityBuildings.CurrentBuilding = selectedBuilding.Name;
game.setScreen(new CityScreen(game)); game.setScreen(new CityScreen(game));
dispose(); dispose();
} }
@ -38,7 +38,7 @@ public class BuildingPickerScreen extends PickerScreen {
rightSideButton.setTouchable(Touchable.disabled); rightSideButton.setTouchable(Touchable.disabled);
rightSideButton.setColor(Color.GRAY); rightSideButton.setColor(Color.GRAY);
CityBuildings cityBuildings = game.civInfo.GetCurrentCity().cityBuildings; CityBuildings cityBuildings = game.civInfo.getCurrentCity().cityBuildings;
for(final Building building : GameBasics.Buildings.values()) { for(final Building building : GameBasics.Buildings.values()) {
if(!cityBuildings.CanBuild(building)) continue; if(!cityBuildings.CanBuild(building)) continue;
TextButton TB = new TextButton(building.Name+"\r\n"+cityBuildings.TurnsToBuilding(building.Name)+" turns", skin); TextButton TB = new TextButton(building.Name+"\r\n"+cityBuildings.TurnsToBuilding(building.Name)+" turns", skin);

View File

@ -1,15 +1,12 @@
package com.unciv.game.pickerscreens; package com.unciv.game.pickerscreens;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Touchable; import com.badlogic.gdx.scenes.scene2d.Touchable;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.SplitPane;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.unciv.game.CameraStageBaseScreen;
import com.unciv.game.UnCivGame; import com.unciv.game.UnCivGame;
import com.unciv.models.gamebasics.GameBasics; import com.unciv.models.gamebasics.GameBasics;
import com.unciv.models.gamebasics.TileImprovement; import com.unciv.models.gamebasics.TileImprovement;
@ -25,7 +22,7 @@ public class ImprovementPickerScreen extends PickerScreen {
rightSideButton.addListener(new ClickListener(){ rightSideButton.addListener(new ClickListener(){
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
tileInfo.StartWorkingOnImprovement(SelectedImprovement); tileInfo.startWorkingOnImprovement(SelectedImprovement);
game.setWorldScreen(); game.setWorldScreen();
dispose(); dispose();
} }
@ -34,8 +31,10 @@ public class ImprovementPickerScreen extends PickerScreen {
rightSideButton.setTouchable(Touchable.disabled); rightSideButton.setTouchable(Touchable.disabled);
rightSideButton.setColor(Color.GRAY); rightSideButton.setColor(Color.GRAY);
VerticalGroup regularImprovements = new VerticalGroup();
regularImprovements.space(10);
for(final TileImprovement improvement : GameBasics.TileImprovements.values()) { for(final TileImprovement improvement : GameBasics.TileImprovements.values()) {
if(!tileInfo.CanBuildImprovement(improvement) || improvement.Name.equals(tileInfo.Improvement)) continue; if(!tileInfo.canBuildImprovement(improvement) || improvement.Name.equals(tileInfo.improvement)) continue;
TextButton TB = new TextButton(improvement.Name+"\r\n"+improvement.TurnsToBuild+" turns", skin); TextButton TB = new TextButton(improvement.Name+"\r\n"+improvement.TurnsToBuild+" turns", skin);
TB.addListener(new ClickListener(){ TB.addListener(new ClickListener(){
@Override @Override
@ -47,8 +46,8 @@ public class ImprovementPickerScreen extends PickerScreen {
descriptionLabel.setText(improvement.GetDescription()); descriptionLabel.setText(improvement.GetDescription());
} }
}); });
topTable.add(TB).pad(10); regularImprovements.addActor(TB);
topTable.row();
} }
topTable.add(regularImprovements);
} }
} }

View File

@ -18,7 +18,7 @@ public class TechPickerScreen extends PickerScreen {
HashMap<String, TextButton> techNameToButton = new HashMap<String, TextButton>(); HashMap<String, TextButton> techNameToButton = new HashMap<String, TextButton>();
Technology SelectedTech; Technology SelectedTech;
com.unciv.civinfo.CivilizationTech civTech = game.civInfo.Tech; com.unciv.civinfo.CivilizationTech civTech = game.civInfo.tech;
ArrayList<String> TechsToResearch = new ArrayList<String>(civTech.TechsToResearch); ArrayList<String> TechsToResearch = new ArrayList<String>(civTech.TechsToResearch);
public void SetButtonsInfo() { public void SetButtonsInfo() {
@ -48,7 +48,7 @@ public class TechPickerScreen extends PickerScreen {
TB.setText(TB.getText() + " (" + TechsToResearch.indexOf(techName) + ")"); TB.setText(TB.getText() + " (" + TechsToResearch.indexOf(techName) + ")");
} }
if(!civTech.IsResearched(techName)) TB.setText(TB.getText() + "\r\n" + game.civInfo.TurnsToTech(techName) + " turns"); if(!civTech.IsResearched(techName)) TB.setText(TB.getText() + "\r\n" + game.civInfo.turnsToTech(techName) + " turns");
} }
} }

View File

@ -6,7 +6,7 @@ import com.unciv.models.stats.NamedStats;
import java.util.Collection; import java.util.Collection;
public class Terrain extends NamedStats implements ICivilopedia { public class Terrain extends NamedStats implements ICivilopedia {
public String Type; // BaseTerrain or TerrainFeature public String Type; // baseTerrain or terrainFeature
/// <summary> /// <summary>
/// For base terrain - comma-delimited 256 RGB values, e.g. "116,88,62" /// For base terrain - comma-delimited 256 RGB values, e.g. "116,88,62"

View File

@ -34,7 +34,7 @@ public class TileImprovement extends NamedStats implements ICivilopedia {
stringBuilder.append("\r\n"+statsString+" for "+ StringUtils.join(", ",statsToResourceNames.get(statsString))); 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(); return stringBuilder.toString();
} }