mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-23 03:23:17 -04:00
Added factories and civ resource management
This commit is contained in:
parent
6a73c3f370
commit
48f56e2e85
@ -84,7 +84,7 @@
|
|||||||
name:"Stable",
|
name:"Stable",
|
||||||
description: "Cattle, sheep and horses provide +1 production.",
|
description: "Cattle, sheep and horses provide +1 production.",
|
||||||
maintainance:1,
|
maintainance:1,
|
||||||
resourceRequired:true,
|
resourceBoostingBuilding:true,
|
||||||
resourceBonusStats:{production:1},
|
resourceBonusStats:{production:1},
|
||||||
requiredTech:"Horseback Riding"
|
requiredTech:"Horseback Riding"
|
||||||
},
|
},
|
||||||
@ -131,7 +131,7 @@
|
|||||||
name:"Mint",
|
name:"Mint",
|
||||||
description: "",
|
description: "",
|
||||||
maintainance:0,
|
maintainance:0,
|
||||||
resourceRequired:true,
|
resourceBoostingBuilding:true,
|
||||||
resourceBonusStats:{gold:2},
|
resourceBonusStats:{gold:2},
|
||||||
requiredTech:"Currency"
|
requiredTech:"Currency"
|
||||||
},
|
},
|
||||||
@ -164,7 +164,7 @@
|
|||||||
name:"Forge",
|
name:"Forge",
|
||||||
description: "Iron provides +1 production",
|
description: "Iron provides +1 production",
|
||||||
maintainance:1,
|
maintainance:1,
|
||||||
resourceRequired:true,
|
resourceBoostingBuilding:true,
|
||||||
resourceBonusStats:{production:1},
|
resourceBonusStats:{production:1},
|
||||||
requiredTech:"Metal Casting"
|
requiredTech:"Metal Casting"
|
||||||
},
|
},
|
||||||
@ -175,7 +175,7 @@
|
|||||||
percentStatBonus:{science:33},
|
percentStatBonus:{science:33},
|
||||||
requiredBuilding:"Library",
|
requiredBuilding:"Library",
|
||||||
unique:"JunglesProvideScience",
|
unique:"JunglesProvideScience",
|
||||||
requiredTech:"Metal Casting"
|
requiredTech:"Education"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"Oxford University",
|
name:"Oxford University",
|
||||||
@ -288,6 +288,23 @@
|
|||||||
unique:"FreeGreatArtistAppears",
|
unique:"FreeGreatArtistAppears",
|
||||||
requiredTech:"Archaeology"
|
requiredTech:"Archaeology"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name:"Hospital",
|
||||||
|
description: "",
|
||||||
|
food:5,
|
||||||
|
requiredBuilding:"Aqueduct",
|
||||||
|
maintainance:2,
|
||||||
|
requiredTech:"Biology"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name:"Factory",
|
||||||
|
description: "",
|
||||||
|
production:4,
|
||||||
|
requiredBuilding:"Workshop",
|
||||||
|
maintainance:3,
|
||||||
|
requiredResource:"Coal",
|
||||||
|
requiredTech:"Steam Power"
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
]
|
]
|
@ -318,13 +318,13 @@
|
|||||||
name:"Biology",
|
name:"Biology",
|
||||||
row:4,
|
row:4,
|
||||||
prerequisites:["Archaeology","Scientific Theory"],
|
prerequisites:["Archaeology","Scientific Theory"],
|
||||||
description:"Reveals oil and allows construction of oil wells - Todo"
|
description:"Reveals oil and allows construction of oil wells, and construction of hospitals, which provide a large amount of food"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"Steam Power",
|
name:"Steam Power",
|
||||||
row:6,
|
row:6,
|
||||||
prerequisites:["Scientific Theory","Military Science"],
|
prerequisites:["Scientific Theory","Military Science"],
|
||||||
description:"Enables construction of factories and - Todo"
|
description:"Enables construction of factories, boosting production"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"Dynamite",
|
name:"Dynamite",
|
||||||
|
@ -21,7 +21,7 @@ android {
|
|||||||
applicationId "com.unciv.game"
|
applicationId "com.unciv.game"
|
||||||
minSdkVersion 9
|
minSdkVersion 9
|
||||||
targetSdkVersion 25
|
targetSdkVersion 25
|
||||||
versionCode 8
|
versionCode 9
|
||||||
versionName "0.9"
|
versionName "0.9"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
@ -86,8 +86,7 @@ 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.resourceBoostingBuilding) {
|
||||||
if(building.resourceRequired) {
|
|
||||||
boolean containsResourceWithImprovement = getCity().getTilesInRange()
|
boolean containsResourceWithImprovement = getCity().getTilesInRange()
|
||||||
.any(new Predicate<TileInfo>() {
|
.any(new Predicate<TileInfo>() {
|
||||||
@Override
|
@Override
|
||||||
@ -117,6 +116,9 @@ public class CityBuildings
|
|||||||
return arg0.cityBuildings.isBuilt(building.requiredBuildingInAllCities);
|
return arg0.cityBuildings.isBuilt(building.requiredBuildingInAllCities);
|
||||||
}
|
}
|
||||||
}) ) return false;
|
}) ) return false;
|
||||||
|
if(building.requiredResource!=null &&
|
||||||
|
!civInfo.getCivResources().keySet().contains(GameBasics.TileResources.get(building.requiredResource)))
|
||||||
|
return false; // Only checks if exists, doesn't check amount - todo
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import com.badlogic.gdx.math.Vector2;
|
|||||||
import com.badlogic.gdx.utils.Predicate;
|
import com.badlogic.gdx.utils.Predicate;
|
||||||
import com.unciv.game.UnCivGame;
|
import com.unciv.game.UnCivGame;
|
||||||
import com.unciv.models.LinqCollection;
|
import com.unciv.models.LinqCollection;
|
||||||
|
import com.unciv.models.LinqHashMap;
|
||||||
import com.unciv.models.gamebasics.Building;
|
import com.unciv.models.gamebasics.Building;
|
||||||
import com.unciv.models.gamebasics.ResourceType;
|
import com.unciv.models.gamebasics.ResourceType;
|
||||||
import com.unciv.models.gamebasics.TileResource;
|
import com.unciv.models.gamebasics.TileResource;
|
||||||
@ -69,15 +70,17 @@ public class CityInfo {
|
|||||||
civInfo.cities.add(this);
|
civInfo.cities.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<String> getLuxuryResources() {
|
public LinqHashMap<TileResource,Integer> getCityResources(){
|
||||||
LinqCollection<String> LuxuryResources = new LinqCollection<String>();
|
LinqHashMap<TileResource,Integer> cityResources = new LinqHashMap<TileResource, Integer>();
|
||||||
|
|
||||||
for (TileInfo tileInfo : getTilesInRange()) {
|
for (TileInfo tileInfo : getTilesInRange()) {
|
||||||
TileResource resource = tileInfo.getTileResource();
|
TileResource resource = tileInfo.getTileResource();
|
||||||
if (resource != null && resource.resourceType == ResourceType.Luxury &&
|
if (resource != null && (resource.improvement.equals(tileInfo.improvement) || tileInfo.isCityCenter())){
|
||||||
(resource.improvement.equals(tileInfo.improvement) || tileInfo.isCityCenter()))
|
if(cityResources.containsKey(resource)) cityResources.put(resource,cityResources.get(resource)+1);
|
||||||
LuxuryResources.add(tileInfo.resource);
|
else cityResources.put(resource,1);
|
||||||
}
|
}
|
||||||
return LuxuryResources.unique();
|
}
|
||||||
|
return cityResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getWorkingPopulation() {
|
private int getWorkingPopulation() {
|
||||||
|
@ -4,8 +4,11 @@ import com.badlogic.gdx.math.Vector2;
|
|||||||
import com.badlogic.gdx.utils.Predicate;
|
import com.badlogic.gdx.utils.Predicate;
|
||||||
import com.unciv.game.UnCivGame;
|
import com.unciv.game.UnCivGame;
|
||||||
import com.unciv.models.LinqCollection;
|
import com.unciv.models.LinqCollection;
|
||||||
|
import com.unciv.models.LinqHashMap;
|
||||||
import com.unciv.models.gamebasics.Building;
|
import com.unciv.models.gamebasics.Building;
|
||||||
import com.unciv.models.gamebasics.GameBasics;
|
import com.unciv.models.gamebasics.GameBasics;
|
||||||
|
import com.unciv.models.gamebasics.ResourceType;
|
||||||
|
import com.unciv.models.gamebasics.TileResource;
|
||||||
import com.unciv.models.stats.CivStats;
|
import com.unciv.models.stats.CivStats;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -74,16 +77,30 @@ public class CivilizationInfo {
|
|||||||
CivStats statsForTurn = new CivStats() {{
|
CivStats statsForTurn = new CivStats() {{
|
||||||
happiness = baseHappiness;
|
happiness = baseHappiness;
|
||||||
}};
|
}};
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
statsForTurn.happiness += LuxuryResources.size() * 5; // 5 happiness for each unique luxury in civ
|
statsForTurn.happiness += new LinqCollection<TileResource>(getCivResources().keySet()).count(new Predicate<TileResource>() {
|
||||||
|
@Override
|
||||||
|
public boolean evaluate(TileResource arg0) {
|
||||||
|
return arg0.resourceType == ResourceType.Luxury;
|
||||||
|
}
|
||||||
|
}) * 5; // 5 happiness for each unique luxury in civ
|
||||||
|
|
||||||
return statsForTurn;
|
return statsForTurn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LinqHashMap<TileResource,Integer> getCivResources(){
|
||||||
|
LinqHashMap<TileResource,Integer> civResources = new LinqHashMap<TileResource, Integer>();
|
||||||
|
for (CityInfo city : cities) {
|
||||||
|
for(TileResource resource : city.getCityResources().keySet()){
|
||||||
|
if(civResources.containsKey(resource)) civResources.put(resource,civResources.get(resource)+1);
|
||||||
|
else civResources.put(resource,1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return civResources;
|
||||||
|
}
|
||||||
|
|
||||||
public LinqCollection<String> getBuildingUniques(){
|
public LinqCollection<String> getBuildingUniques(){
|
||||||
return cities.selectMany(new LinqCollection.Func<CityInfo, Collection<? extends String>>() {
|
return cities.selectMany(new LinqCollection.Func<CityInfo, Collection<? extends String>>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -7,36 +7,50 @@ import com.unciv.models.stats.NamedStats;
|
|||||||
public class Building extends NamedStats implements ICivilopedia {
|
public class Building extends NamedStats implements ICivilopedia {
|
||||||
public String description;
|
public String description;
|
||||||
public String requiredTech;
|
public String requiredTech;
|
||||||
public Technology GetRequiredTech(){return GameBasics.Technologies.get(requiredTech);}
|
|
||||||
|
public Technology GetRequiredTech() {
|
||||||
|
return GameBasics.Technologies.get(requiredTech);
|
||||||
|
}
|
||||||
|
|
||||||
public int cost;
|
public int cost;
|
||||||
public int maintainance = 0;
|
public int maintainance = 0;
|
||||||
public FullStats percentStatBonus = new FullStats();
|
public FullStats percentStatBonus = new FullStats();
|
||||||
//public Func<CityInfo,FullStats> GetFlatBonusStats;
|
//public Func<CityInfo,FullStats> GetFlatBonusStats;
|
||||||
public boolean isWonder = false;
|
public boolean isWonder = false;
|
||||||
public boolean resourceRequired = false;
|
public boolean resourceBoostingBuilding = false;
|
||||||
public String requiredBuilding;
|
public String requiredBuilding;
|
||||||
public String requiredBuildingInAllCities;
|
public String requiredBuildingInAllCities;
|
||||||
|
public String requiredResource;
|
||||||
|
|
||||||
// Uniques
|
// Uniques
|
||||||
public String providesFreeBuilding;
|
public String providesFreeBuilding;
|
||||||
public int freeTechs;
|
public int freeTechs;
|
||||||
public String unique; // for wonders which have individual functions that are totally unique
|
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 */
|
/**
|
||||||
|
* The bonus stats that a resource gets when this building is built
|
||||||
|
*/
|
||||||
public FullStats resourceBonusStats;
|
public FullStats resourceBonusStats;
|
||||||
|
|
||||||
public String getDescription(){return getDescription(false);}
|
public String getDescription() {
|
||||||
|
return getDescription(false);
|
||||||
|
}
|
||||||
|
|
||||||
public String getDescription(boolean forBuildingPickerScreen) {
|
public String getDescription(boolean forBuildingPickerScreen) {
|
||||||
FullStats stats = new FullStats(this);
|
FullStats stats = new FullStats(this);
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
if (!forBuildingPickerScreen) stringBuilder.append("Cost: "+cost+"\r\n");
|
if (!forBuildingPickerScreen) stringBuilder.append("Cost: " + cost + "\r\n");
|
||||||
if (isWonder) stringBuilder.append("Wonder\r\n");
|
if (isWonder) stringBuilder.append("Wonder\r\n");
|
||||||
if (!forBuildingPickerScreen && requiredTech != null) stringBuilder.append("Requires "+requiredTech+" to be researched\r\n");
|
if (!forBuildingPickerScreen && requiredTech != null)
|
||||||
if (!forBuildingPickerScreen && requiredBuilding != null) stringBuilder.append("Requires a "+requiredBuilding+" to be built in this city\r\n");
|
stringBuilder.append("Requires " + requiredTech + " to be researched\r\n");
|
||||||
if (!forBuildingPickerScreen && requiredBuildingInAllCities != null) stringBuilder.append("Requires a "+requiredBuildingInAllCities+" to be built in all cities\r\n");
|
if (!forBuildingPickerScreen && requiredBuilding != null)
|
||||||
if(providesFreeBuilding!=null) stringBuilder.append("Provides a free "+providesFreeBuilding+" in this city\r\n");
|
stringBuilder.append("Requires a " + requiredBuilding + " to be built in this city\r\n");
|
||||||
if(maintainance!=0) stringBuilder.append("Maintainance cost: "+maintainance+" gold\r\n");
|
if (!forBuildingPickerScreen && 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);
|
stringBuilder.append(description + "\r\n" + stats);
|
||||||
return stringBuilder.toString();
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user