Converted all GameBasics to Kotlin

This commit is contained in:
Yair Morgenstern 2018-02-24 22:43:41 +02:00
parent 49c0707be1
commit 18be9e37b2
38 changed files with 577 additions and 655 deletions

View file

@ -2,7 +2,7 @@
{
name:"Palace",
description: "Indicates that this city is the capital",
baseDescription: "Indicates that this city is the capital",
isWonder:true,
production:3,
science:3,
@ -12,35 +12,35 @@
},
{
name:"Monument",
description: "Produces culture, enabling border growth",
baseDescription: "Produces culture, enabling border growth",
culture:2,
cost:40,
hurryCostModifier:40,
maintainance:1
maintenance:1
},
{
name:"Granary",
description: "",
baseDescription: "",
food:2,
resourceBonusStats:{food:1},
maintainance:1,
maintenance:1,
hurryCostModifier:25,
requiredTech:"Pottery"
},
{
name:"Stone Works",
description: "",
baseDescription: "",
happiness:1,
production:1
requiredNearbyImprovedResources:["Marble","Stone"]
resourceBonusStats:{production:1},
maintainance:1,
maintenance:1,
hurryCostModifier:25,
requiredTech:"Calendar"
},
{
name:"Stonehenge",
description: "",
baseDescription: "",
culture:6,
isWonder:true,
greatPersonPoints:{production:1},
@ -48,7 +48,7 @@
},
{
name:"The Great Library",
description: "Provides a free technology, and a library in the city it is built in",
baseDescription: "Provides a free technology, and a library in the city it is built in",
science:3,
culture:1,
greatPersonPoints:{science:1},
@ -59,15 +59,15 @@
},
{
name:"Library",
description: "Adds 1 science for each 2 population in the city.",
baseDescription: "Adds 1 science for each 2 population in the city.",
hurryCostModifier:25,
maintainance:1,
maintenance:1,
unique:"SciencePer2Pop",
requiredTech:"Writing"
},
{
name:"Circus",
description: "",
baseDescription: "",
requiredNearbyImprovedResources:["Ivory","Horses"]
happiness:2,
hurryCostModifier:25,
@ -75,7 +75,7 @@
},
{
name:"The Pyramids",
description: "Worker construction increased 25%, provides 2 free workers",
baseDescription: "Worker construction increased 25%, provides 2 free workers",
culture:1,
greatPersonPoints:{production:1},
isWonder:true,
@ -84,17 +84,17 @@
},
{
name:"Temple",
description: "",
baseDescription: "",
culture:3,
specialistSlots:{culture:1},
requiredBuilding:"Monument",
maintainance:2,
maintenance:2,
hurryCostModifier:25,
requiredTech:"Philosophy"
},
{
name:"The Oracle",
description: "Provides a free social policy",
baseDescription: "Provides a free social policy",
culture:3,
greatPersonPoints:{science:1},
isWonder:true,
@ -103,7 +103,7 @@
},
{
name:"National College",
description: "",
baseDescription: "",
science:3,
culture:1,
isWonder:true,
@ -113,7 +113,7 @@
},
{
name:"Chichen Itza",
description: "Length of golden ages increased +50%",
baseDescription: "Length of golden ages increased +50%",
culture:1,
greatPersonPoints:{production:1},
isWonder:true,
@ -122,8 +122,8 @@
},
{
name:"Stable",
description: "",
maintainance:1,
baseDescription: "",
maintenance:1,
requiredNearbyImprovedResources:["Horses","Sheep","Cattle"]
resourceBonusStats:{production:1},
hurryCostModifier:25,
@ -131,7 +131,7 @@
},
{
name:"Circus Maximus",
description: "",
baseDescription: "",
happiness:5,
culture:1,
isWonder:true,
@ -140,7 +140,7 @@
},
{
name:"Hanging Gardens",
description: "",
baseDescription: "",
greatPersonPoints:{culture:1},
food:10,
culture:1,
@ -149,15 +149,15 @@
},
{
name:"Colloseum",
description: "",
maintainance:1,
baseDescription: "",
maintenance:1,
happiness:2,
hurryCostModifier:25,
requiredTech:"Construction"
},
{
name:"Market",
description: "",
baseDescription: "",
gold:2,
specialistSlots:{gold:1},
hurryCostModifier:25,
@ -166,8 +166,8 @@
},
{
name:"Monastery",
description: "",
maintainance:0,
baseDescription: "",
maintenance:0,
requiredNearbyImprovedResources:["Wine","Incense"],
resourceBonusStats:{culture:2},
hurryCostModifier:25,
@ -175,7 +175,7 @@
},
{
name:"Notre Dame",
description: "",
baseDescription: "",
culture:1,
happiness:10,
greatPersonPoints:{gold:1},
@ -184,7 +184,7 @@
},
{
name:"Hagia Sophia",
description: "+33% great person generation in all cities",
baseDescription: "+33% great person generation in all cities",
culture:1,
greatPersonPoints:{culture:1},
isWonder:true,
@ -193,8 +193,8 @@
},
{
name:"Mint",
description: "",
maintainance:0,
baseDescription: "",
maintenance:0,
requiredNearbyImprovedResources:["Gold","Silver"],
resourceBonusStats:{gold:2},
hurryCostModifier:25,
@ -202,7 +202,7 @@
},
{
name:"Machu Pichu",
description: "Gold from all trade routes +25%",
baseDescription: "Gold from all trade routes +25%",
gold:5,
greatPersonPoints:{gold:1},
culture:1,
@ -212,16 +212,16 @@
},
{
name:"Aqueduct",
description: "40% of food is carried over after a new citizen is born",
maintainance:1,
baseDescription: "40% of food is carried over after a new citizen is born",
maintenance:1,
hurryCostModifier:25,
unique:"FoodCarriesOver"
requiredTech:"Engineering"
},
{
name:"Workshop",
description: "",
maintainance:2,
baseDescription: "",
maintenance:2,
production:2,
specialistSlots:{production:1},
hurryCostModifier:25,
@ -230,8 +230,8 @@
},
{
name:"Forge",
description: "",
maintainance:1,
baseDescription: "",
maintenance:1,
hurryCostModifier:25,
requiredNearbyImprovedResources:["Iron"],
resourceBonusStats:{production:1},
@ -239,8 +239,8 @@
},
{
name:"University",
description: "Jungles provide +2 science",
maintainance:2,
baseDescription: "Jungles provide +2 science",
maintenance:2,
hurryCostModifier:15,
percentStatBonus:{science:33},
specialistSlots:{science:2},
@ -250,7 +250,7 @@
},
{
name:"Oxford University",
description: "+50% science from this city",
baseDescription: "+50% science from this city",
science:3,
culture:1,
freeTechs:1,
@ -261,7 +261,7 @@
},
{
name:"Angkor Wat",
description: "Cost of aquiring new tiles reduced by 25%",
baseDescription: "Cost of aquiring new tiles reduced by 25%",
culture:1,
greatPersonPoints:{production:1},
isWonder:true,
@ -270,7 +270,7 @@
},
{
name:"Porcelain Tower",
description: "A free great scientist appears, production to science conversion in cities increased by 33%",
baseDescription: "A free great scientist appears, production to science conversion in cities increased by 33%",
culture:1,
greatPersonPoints:{science:2},
isWonder:true,
@ -279,7 +279,7 @@
},
{
name:"Ironworks",
description: "",
baseDescription: "",
production:8,
culture:1,
isWonder:true,
@ -288,8 +288,8 @@
},
{
name:"Observatory",
description: "City must be bordering a mountain",
maintainance:2,
baseDescription: "City must be bordering a mountain",
maintenance:2,
hurryCostModifier:25,
percentStatBonus:{science:50},
requiredBuilding:"Library",
@ -297,17 +297,17 @@
},
{
name:"Opera House",
description: "",
baseDescription: "",
culture:4,
specialistSlots:{culture:1},
hurryCostModifier:10,
requiredBuilding:"Temple",
maintainance:2,
maintenance:2,
requiredTech:"Acoustics"
},
{
name:"Sistine Chapel",
description: "Culture in all cities increased by 25%",
baseDescription: "Culture in all cities increased by 25%",
culture:1,
isWonder:true,
unique:"CultureIncrease",
@ -315,7 +315,7 @@
},
{
name:"Bank",
description: "",
baseDescription: "",
gold:2,
specialistSlots:{gold:1},
hurryCostModifier:15,
@ -325,7 +325,7 @@
},
{
name:"Forbidden Palace",
description: "Unhappiness from population decreased by 10%",
baseDescription: "Unhappiness from population decreased by 10%",
culture:1,
isWonder:true,
unique:"CitizenUnhappinessDecreased",
@ -333,16 +333,16 @@
},
{
name:"Theatre",
description: "",
baseDescription: "",
happiness:3,
hurryCostModifier:10,
maintainance:2,
maintenance:2,
requiredBuilding:"Colloseum",
requiredTech:"Printing Press"
},
{
name:"Taj Mahal",
description: "Empire enters a golden age",
baseDescription: "Empire enters a golden age",
culture:1,
happiness:4,
isWonder:true,
@ -351,27 +351,27 @@
},
{
name:"Windmill",
description: "",
baseDescription: "",
production:2,
specialistSlots:{production:1},
hurryCostModifier:25,
maintainance:2,
maintenance:2,
percentStatBonus:{production:10},
requiredTech:"Economics"
},
{
name:"Museum",
description: "",
baseDescription: "",
culture:5,
specialistSlots:{culture:1},
requiredBuilding:"Opera House",
maintainance:3,
maintenance:3,
hurryCostModifier:0,
requiredTech:"Archaeology"
},
{
name:"Hermitage",
description: "",
baseDescription: "",
percentStatBonus:{culture:50},
culture:5,
isWonder:true,
@ -380,7 +380,7 @@
},
{
name:"The Louvre",
description: "A Free Great Artist appears near the city",
baseDescription: "A Free Great Artist appears near the city",
culture:1,
happiness:4,
isWonder:true,
@ -389,39 +389,39 @@
},
{
name:"Public School",
description: "+1 science per 2 population",
baseDescription: "+1 science per 2 population",
science:3,
specialistSlots:{science:1},
requiredBuilding:"University",
maintainance:3,
maintenance:3,
hurryCostModifier:0,
unique:"SciencePer2Pop",
requiredTech:"Scientific Theory"
},
{
name:"Hospital",
description: "",
baseDescription: "",
food:5,
requiredBuilding:"Aqueduct",
maintainance:2,
maintenance:2,
hurryCostModifier:0,
requiredTech:"Biology"
},
{
name:"Factory",
description: "",
baseDescription: "",
production:4,
percentStatBonus:{production:10},
specialistSlots:{production:1},
requiredBuilding:"Workshop",
maintainance:3,
maintenance:3,
hurryCostModifier:0,
requiredResource:"Coal",
requiredTech:"Steam Power"
},
{
name:"Stock Exchange",
description: "",
baseDescription: "",
gold:3,
percentStatBonus:{gold:25},
specialistSlots:{gold:2},
@ -431,7 +431,7 @@
},
{
name:"Cristo Redentor",
description: "Culture cost of adopting new Policies reduced by 10%",
baseDescription: "Culture cost of adopting new Policies reduced by 10%",
culture:5,
isWonder:true,
unique:"PolicyCostReduction",
@ -439,16 +439,16 @@
},
{
name:"Broadcast Tower",
description: "",
baseDescription: "",
culture:3,
percentStatBonus:{culture:33},
requiredBuilding:"Museum",
maintainance:3,
maintenance:3,
requiredTech:"Radio"
},
{
name:"Eiffel Tower",
description: "Provides 1 happiness per social policy",
baseDescription: "Provides 1 happiness per social policy",
culture:1,
happiness:5
isWonder:true,
@ -457,50 +457,50 @@
},
{
name:"Medical Lab",
description: "25% of food carried over after a new citizen is born",
baseDescription: "25% of food carried over after a new citizen is born",
requiredBuilding:"Hospital",
maintainance:3,
maintenance:3,
requiredTech:"Pharmaceuticals"
},
{
name:"Research Lab",
description: "",
baseDescription: "",
science:4,
percentStatBonus:{science:50},
specialistSlots:{science:1},
requiredBuilding:"Public School",
maintainance:3,
maintenance:3,
requiredTech:"Plastics"
},
{
name:"Hydro Plant",
description: "Provides +1 production to tiles near rivers",
maintainance:3,
baseDescription: "Provides +1 production to tiles near rivers",
maintenance:3,
requiredResource:"Aluminum",
requiredTech:"Plastics"
},
{
name:"Stadium",
description: "",
baseDescription: "",
happiness:4,
requiredBuilding:"Theatre",
maintainance:2,
maintenance:2,
requiredTech:"Mass Media"
},
{
name:"Solar Plant",
description: "Can only be built in cities next to deserts; cannot be built in a city with a Nuclear Plant",
baseDescription: "Can only be built in cities next to deserts; cannot be built in a city with a Nuclear Plant",
production:5,
percentStatBonus:{production:15},
requiredBuilding:"Factory",
maintainance:3,
maintenance:3,
cannotBeBuiltWith:"Nuclear Plant",
requiredTech:"Ecology",
unique:"MustBeNextToDesert"
},
{
name:"Apollo Program",
description: "Allows the building of spaceship parts",
baseDescription: "Allows the building of spaceship parts",
cost:1500,
isWonder:true,
unique:"ApolloProgram",
@ -508,18 +508,18 @@
},
{
name:"Nuclear Plant",
description: "Can only be built in cities next to deserts; cannot be built in a city with a Nuclear Plant",
baseDescription: "Can only be built in cities next to deserts; cannot be built in a city with a Nuclear Plant",
production:5,
percentStatBonus:{production:15},
requiredBuilding:"Factory",
maintainance:3,
maintenance:3,
cannotBeBuiltWith:"Solar Plant",
requiredResource:"Uranium",
requiredTech:"Nuclear Fission"
},
{
name:"Spaceship Factory",
description: "Increases production of spaceship parts by 50%",
baseDescription: "Increases production of spaceship parts by 50%",
production:3,
requiredResource:"Aluminum",
cost:360,
@ -528,28 +528,28 @@
},
{
name:"SS Booster",
description: "Spaceship part",
baseDescription: "Spaceship part",
requiredResource:"Aluminum",
requiredTech:"Robotics",
unique:"SpaceshipPart"
},
{
name:"SS Cockpit",
description: "Spaceship part",
baseDescription: "Spaceship part",
requiredResource:"Aluminum",
requiredTech:"Satellites",
unique:"SpaceshipPart"
},
{
name:"SS Engine",
description: "Spaceship part",
baseDescription: "Spaceship part",
requiredResource:"Aluminum",
requiredTech:"Particle Physics",
unique:"SpaceshipPart"
},
{
name:"SS Statis Chamber",
description: "Spaceship part",
baseDescription: "Spaceship part",
requiredResource:"Aluminum",
requiredTech:"Nanotechnology",
unique:"SpaceshipPart"

View file

@ -4,44 +4,38 @@
name:"Grassland",
type:"BaseTerrain",
food:2,
movementCost:1,
rgb:"0,255,0"
movementCost:1
},
{
name:"Plains",
type:"BaseTerrain",
food:1,
production:1,
movementCost:1,
rgb:"240,180,135"
movementCost:1
},
{
name:"Tundra",
type:"BaseTerrain",
food:1,
movementCost:1,
rgb:"130,137,121"
movementCost:1
},
{
name:"Desert",
type:"BaseTerrain",
movementCost:1,
rgb:"237,201,175"
movementCost:1
},
{
name:"Lakes",
type:"BaseTerrain",
food:1,
gold:1,
rgb:"104,120,201",
gold:1
canHaveOverlay:false
},
{
name:"Hill",
type:"BaseTerrain",
production:2,
movementCost:2,
rgb:"116,88,62"
movementCost:2
},
// Terrain features

