mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-22 10:54:19 -04:00
Added factories and civ resource management
This commit is contained in:
parent
6a73c3f370
commit
48f56e2e85
@ -84,7 +84,7 @@
|
||||
name:"Stable",
|
||||
description: "Cattle, sheep and horses provide +1 production.",
|
||||
maintainance:1,
|
||||
resourceRequired:true,
|
||||
resourceBoostingBuilding:true,
|
||||
resourceBonusStats:{production:1},
|
||||
requiredTech:"Horseback Riding"
|
||||
},
|
||||
@ -131,7 +131,7 @@
|
||||
name:"Mint",
|
||||
description: "",
|
||||
maintainance:0,
|
||||
resourceRequired:true,
|
||||
resourceBoostingBuilding:true,
|
||||
resourceBonusStats:{gold:2},
|
||||
requiredTech:"Currency"
|
||||
},
|
||||
@ -164,7 +164,7 @@
|
||||
name:"Forge",
|
||||
description: "Iron provides +1 production",
|
||||
maintainance:1,
|
||||
resourceRequired:true,
|
||||
resourceBoostingBuilding:true,
|
||||
resourceBonusStats:{production:1},
|
||||
requiredTech:"Metal Casting"
|
||||
},
|
||||
@ -175,7 +175,7 @@
|
||||
percentStatBonus:{science:33},
|
||||
requiredBuilding:"Library",
|
||||
unique:"JunglesProvideScience",
|
||||
requiredTech:"Metal Casting"
|
||||
requiredTech:"Education"
|
||||
},
|
||||
{
|
||||
name:"Oxford University",
|
||||
@ -288,6 +288,23 @@
|
||||
unique:"FreeGreatArtistAppears",
|
||||
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",
|
||||
row:4,
|
||||
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",
|
||||
row:6,
|
||||
prerequisites:["Scientific Theory","Military Science"],
|
||||
description:"Enables construction of factories and - Todo"
|
||||
description:"Enables construction of factories, boosting production"
|
||||
},
|
||||
{
|
||||
name:"Dynamite",
|
||||
|
@ -21,7 +21,7 @@ android {
|
||||
applicationId "com.unciv.game"
|
||||
minSdkVersion 9
|
||||
targetSdkVersion 25
|
||||
versionCode 8
|
||||
versionCode 9
|
||||
versionName "0.9"
|
||||
}
|
||||
buildTypes {
|
||||
|
@ -86,8 +86,7 @@ public class CityBuildings
|
||||
{
|
||||
CivilizationInfo civInfo = UnCivGame.Current.civInfo;
|
||||
if(isBuilt(building.name)) return false;
|
||||
// if (building.name.equals("Worker") || building.name.equals("Settler")) return false;
|
||||
if(building.resourceRequired) {
|
||||
if(building.resourceBoostingBuilding) {
|
||||
boolean containsResourceWithImprovement = getCity().getTilesInRange()
|
||||
.any(new Predicate<TileInfo>() {
|
||||
@Override
|
||||
@ -117,6 +116,9 @@ public class CityBuildings
|
||||
return arg0.cityBuildings.isBuilt(building.requiredBuildingInAllCities);
|
||||
}
|
||||
}) ) 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;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ 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.LinqHashMap;
|
||||
import com.unciv.models.gamebasics.Building;
|
||||
import com.unciv.models.gamebasics.ResourceType;
|
||||
import com.unciv.models.gamebasics.TileResource;
|
||||
@ -69,15 +70,17 @@ public class CityInfo {
|
||||
civInfo.cities.add(this);
|
||||
}
|
||||
|
||||
ArrayList<String> getLuxuryResources() {
|
||||
LinqCollection<String> LuxuryResources = new LinqCollection<String>();
|
||||
public LinqHashMap<TileResource,Integer> getCityResources(){
|
||||
LinqHashMap<TileResource,Integer> cityResources = new LinqHashMap<TileResource, Integer>();
|
||||
|
||||
for (TileInfo tileInfo : getTilesInRange()) {
|
||||
TileResource resource = tileInfo.getTileResource();
|
||||
if (resource != null && resource.resourceType == ResourceType.Luxury &&
|
||||
(resource.improvement.equals(tileInfo.improvement) || tileInfo.isCityCenter()))
|
||||
LuxuryResources.add(tileInfo.resource);
|
||||
if (resource != null && (resource.improvement.equals(tileInfo.improvement) || tileInfo.isCityCenter())){
|
||||
if(cityResources.containsKey(resource)) cityResources.put(resource,cityResources.get(resource)+1);
|
||||
else cityResources.put(resource,1);
|
||||
}
|
||||
return LuxuryResources.unique();
|
||||
}
|
||||
return cityResources;
|
||||
}
|
||||
|
||||
private int getWorkingPopulation() {
|
||||
|
@ -4,8 +4,11 @@ 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.LinqHashMap;
|
||||
import com.unciv.models.gamebasics.Building;
|
||||
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 java.util.Collection;
|
||||
@ -74,16 +77,30 @@ public class CivilizationInfo {
|
||||
CivStats statsForTurn = new CivStats() {{
|
||||
happiness = baseHappiness;
|
||||
}};
|
||||
HashSet<String> LuxuryResources = new HashSet<String>();
|
||||
for (CityInfo city : cities) {
|
||||
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;
|
||||
}
|
||||
|
||||
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(){
|
||||
return cities.selectMany(new LinqCollection.Func<CityInfo, Collection<? extends String>>() {
|
||||
@Override
|
||||
|
@ -7,36 +7,50 @@ import com.unciv.models.stats.NamedStats;
|
||||
public class Building extends NamedStats implements ICivilopedia {
|
||||
public String description;
|
||||
public String requiredTech;
|
||||
public Technology GetRequiredTech(){return GameBasics.Technologies.get(requiredTech);}
|
||||
|
||||
public Technology GetRequiredTech() {
|
||||
return GameBasics.Technologies.get(requiredTech);
|
||||
}
|
||||
|
||||
public int cost;
|
||||
public int maintainance = 0;
|
||||
public FullStats percentStatBonus = new FullStats();
|
||||
//public Func<CityInfo,FullStats> GetFlatBonusStats;
|
||||
public boolean isWonder = false;
|
||||
public boolean resourceRequired = false;
|
||||
public boolean resourceBoostingBuilding = false;
|
||||
public String requiredBuilding;
|
||||
public String requiredBuildingInAllCities;
|
||||
public String requiredResource;
|
||||
|
||||
// Uniques
|
||||
public String providesFreeBuilding;
|
||||
public int freeTechs;
|
||||
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 String getDescription(){return getDescription(false);}
|
||||
public String getDescription() {
|
||||
return getDescription(false);
|
||||
}
|
||||
|
||||
public String getDescription(boolean forBuildingPickerScreen) {
|
||||
FullStats stats = new FullStats(this);
|
||||
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 (!forBuildingPickerScreen && requiredTech != null) stringBuilder.append("Requires "+requiredTech+" to be researched\r\n");
|
||||
if (!forBuildingPickerScreen && requiredBuilding != null) stringBuilder.append("Requires a "+requiredBuilding+" to be built in this city\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");
|
||||
if (!forBuildingPickerScreen && requiredTech != null)
|
||||
stringBuilder.append("Requires " + requiredTech + " to be researched\r\n");
|
||||
if (!forBuildingPickerScreen && requiredBuilding != null)
|
||||
stringBuilder.append("Requires a " + requiredBuilding + " to be built in this city\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);
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user