View file

@ -87,6 +87,7 @@ public class CityConstructions
});
if (currentConstruction == null) currentConstruction = Worker;
GameBasics.TileImprovements.keySet().contains("fds");
cityInfo.civInfo.gameInfo.addNotification("Work has started on "+ currentConstruction,cityInfo.cityLocation);
}
@ -122,7 +123,7 @@ public class CityConstructions
public int getMaintainanceCosts(){
int maintainanceTotal = 0;
for( Building building : getBuiltBuildings()) maintainanceTotal+=building.maintainance;
for( Building building : getBuiltBuildings()) maintainanceTotal+=building.maintenance;
return maintainanceTotal;
}

View file

@ -1,11 +0,0 @@
package com.unciv.logic.city;
import com.unciv.models.linq.Linq;
import com.unciv.models.stats.INamed;
public interface IConstruction extends INamed {
int getProductionCost(Linq<String> adoptedPolicies);
int getGoldCost(Linq<String> adoptedPolicies);
boolean isBuildable(CityConstructions construction);
void postBuildEvent(CityConstructions construction); // Yes I'm hilarious.
}

View file

@ -0,0 +1,11 @@
package com.unciv.logic.city
import com.unciv.models.linq.Linq
import com.unciv.models.stats.INamed
interface IConstruction : INamed {
fun getProductionCost(adoptedPolicies: Linq<String>): Int
fun getGoldCost(adoptedPolicies: Linq<String>): Int
fun isBuildable(construction: CityConstructions): Boolean
fun postBuildEvent(construction: CityConstructions) // Yes I'm hilarious.
}

View file

@ -1,17 +0,0 @@
package com.unciv.models.gamebasics;
import com.unciv.models.stats.INamed;
public class BasicHelp implements ICivilopedia, INamed {
public String description;
public String name;
public String getName() {
return name;
}
@Override
public String getDescription() {
return description;
}
}

View file

@ -0,0 +1,8 @@
package com.unciv.models.gamebasics
import com.unciv.models.stats.INamed
class BasicHelp : ICivilopedia, INamed {
override lateinit var name: String
override val description: String = ""
}

View file

@ -1,230 +0,0 @@
package com.unciv.models.gamebasics;
import com.badlogic.gdx.utils.Predicate;
import com.unciv.logic.city.CityInfo;
import com.unciv.logic.civilization.CivilizationInfo;
import com.unciv.logic.city.CityConstructions;
import com.unciv.logic.city.IConstruction;
import com.unciv.logic.map.TileInfo;
import com.unciv.ui.ScienceVictoryScreen;
import com.unciv.ui.UnCivGame;
import com.unciv.ui.VictoryScreen;
import com.unciv.ui.pickerscreens.PolicyPickerScreen;
import com.unciv.models.linq.Linq;
import com.unciv.models.stats.FullStats;
import com.unciv.models.stats.NamedStats;
public class Building extends NamedStats implements IConstruction, ICivilopedia {
public String description;
public String requiredTech;
public Technology GetRequiredTech() {
return GameBasics.Technologies.get(requiredTech);
}
public int cost;
public int maintainance = 0;
public FullStats percentStatBonus;
public FullStats specialistSlots;
public FullStats greatPersonPoints;
public int hurryCostModifier; // Extra cost percentage when purchasing
public boolean isWonder = false;
public String requiredBuilding;
public String requiredBuildingInAllCities;
public String requiredResource; // A strategic resource that will be consumed by this building
public Linq requiredNearbyImprovedResources; // City can only be built if one of these resources is nearby - it must be improved!
public String cannotBeBuiltWith;
// 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
*/
public FullStats resourceBonusStats;
public FullStats getStats(Linq<String> adoptedPolicies){
FullStats stats = this.clone();
if (adoptedPolicies.contains("Organized Religion") &&
new Linq<String>("Monument","Temple","Monastery").contains(name))
stats.happiness+=1;
if (adoptedPolicies.contains("Free Religion") &&
new Linq<String>("Monument","Temple","Monastery").contains(name))
stats.culture+=1;
if (adoptedPolicies.contains("Entrepreneurship") &&
new Linq<String>("Mint","Market","Bank","Stock Market").contains(name))
stats.science+=1;
if (adoptedPolicies.contains("Humanism") &&
new Linq<String>("University","Observatory","Public School").contains(name))
stats.science+=1;
if (adoptedPolicies.contains("Theocracy") && name.equals("Temple"))
percentStatBonus = new FullStats(){{gold=10;}};
if (adoptedPolicies.contains("Free Thought") && name.equals("University"))
percentStatBonus.science=50;
if (adoptedPolicies.contains("Rationalism Complete") && !isWonder && stats.science>0)
stats.gold+=1;
if (adoptedPolicies.contains("Constitution") && isWonder)
stats.culture+=2;
return stats;
}
public String getDescription() {
return getDescription(false,new Linq<String>());
}
public String getDescription(boolean forBuildingPickerScreen, Linq<String> adoptedPolicies) {
FullStats stats = getStats(adoptedPolicies);
StringBuilder stringBuilder = new StringBuilder();
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(description!=null) stringBuilder.append(description + "\r\n");
if(!stats.toString().equals(""))
stringBuilder.append(stats+"\r\n");
if(this.percentStatBonus!=null){
if(this.percentStatBonus.production!=0) stringBuilder.append("+"+(int)this.percentStatBonus.production+"% production\r\n");
if(this.percentStatBonus.gold!=0) stringBuilder.append("+"+(int)this.percentStatBonus.gold+"% gold\r\n");
if(this.percentStatBonus.science!=0) stringBuilder.append("+"+(int)this.percentStatBonus.science+"% science\r\n");
if(this.percentStatBonus.food!=0) stringBuilder.append("+"+(int)this.percentStatBonus.food+"% food\r\n");
if(this.percentStatBonus.culture!=0) stringBuilder.append("+"+(int)this.percentStatBonus.culture+"% culture\r\n");
}
if(this.greatPersonPoints!=null){
if(this.greatPersonPoints.production!=0) stringBuilder.append("+"+(int)this.greatPersonPoints.production+" Great Engineer points\r\n");
if(this.greatPersonPoints.gold!=0) stringBuilder.append("+"+(int)this.greatPersonPoints.gold+" Great Merchant points\r\n");
if(this.greatPersonPoints.science!=0) stringBuilder.append("+"+(int)this.greatPersonPoints.science+" Great Scientist points\r\n");
if(this.greatPersonPoints.culture!=0) stringBuilder.append("+"+(int)this.greatPersonPoints.culture+" Great Artist points\r\n");
}
if(resourceBonusStats!=null){
String resources = StringUtils.join(",",GameBasics.TileResources.linqValues().where(new Predicate<TileResource>() {
@Override
public boolean evaluate(TileResource arg0) {
return name.equals(arg0.building);
}
}).select(new Linq.Func<TileResource, String>() {
@Override
public String GetBy(TileResource arg0) {
return arg0.name;
}
})) ;
stringBuilder.append(resources+" provide "+resourceBonusStats+" \r\n");
}
if (maintainance != 0)
stringBuilder.append("Maintainance cost: " + maintainance + " gold\r\n");
return stringBuilder.toString();
}
@Override
public int getProductionCost(Linq<String> adoptedPolicies) {
if(!isWonder && culture!=0 && adoptedPolicies.contains("Piety"))
return (int) (cost*0.85);
return cost;
}
public int getGoldCost(Linq<String> adoptedPolicies) {
double cost = Math.pow(30 * getProductionCost(adoptedPolicies),0.75) * (1 + hurryCostModifier/100);
if(adoptedPolicies.contains("Mercantilism")) cost*=0.75;
if(adoptedPolicies.contains("Patronage")) cost*=0.5;
return (int)( cost / 10 ) * 10;
}
public boolean isBuildable(CityConstructions construction){
CivilizationInfo civInfo = construction.cityInfo.civInfo;
if(construction.isBuilt(name)) return false;
if (requiredTech != null && !civInfo.tech.isResearched(requiredTech)) return false;
if (isWonder && civInfo.cities
.any(new Predicate<CityInfo>() {
@Override
public boolean evaluate(CityInfo arg0) {
CityConstructions CB = arg0.cityConstructions;
return CB.isBuilding(name) || CB.isBuilt(name);
}
}) ) return false;
if (requiredBuilding != null && !construction.isBuilt(requiredBuilding)) return false;
if (requiredBuildingInAllCities != null ||
civInfo.cities.any(new Predicate<CityInfo>() {
@Override
public boolean evaluate(CityInfo arg0) {
return arg0.cityConstructions.isBuilt(requiredBuildingInAllCities);
}
}) ) return false;
if(cannotBeBuiltWith != null && construction.isBuilt(cannotBeBuiltWith)) return false;
if("MustBeNextToDesert".equals(unique) &&
!civInfo.gameInfo.tileMap.getTilesInDistance(construction.cityInfo.cityLocation,1).any(new Predicate<TileInfo>() {
@Override
public boolean evaluate(TileInfo arg0) {
return arg0.baseTerrain.equals("Desert");
}
}))
return false;
if(requiredResource!=null &&
!civInfo.getCivResources().keySet().contains(GameBasics.TileResources.get(requiredResource)))
return false; // Only checks if exists, doesn't check amount - todo
if(requiredNearbyImprovedResources!=null) {
boolean containsResourceWithImprovement = construction.cityInfo.getTilesInRange()
.any(new Predicate<TileInfo>() {
@Override
public boolean evaluate(TileInfo tile) {
return tile.resource != null
&& requiredNearbyImprovedResources.contains(tile.resource)
&& tile.getTileResource().improvement.equals(tile.improvement);
}
});
if(!containsResourceWithImprovement) return false;
}
if("SpaceshipPart".equals(unique)){
if(!civInfo.getBuildingUniques().contains("ApolloProgram")) return false;
if(civInfo.scienceVictory.unconstructedParts().get(name) ==0) return false; // Don't need to build any more of these!
}
return true;
}
@Override
public void postBuildEvent(CityConstructions constructions) {
CivilizationInfo civInfo = constructions.cityInfo.civInfo;
if("ApolloProgram".equals(unique)) UnCivGame.Current.setScreen(new ScienceVictoryScreen(civInfo));
if("SpaceshipPart".equals(unique)) {
civInfo.scienceVictory.currentParts.add(name, 1);
UnCivGame.Current.setScreen(new ScienceVictoryScreen(civInfo));
if(civInfo.scienceVictory.unconstructedParts().isEmpty())
UnCivGame.Current.setScreen(new VictoryScreen());
return;
}
constructions.builtBuildings.add(name);
if (providesFreeBuilding != null && !constructions.builtBuildings.contains(providesFreeBuilding))
constructions.builtBuildings.add(providesFreeBuilding);
if (freeTechs != 0) civInfo.tech.freeTechs += freeTechs;
if("EmpireEntersGoldenAge".equals(unique)) civInfo.goldenAges.enterGoldenAge();
if("FreeGreatArtistAppears".equals(unique)) civInfo.addGreatPerson("Great Artist");
if("WorkerConstruction".equals(unique)){
civInfo.placeUnitNearTile(constructions.cityInfo.cityLocation,"Worker");
civInfo.placeUnitNearTile(constructions.cityInfo.cityLocation,"Worker");
}
if("FreeSocialPolicy".equals(unique)){
civInfo.policies.freePolicies++;
UnCivGame.Current.setScreen(new PolicyPickerScreen(civInfo));
}
}
}

View file

@ -0,0 +1,201 @@
package com.unciv.models.gamebasics
import com.unciv.logic.city.CityConstructions
import com.unciv.logic.city.IConstruction
import com.unciv.ui.ScienceVictoryScreen
import com.unciv.ui.UnCivGame
import com.unciv.ui.VictoryScreen
import com.unciv.ui.pickerscreens.PolicyPickerScreen
import com.unciv.models.linq.Linq
import com.unciv.models.stats.FullStats
import com.unciv.models.stats.NamedStats
class Building : NamedStats(), IConstruction, ICivilopedia {
private lateinit var baseDescription: String
override val description: String
get() = getDescription(false, Linq())
@JvmField var requiredTech: String? = null
@JvmField var cost: Int = 0
@JvmField var maintenance = 0
@JvmField var percentStatBonus: FullStats? = null
@JvmField var specialistSlots: FullStats? = null
@JvmField var greatPersonPoints: FullStats? = null
/** Extra cost percentage when purchasing */
@JvmField var hurryCostModifier: Int = 0
@JvmField var isWonder = false
@JvmField var requiredBuilding: String? = null
@JvmField var requiredBuildingInAllCities: String? = null
/** A strategic resource that will be consumed by this building */
@JvmField var requiredResource: String? = null
/** City can only be built if one of these resources is nearby - it must be improved! */
@JvmField var requiredNearbyImprovedResources: Linq<String>? = null
@JvmField var cannotBeBuiltWith: String? = null
// Uniques
@JvmField var providesFreeBuilding: String? = null
@JvmField var freeTechs: Int = 0
@JvmField var unique: String? = null // for wonders which have individual functions that are totally unique
/**
* The bonus stats that a resource gets when this building is built
*/
@JvmField var resourceBonusStats: FullStats? = null
fun getRequiredTech(): Technology {
return GameBasics.Technologies[requiredTech]!!
}
fun getStats(adoptedPolicies: Linq<String>): FullStats {
val stats = this.clone()
if (adoptedPolicies.contains("Organized Religion") && Linq("Monument", "Temple", "Monastery").contains(name))
stats.happiness += 1f
if (adoptedPolicies.contains("Free Religion") && Linq("Monument", "Temple", "Monastery").contains(name))
stats.culture += 1f
if (adoptedPolicies.contains("Entrepreneurship") && Linq("Mint", "Market", "Bank", "Stock Market").contains(name))
stats.science += 1f
if (adoptedPolicies.contains("Humanism") && Linq("University", "Observatory", "Public School").contains(name))
stats.science += 1f
if (adoptedPolicies.contains("Theocracy") && name == "Temple")
percentStatBonus = object : FullStats() {
init {
gold = 10f
}
}
if (adoptedPolicies.contains("Free Thought") && name == "University")
percentStatBonus!!.science = 50f
if (adoptedPolicies.contains("Rationalism Complete") && !isWonder && stats.science > 0)
stats.gold += 1f
if (adoptedPolicies.contains("Constitution") && isWonder)
stats.culture += 2f
return stats
}
fun getDescription(forBuildingPickerScreen: Boolean, adoptedPolicies: Linq<String>): String {
val stats = getStats(adoptedPolicies)
val stringBuilder = StringBuilder()
if (!forBuildingPickerScreen) stringBuilder.appendln("Cost: " + cost)
if (isWonder) stringBuilder.appendln("Wonder")
if (!forBuildingPickerScreen && requiredTech != null)
stringBuilder.appendln("Requires $requiredTech to be researched")
if (!forBuildingPickerScreen && requiredBuilding != null)
stringBuilder.appendln("Requires a $requiredBuilding to be built in this city")
if (!forBuildingPickerScreen && requiredBuildingInAllCities != null)
stringBuilder.appendln("Requires a $requiredBuildingInAllCities to be built in all cities")
if (providesFreeBuilding != null)
stringBuilder.appendln("Provides a free $providesFreeBuilding in this city")
stringBuilder.appendln(baseDescription)
if (stats.toString() != "")
stringBuilder.appendln(stats)
if (this.percentStatBonus != null) {
if (this.percentStatBonus!!.production != 0f) stringBuilder.append("+" + this.percentStatBonus!!.production.toInt() + "% production\r\n")
if (this.percentStatBonus!!.gold != 0f) stringBuilder.append("+" + this.percentStatBonus!!.gold.toInt() + "% gold\r\n")
if (this.percentStatBonus!!.science != 0f) stringBuilder.append("+" + this.percentStatBonus!!.science.toInt() + "% science\r\n")
if (this.percentStatBonus!!.food != 0f) stringBuilder.append("+" + this.percentStatBonus!!.food.toInt() + "% food\r\n")
if (this.percentStatBonus!!.culture != 0f) stringBuilder.append("+" + this.percentStatBonus!!.culture.toInt() + "% culture\r\n")
}
if (this.greatPersonPoints != null) {
val gpp = this.greatPersonPoints!!
if (gpp.production != 0f) stringBuilder.appendln("+" + gpp.production.toInt() + " Great Engineer points")
if (gpp.gold != 0f) stringBuilder.appendln("+" + gpp.gold.toInt() + " Great Merchant points")
if (gpp.science != 0f) stringBuilder.appendln("+" + gpp.science.toInt() + " Great Scientist points")
if (gpp.culture != 0f) stringBuilder.appendln("+" + gpp.culture.toInt() + " Great Artist points")
}
if (resourceBonusStats != null) {
val resources = GameBasics.TileResources.linqValues().where { name == it.building }.select { it.name }.joinToString()
stringBuilder.appendln("$resources provide $resourceBonusStats")
}
if (maintenance != 0)
stringBuilder.appendln("Maintenance cost: $maintenance gold")
return stringBuilder.toString()
}
override fun getProductionCost(adoptedPolicies: Linq<String>): Int {
return if (!isWonder && culture != 0f && adoptedPolicies.contains("Piety")) (cost * 0.85).toInt()
else cost
}
override fun getGoldCost(adoptedPolicies: Linq<String>): Int {
var cost = Math.pow((30 * getProductionCost(adoptedPolicies)).toDouble(), 0.75) * (1 + hurryCostModifier / 100)
if (adoptedPolicies.contains("Mercantilism")) cost *= 0.75
if (adoptedPolicies.contains("Patronage")) cost *= 0.5
return (cost / 10).toInt() * 10
}
override fun isBuildable(construction: CityConstructions): Boolean {
if (construction.isBuilt(name)) return false
val civInfo = construction.cityInfo.civInfo
if (requiredTech != null && !civInfo.tech.isResearched(requiredTech)) return false
if (isWonder && civInfo.cities.any {
it.cityConstructions.isBuilding(name) || it.cityConstructions.isBuilt(name)
})
return false
if (requiredBuilding != null && !construction.isBuilt(requiredBuilding)) return false
if (requiredBuildingInAllCities != null || civInfo.cities.any { it.cityConstructions.isBuilt(requiredBuildingInAllCities) })
return false
if (cannotBeBuiltWith != null && construction.isBuilt(cannotBeBuiltWith)) return false
if ("MustBeNextToDesert" == unique && !civInfo.gameInfo.tileMap.getTilesInDistance(construction.cityInfo.cityLocation, 1).any { it.baseTerrain == "Desert" })
return false
if (requiredResource != null && !civInfo.civResources.containsKey(GameBasics.TileResources[requiredResource]))
return false // Only checks if exists, doesn't check amount - todo
if (requiredNearbyImprovedResources != null) {
val containsResourceWithImprovement = construction.cityInfo.tilesInRange
.any { tile ->
(tile.resource != null
&& requiredNearbyImprovedResources!!.contains(tile.resource)
&& tile.tileResource!!.improvement == tile.improvement)
}
if (!containsResourceWithImprovement) return false
}
if ("SpaceshipPart" == unique) {
if (!civInfo.buildingUniques.contains("ApolloProgram")) return false
if (civInfo.scienceVictory.unconstructedParts()[name] == 0) return false // Don't need to build any more of these!
}
return true
}
override fun postBuildEvent(construction: CityConstructions) {
val civInfo = construction.cityInfo.civInfo
if (unique == "SpaceshipPart") {
civInfo.scienceVictory.currentParts.add(name, 1)
UnCivGame.Current.screen = ScienceVictoryScreen(civInfo)
if (civInfo.scienceVictory.unconstructedParts().isEmpty())
UnCivGame.Current.screen = VictoryScreen()
return
}
construction.builtBuildings.add(name)
if (providesFreeBuilding != null && !construction.builtBuildings.contains(providesFreeBuilding))
construction.builtBuildings.add(providesFreeBuilding)
when (unique) {
"ApolloProgram" -> UnCivGame.Current.screen = ScienceVictoryScreen(civInfo)
"EmpireEntersGoldenAge" -> civInfo.goldenAges.enterGoldenAge()
"FreeGreatArtistAppears" -> civInfo.addGreatPerson("Great Artist")
"WorkerConstruction" -> {
civInfo.placeUnitNearTile(construction.cityInfo.cityLocation, "Worker")
civInfo.placeUnitNearTile(construction.cityInfo.cityLocation, "Worker")
}
"FreeSocialPolicy" -> {
civInfo.policies.freePolicies++
UnCivGame.Current.screen = PolicyPickerScreen(civInfo)
}
}
if (freeTechs != 0) civInfo.tech.freeTechs += freeTechs
}
}

View file

@ -1,16 +0,0 @@
package com.unciv.models.gamebasics;
import com.unciv.models.linq.LinqHashMap;
import java.util.LinkedHashMap;
public class GameBasics{
public static LinqHashMap<String,Building> Buildings;
public static LinqHashMap<String,Terrain> Terrains;
public static LinqHashMap<String,TileResource> TileResources;
public static LinqHashMap<String,TileImprovement> TileImprovements;
public static LinqHashMap<String, Technology> Technologies;
public static LinqHashMap<String, BasicHelp> Helps;
public static LinqHashMap<String,Unit> Units;
public static LinkedHashMap<String,PolicyBranch> PolicyBranches;
}

View file

@ -0,0 +1,16 @@
package com.unciv.models.gamebasics
import com.unciv.models.linq.LinqHashMap
import java.util.LinkedHashMap
object GameBasics {
@JvmField var Buildings: LinqHashMap<String, Building> = LinqHashMap()
@JvmField var Terrains: LinqHashMap<String, Terrain> = LinqHashMap()
@JvmField var TileResources: LinqHashMap<String, TileResource> = LinqHashMap()
@JvmField var TileImprovements: LinqHashMap<String, TileImprovement> = LinqHashMap()
@JvmField var Technologies: LinqHashMap<String, Technology> = LinqHashMap()
@JvmField var Helps: LinqHashMap<String, BasicHelp> = LinqHashMap()
@JvmField var Units: LinqHashMap<String, Unit> = LinqHashMap()
@JvmField var PolicyBranches: LinqHashMap<String, PolicyBranch> = LinqHashMap()
}

View file

@ -1,9 +0,0 @@
package com.unciv.models.gamebasics;
/**
* Created by LENOVO on 10/18/2017.
*/
public interface ICivilopedia {
String getDescription();
}

View file

@ -0,0 +1,6 @@
package com.unciv.models.gamebasics
interface ICivilopedia {
val description: String
}

View file

@ -1,23 +0,0 @@
package com.unciv.models.gamebasics;
import com.unciv.models.linq.Linq;
import com.unciv.models.stats.INamed;
/**
* Created by LENOVO on 12/22/2017.
*/
public class Policy implements INamed{
public String name;
public String description;
public String branch;
public int row;
public int column;
public Linq<String> requires;
@Override
public String getName() {
return name;
}
}

View file

@ -0,0 +1,15 @@
package com.unciv.models.gamebasics
import com.unciv.models.linq.Linq
import com.unciv.models.stats.INamed
open class Policy : INamed {
override lateinit var name: String
@JvmField var description: String? = null
@JvmField var branch: String? = null
@JvmField var row: Int = 0
@JvmField var column: Int = 0
@JvmField var requires: Linq<String>? = null
}

View file

@ -1,7 +0,0 @@
package com.unciv.models.gamebasics;
import com.unciv.models.linq.Linq;
public class PolicyBranch extends Policy{
public Linq<Policy> policies;
}

View file

@ -0,0 +1,7 @@
package com.unciv.models.gamebasics
import com.unciv.models.linq.Linq
class PolicyBranch : Policy() {
@JvmField var policies: Linq<Policy>? = null
}

View file

@ -1,7 +0,0 @@
package com.unciv.models.gamebasics;
public enum ResourceType{
Luxury,
Strategic,
Bonus
}

View file

@ -0,0 +1,7 @@
package com.unciv.models.gamebasics
enum class ResourceType {
Luxury,
Strategic,
Bonus
}

View file

@ -1,13 +0,0 @@
package com.unciv.models.gamebasics;
import java.util.ArrayList;
public class TechColumn {
public int columnNumber;
public String era;
public GameBasics gameBasics;
public ArrayList<Technology> techs = new ArrayList<Technology>();
public int techCost;
public int buildingCost;
public int wonderCost;
}

View file

@ -0,0 +1,12 @@
package com.unciv.models.gamebasics
import java.util.ArrayList
class TechColumn {
@JvmField var columnNumber: Int = 0
@JvmField var era: String? = null
@JvmField var techs = ArrayList<Technology>()
@JvmField var techCost: Int = 0
@JvmField var buildingCost: Int = 0
@JvmField var wonderCost: Int = 0
}

View file

@ -1,15 +0,0 @@
package com.unciv.models.gamebasics;
import java.util.HashSet;
public class Technology
{
public String name;
public String description;
public int cost;
public HashSet<String> prerequisites = new HashSet<String>();
public TechColumn column; // The column that this tech is in the tech tree
public int row;
}

View file

@ -0,0 +1,14 @@
package com.unciv.models.gamebasics
import java.util.HashSet
class Technology {
@JvmField var name: String? = null
@JvmField var description: String? = null
@JvmField var cost: Int = 0
@JvmField var prerequisites = HashSet<String>()
@JvmField var column: TechColumn? = null // The column that this tech is in the tech tree
@JvmField var row: Int = 0
}

View file

@ -1,43 +0,0 @@
package com.unciv.models.gamebasics;
import com.unciv.models.stats.NamedStats;
import java.util.Collection;
public class Terrain extends NamedStats implements ICivilopedia {
public TerrainType type; // BaseTerrain or TerrainFeature
public boolean overrideStats = false;
/***
* If true, other terrain layers can come over this one. For mountains, lakes etc. this is false
*/
public boolean canHaveOverlay = true;
/***
*If true, nothing can be built here - not even resource improvements
*/
public boolean unbuildable = false;
/***
* For terrain features
*/
public Collection<String> occursOn;
/***
*For terrain features - which technology alllows removal of this feature
*/
public String removalTech;
public int movementCost=1;
public String rgb;
@Override
public String getDescription() {
return ""+this.clone();
}
}

View file

@ -0,0 +1,33 @@
package com.unciv.models.gamebasics
import com.unciv.models.stats.NamedStats
class Terrain : NamedStats(), ICivilopedia {
override val description: String
get() = this.clone().toString()
@JvmField var type: TerrainType? = null // BaseTerrain or TerrainFeature
@JvmField var overrideStats = false
/***
* If true, other terrain layers can come over this one. For mountains, lakes etc. this is false
*/
@JvmField var canHaveOverlay = true
/***
* If true, nothing can be built here - not even resource improvements
*/
@JvmField var unbuildable = false
/***
* For terrain features
*/
@JvmField var occursOn: Collection<String>? = null
@JvmField var movementCost = 1
}

View file

@ -1,6 +0,0 @@
package com.unciv.models.gamebasics;
public enum TerrainType{
BaseTerrain,
TerrainFeature
}

View file

@ -0,0 +1,6 @@
package com.unciv.models.gamebasics
enum class TerrainType {
BaseTerrain,
TerrainFeature
}

View file

@ -1,50 +0,0 @@
package com.unciv.models.gamebasics;
import com.unciv.logic.civilization.CivilizationInfo;
import com.unciv.models.stats.FullStats;
import com.unciv.models.stats.NamedStats;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
public class TileImprovement extends NamedStats implements ICivilopedia {
public Collection<String> terrainsCanBeBuiltOn = new ArrayList<String>();
public String techRequired;
public String improvingTech;
public FullStats improvingTechStats;
private int turnsToBuild; // This is the base cost.
public int getTurnsToBuild(CivilizationInfo civInfo){
float realTurnsToBuild = turnsToBuild;
if(civInfo.getBuildingUniques().contains("WorkerConstruction"))
realTurnsToBuild*=0.75;
if(civInfo.policies.isAdopted("Citizenship"))
realTurnsToBuild*=0.75;
return Math.round(realTurnsToBuild);
}
@Override
public String getDescription() {
StringBuilder stringBuilder = new StringBuilder();
if(!this.clone().toString().isEmpty()) stringBuilder.append(this.clone()+"\r\n");
if(!terrainsCanBeBuiltOn.isEmpty()) stringBuilder.append("Can be built on " + StringUtils.join(", ", terrainsCanBeBuiltOn));
HashMap<String,ArrayList<String>> statsToResourceNames = new HashMap<String, ArrayList<String>>();
for(TileResource tr : GameBasics.TileResources.values()){
if(!tr.improvement.equals(name)) continue;
String statsString = tr.improvementStats.toString();
if(!statsToResourceNames.containsKey(statsString))
statsToResourceNames.put(statsString,new ArrayList<String>());
statsToResourceNames.get(statsString).add(tr.name);
}
for(String statsString : statsToResourceNames.keySet()){
stringBuilder.append("\r\n"+statsString+" for "+ StringUtils.join(", ",statsToResourceNames.get(statsString)));
}
if(techRequired !=null) stringBuilder.append("\r\nTech required: "+ techRequired);
return stringBuilder.toString();
}
}

View file

@ -0,0 +1,49 @@
package com.unciv.models.gamebasics
import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.models.stats.FullStats
import com.unciv.models.stats.NamedStats
import java.util.ArrayList
import java.util.HashMap
class TileImprovement : NamedStats(), ICivilopedia {
@JvmField var terrainsCanBeBuiltOn: Collection<String> = ArrayList()
@JvmField var techRequired: String? = null
@JvmField var improvingTech: String? = null
@JvmField var improvingTechStats: FullStats? = null
private val turnsToBuild: Int = 0 // This is the base cost.
fun getTurnsToBuild(civInfo: CivilizationInfo): Int {
var realTurnsToBuild = turnsToBuild.toFloat()
if (civInfo.buildingUniques.contains("WorkerConstruction"))
realTurnsToBuild *= 0.75f
if (civInfo.policies.isAdopted("Citizenship"))
realTurnsToBuild *= 0.75f
return Math.round(realTurnsToBuild)
}
override val description: String
get() {
val stringBuilder = StringBuilder()
if (!this.clone().toString().isEmpty()) stringBuilder.appendln(this.clone().toString())
if (!terrainsCanBeBuiltOn.isEmpty()) stringBuilder.appendln("Can be built on " + terrainsCanBeBuiltOn.joinToString(", "))
val statsToResourceNames = HashMap<String, ArrayList<String>>()
for (tr: TileResource in GameBasics.TileResources.values.filter { it.improvement == name }) {
val statsString = tr.improvementStats.toString()
if (!statsToResourceNames.containsKey(statsString))
statsToResourceNames[statsString] = ArrayList()
statsToResourceNames[statsString]!!.add(tr.name)
}
statsToResourceNames.forEach {
stringBuilder.appendln(it.key + " for " + it.value.joinToString(", "))
}
if (techRequired != null) stringBuilder.appendln("Tech required: " + techRequired)
return stringBuilder.toString()
}
}

View file

@ -1,32 +0,0 @@
package com.unciv.models.gamebasics;
import com.unciv.models.stats.NamedStats;
import com.unciv.models.stats.FullStats;
import java.util.Collection;
public class TileResource extends NamedStats implements ICivilopedia {
public ResourceType resourceType;
public Collection<String> terrainsCanBeFoundOn;
public String improvement;
public FullStats improvementStats;
/// <summary>
/// The building that improves this resource, if any. E.G.: Granary for wheat, Stable for cattle.
/// </summary>
public String building;
public Building GetBuilding(){return building ==null ? null : GameBasics.Buildings.get(building);}
public String revealedBy;
@Override
public String getDescription() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(this.clone()+"\r\n");
stringBuilder.append("Can be found on " + com.unciv.models.gamebasics.StringUtils.join(", ", terrainsCanBeFoundOn));
stringBuilder.append("\r\n\r\nImproved by "+ improvement +"\r\n");
stringBuilder.append("\r\nBonus stats for improvement: "+ improvementStats +"\r\n");
return stringBuilder.toString();
}
}

View file

@ -0,0 +1,34 @@
package com.unciv.models.gamebasics
import com.unciv.models.linq.Linq
import com.unciv.models.stats.NamedStats
import com.unciv.models.stats.FullStats
class TileResource : NamedStats(), ICivilopedia {
override val description: String
get(){
val stringBuilder = StringBuilder()
stringBuilder.appendln(this.clone().toString())
stringBuilder.appendln("Can be found on " + terrainsCanBeFoundOn.joinToString())
stringBuilder.appendln()
stringBuilder.appendln("Improved by " + improvement)
stringBuilder.appendln("Bonus stats for improvement: " + improvementStats)
return stringBuilder.toString()
}
@JvmField var resourceType: ResourceType = ResourceType.Bonus
@JvmField var terrainsCanBeFoundOn: Linq<String> = Linq()
@JvmField var improvement: String? = null
@JvmField var improvementStats: FullStats? = null
/**
* The building that improves this resource, if any. E.G.: Granary for wheat, Stable for cattle.
*/
@JvmField var building: String? = null
@JvmField var revealedBy: String? = null
fun GetBuilding(): Building? {
return if (building == null) null else GameBasics.Buildings[building]
}
}

View file

@ -1,55 +0,0 @@
package com.unciv.models.gamebasics;
import com.unciv.logic.city.IConstruction;
import com.unciv.logic.city.CityConstructions;
import com.unciv.logic.map.MapUnit;
import com.unciv.models.linq.Linq;
import com.unciv.models.stats.INamed;
public class Unit implements INamed, IConstruction {
public String name;
public String description;
public int cost;
public int hurryCostModifier;
public int movement;
boolean unbuildable; // for special units likee great people
public Unit(){} // for json parsing, we need to have a default constructor
@Override
public String getName() {
return name;
}
public boolean isConstructable() {
return !unbuildable;
}
@Override
public int getProductionCost(Linq<String> policies) {
return cost;
}
@Override
public int getGoldCost(Linq<String> policies) {
return (int)( Math.pow(30 * cost,0.75) * (1 + hurryCostModifier/100) / 10 ) * 10;
}
@Override
public boolean isBuildable(CityConstructions construction) {
return !unbuildable;
}
@Override
public void postBuildEvent(CityConstructions construction) {
construction.cityInfo.civInfo.placeUnitNearTile(construction.cityInfo.cityLocation,name);
}
public MapUnit getMapUnit(){
MapUnit unit = new MapUnit();
unit.name=name;
unit.maxMovement=movement;
unit.currentMovement=movement;
return unit;
}
}

View file

@ -0,0 +1,45 @@
package com.unciv.models.gamebasics
import com.unciv.logic.city.IConstruction
import com.unciv.logic.city.CityConstructions
import com.unciv.logic.map.MapUnit
import com.unciv.models.linq.Linq
import com.unciv.models.stats.INamed
class Unit : INamed, IConstruction {
override lateinit var name: String
@JvmField var description: String? = null
@JvmField var cost: Int = 0
@JvmField var hurryCostModifier: Int = 0
@JvmField var movement: Int = 0
@JvmField internal var unbuildable: Boolean = false // for special units like great people
val isConstructable: Boolean
get() = !unbuildable
val mapUnit: MapUnit
get() {
val unit = MapUnit()
unit.name = name
unit.maxMovement = movement
unit.currentMovement = movement.toFloat()
return unit
}
override fun getProductionCost(adoptedPolicies: Linq<String>): Int {
return cost
}
override fun getGoldCost(adoptedPolicies: Linq<String>): Int {
return (Math.pow((30 * cost).toDouble(), 0.75) * (1 + hurryCostModifier / 100) / 10).toInt() * 10
}
override fun isBuildable(construction: CityConstructions): Boolean {
return !unbuildable
}
override fun postBuildEvent(construction: CityConstructions) {
construction.cityInfo.civInfo.placeUnitNearTile(construction.cityInfo.cityLocation, name)
}
} // for json parsing, we need to have a default constructor

View file

@ -1,4 +0,0 @@
package com.unciv.models.stats;
public interface INamed{
String getName();}

View file

@ -0,0 +1,5 @@
package com.unciv.models.stats
interface INamed {
var name: String
}

View file

@ -1,14 +0,0 @@
package com.unciv.models.stats;
public class NamedStats extends FullStats implements INamed {
public String name;
public String getName() {
return name;
}
public String toString() {
return name;
}
}

View file

@ -0,0 +1,10 @@
package com.unciv.models.stats
open class NamedStats : FullStats(), INamed {
override lateinit var name: String
override fun toString(): String {
return name
}
}

View file

@ -95,7 +95,7 @@ public class UnCivGame extends Game {
}
for(Building building : GameBasics.Buildings.values()) {
if (building.requiredTech == null) continue;
TechColumn column = building.GetRequiredTech().column;
TechColumn column = building.getRequiredTech().column;
if(building.cost==0)
building.cost = building.isWonder ? column.wonderCost : column.buildingCost;
}