Merge remote-tracking branch 'upstream/master'

update
This commit is contained in:
YueR 2019-10-02 23:24:52 +08:00
commit 2aba654b3a
12 changed files with 220 additions and 178 deletions

View file

@ -620,84 +620,6 @@
},
/*
{
name:"Australia",
leaderName:"John Curtin",
adjective:["Australian"],
startBias:["Avoid Tundra"],
preferredVictoryType:"Scientific",
startIntroPart1: "The people of the Australian nation salute you, Johnatan Joseph Curtin, their Prime Minister, as their leader. You have been the fourteenth prime minister of this nation, once one of the largest colonies of the British empire. You were born in a land mixed with primal nature and human civilization, and ascended on your seat as minister while the accursed Japanese empire, planning to rule the entire Asian continent, sought to conquer Australia. Your wise and careful leadership, horever, united with some luck, twarted their plans, and contributed to the rise of an indipendent, British control-free Australia. Unfortunately, your very ill health prevented you to see that dream come true, as your life ended shortly before the Second World War finally come to a close after six years of bloodshed.",
startIntroPart2: "Mister Curtin, the Australian people consider you as one of their most famous people of their history, and the best leader they could ever have, but not they call for your leadership, so that they are free to ascend to true greatness. Will you answer the call? Will you build a civilization that will stand the test of time?",
declaringWar:"After thorough deliberation, Australia finds itself at a crossroads. Prepare yourself - war is upon us.",
attacked:"We will mobilize every means of resistance to stop this transgression against our nation!",
defeated:"The principles for which we have fought will survive longer than any nation you could ever build.",
introduction:"My name is Jonathan Joseph Curtin, and I speak for the people of Australia as their Prime Minister. We seek sympathetic allies in the fight against the hawks of war.",
neutralHello:"Greetings.",
neutralLetsHearIt:["I'm listening.","What do you have in mind?"],
neutralNo:["Sorry but no.","I decline.","I regret I must refuse."],
neutralYes:["As you wish!","So be it!","I agree!"],
hateHello:"You again, it seems...",
hateLetsHearIt:["Speak your mind.","I'm listening!"],
hateNo:["No.","It shall not be.","Thanks, but no thanks."],
hateYes:["Fine...","I accept."],
afterPeace:"The war is over, for now. At least I see it alive.",
tradeRequest:"I hope you will receive my offer with my sincerest thanks.",
outerColor:[0,102,0],
innerColor:[255,255,0],
uniqueName:"Land Down Under",
unique:"+1 Food in coastal Cities. +1 Culture from Pastures",
cities:["Sydney", "Launceston", "Ballaarat", "Perth", "Brisbane", "Melbourne", "Townsville", "Geelong", "Adelaide",
"Hobart", "Bendigo", "Broken Hill", "Cairns", "Newcastle", "Maitland", "Rockhampton", "Wagga Wagga",
"Wollongong", "Albury", "Alice Springs", "Bathurst", "Queanbeyan", "Bundaberg", "Coffs Harbor", "Darwin",
"Fremantle", "Gladstone", "Goulburn", "Hervey Bay", "Kalgoorlie", "Lismore", "Lithgow", "Maryborough",
"Orange", "Port Macquarie", "Port Pirie", "Boomahnoomoonah", "Tweed Heads"]
///Unique unit: Digger (replaces Infantry, and has +10% Strenght against anti-cavalry units, +10% Strenght on coastal tiles)
///Unique building: Outback Station (replaces Windmill, adds +1 Food)
},
{
name:"Nubia",
leaderName:"Amanitore",
adjective:["Nubian"],
startBias:["Desert"],
preferredVictoryType:"Domination",
startIntroPart1: "O wise Queen of Nubia, Amanitore, we greet thee. You are the leader of the mysterious and fascinating Nubian civilization. For centuries, your people has known lots and lots of centuries of trade, friendships and warfare with the Egyptians, from which they have been culturally inspired, building pyramids and burial tombs that, while not as big as the majestic Pyramids of Kheops, Khephren and Menkaure, were no less amazing than these. After some centuries of servitude under the ambitious Pharaohs of Egypt, your ancestor Piankhi took revenge and subdued the entire land of the Pharaohs."
startIntroPart2: "Amanitore, watchful Queen of Nubia, the empire you command shall claim the horizon as its border. Fear not enemies, for your cities shall know prosperity and piety. Can you build a civilization that stands the test of time?"
declaringWar:"We have arrows, finely honed. We shall deliver them freely to your throat."
attacked:"As predicted, you know only how to take. Come, then - choose the manner of your defear."
defeated:"Though Nubia falls, our pyramids shall remain long after your plans and palaces fall to ruin."
introduction:"I am Amanitore of Nubia. All are welcome in our magnificent cities - provided they come as friends."
neutralHello:"Greetings to you."
neutralLetsHearIt:["Let us hear.","Please, talk.","What do you suggest?"]
neutralNo:["I must refuse.","Sorry, but no.","I'm afraid this is unacceptable."]
neutralYes:["How gracious of you.","So shall it be.","Of course!"]
hateHello:"You again?"
hateLetsHearIt:["What are you to say?","What is it?","Speak."]
hateNo:["The Gods forbid this!","Are you out of your mind?","I cannot do that."]
hateYes:["Hm... very well, fine.","I suppose I should agree...","Very well..."]
afterPeace:"At least you know how to speak of peace. May war never touch us again!"
tradeRequest:"Our delegation brings goodwill. Oh, here's also some fresh camel liver. Just don't cook it!"
outerColor:[255,255,51],
innerColor:[153,76,0],
uniqueName:"Ta-Seti"
unique:"+50% Production toward Ranged units, which gain +50% combat experience. +1 Production from Mines over a Strategic Resource, and +2 Gold from Mines over a Luxury Resource.",
cities:["Kerma","Napata","Nuri","El-Kurru","Kawa","Sedeinga","Heh","Qasr Ibrim","Faras","Shaat","Iken","Abu Simbel","Buhen",
"Dengeil","Miam","Tombos","Kurgus","Toshka","Soleb","Wad ban Naqa","Debba","Bugdumbush","Baki","Amara",
"Musawwarat es-Sufra","El Fura","Ukma","Pedeme","Defeia"]
//Nubians should have Pitati Archer as their unique unit, which replaces Archer and it's stronger. Can also move three tiles.
//There should also be another new Unique Improvement - but only for G&K, since it uses Faith.
},
{ // REQUIRES RIVERS
name:"Aztecs",
@ -998,41 +920,8 @@
"Fredrikstad","Kolding","Horsens","Tromsoe","Vejle","Koge","Sandnes","Holstebro","Slagelse","Drammen",
"Hillerod","Sonderborg","Skien","Svendborg","Holbaek","Hjorring","Fladstrand","Haderslev","Ringsted","Skrive"]
},
{
name:"Philippines",
leaderName:"Jose Rizal",
adjective:["Filipinos"],
startBias:["Coastal"],
prefferedVictoryType:"Cultural",
startIntroPart1:"O magnificent Rizal, your people call you to change their world once more. Can you defend this beautiful and tranquil omeland against all manner of foe?"
startIntroPart2:"Can you forge a place for the Philippine Republic through peace and harmony with the world around you? Can you build a civilization that can stand the test of time?"
declaringWar:"We bleed into the same earth and bleed we must!"
attacked:"You sure about that!"
defeated: "You have destroyed a beautiful creation. In its place is the blood of the thousands that you have lustfully slain.",
introduction: "At long last a friendly face has come to our shores. I am José Rizal, leader of the Philippine Republic! Cometellme of your people and their culture.",
neutralHello:"Hello."
neutralLetsHearIt:["What do you need.","Go on"]
neutralNo:["Sorry I cannot do that.","No Sorry."]
neutralYes:["Of Course!","Yes"]
hateHello:["You again"]
hateLetsHearIt:["Hurry Up!,"So?"]
hateNo:["Of Course Not!,"Are you crazy no"]
hateYes:["Ok Fine","I Agree"]
afterPeace:"Impressive! I Offer you peace because war only bring destruction",
tradeRequest:"Here's the list for our own benefits",
innerColor:[185,132,66]
uniqueName:"Pearl Of The Orient"
unique:"Upon signing OpenBorders, both Civilizations receive a Cargo Ship. Foreign Units within your borders provide Culture."
cities:["Manila","Quezon","Cebu",Pasig","Makati","Cagayan de Oro","Baguio","Davao City","Bacolod","Taguig","Pasay",
"Bataan","Angeles","Marikina"]
},
{
name:"Sweden",
name:"Sweden",
leaderName:"Gustavus Adolphus",
adjective:["Swedish"],
startBias:["Tundra"],
@ -1066,6 +955,117 @@
"Orebro","Vasteras","Linkoping","Norrkoping","Gavle","Karlskrona","Halmstad","Karlstad","Vaxjo",
"Copenhagen","Jonkoping",Boras",]
},
{ // THIS IS A FROM A MOD and so is the least important!
name:"Philippines",
leaderName:"Jose Rizal",
adjective:["Filipinos"],
startBias:["Coastal"],
prefferedVictoryType:"Cultural",
startIntroPart1:"O magnificent Rizal, your people call you to change their world once more. Can you defend this beautiful and tranquil omeland against all manner of foe?"
startIntroPart2:"Can you forge a place for the Philippine Republic through peace and harmony with the world around you? Can you build a civilization that can stand the test of time?"
declaringWar:"We bleed into the same earth and bleed we must!"
attacked:"You sure about that!"
defeated: "You have destroyed a beautiful creation. In its place is the blood of the thousands that you have lustfully slain.",
introduction: "At long last a friendly face has come to our shores. I am José Rizal, leader of the Philippine Republic! Cometellme of your people and their culture.",
neutralHello:"Hello."
neutralLetsHearIt:["What do you need.","Go on"]
neutralNo:["Sorry I cannot do that.","No Sorry."]
neutralYes:["Of Course!","Yes"]
hateHello:["You again"]
hateLetsHearIt:["Hurry Up!,"So?"]
hateNo:["Of Course Not!,"Are you crazy no"]
hateYes:["Ok Fine","I Agree"]
afterPeace:"Impressive! I Offer you peace because war only bring destruction",
tradeRequest:"Here's the list for our own benefits",
innerColor:[185,132,66]
uniqueName:"Pearl Of The Orient"
unique:"Upon signing OpenBorders, both Civilizations receive a Cargo Ship. Foreign Units within your borders provide Culture."
cities:["Manila","Quezon","Cebu",Pasig","Makati","Cagayan de Oro","Baguio","Davao City","Bacolod","Taguig","Pasay",
"Bataan","Angeles","Marikina"]
},
{ /// MOD CIV
name:"Australia",
leaderName:"John Curtin",
adjective:["Australian"],
startBias:["Avoid Tundra"],
preferredVictoryType:"Scientific",
startIntroPart1: "The people of the Australian nation salute you, Johnatan Joseph Curtin, their Prime Minister, as their leader. You have been the fourteenth prime minister of this nation, once one of the largest colonies of the British empire. You were born in a land mixed with primal nature and human civilization, and ascended on your seat as minister while the accursed Japanese empire, planning to rule the entire Asian continent, sought to conquer Australia. Your wise and careful leadership, horever, united with some luck, twarted their plans, and contributed to the rise of an indipendent, British control-free Australia. Unfortunately, your very ill health prevented you to see that dream come true, as your life ended shortly before the Second World War finally come to a close after six years of bloodshed.",
startIntroPart2: "Mister Curtin, the Australian people consider you as one of their most famous people of their history, and the best leader they could ever have, but not they call for your leadership, so that they are free to ascend to true greatness. Will you answer the call? Will you build a civilization that will stand the test of time?",
declaringWar:"After thorough deliberation, Australia finds itself at a crossroads. Prepare yourself - war is upon us.",
attacked:"We will mobilize every means of resistance to stop this transgression against our nation!",
defeated:"The principles for which we have fought will survive longer than any nation you could ever build.",
introduction:"My name is Jonathan Joseph Curtin, and I speak for the people of Australia as their Prime Minister. We seek sympathetic allies in the fight against the hawks of war.",
neutralHello:"Greetings.",
neutralLetsHearIt:["I'm listening.","What do you have in mind?"],
neutralNo:["Sorry but no.","I decline.","I regret I must refuse."],
neutralYes:["As you wish!","So be it!","I agree!"],
hateHello:"You again, it seems...",
hateLetsHearIt:["Speak your mind.","I'm listening!"],
hateNo:["No.","It shall not be.","Thanks, but no thanks."],
hateYes:["Fine...","I accept."],
afterPeace:"The war is over, for now. At least I see it alive.",
tradeRequest:"I hope you will receive my offer with my sincerest thanks.",
outerColor:[0,102,0],
innerColor:[255,255,0],
uniqueName:"Land Down Under",
unique:"+1 Food in coastal Cities. +1 Culture from Pastures",
cities:["Sydney", "Launceston", "Ballaarat", "Perth", "Brisbane", "Melbourne", "Townsville", "Geelong", "Adelaide",
"Hobart", "Bendigo", "Broken Hill", "Cairns", "Newcastle", "Maitland", "Rockhampton", "Wagga Wagga",
"Wollongong", "Albury", "Alice Springs", "Bathurst", "Queanbeyan", "Bundaberg", "Coffs Harbor", "Darwin",
"Fremantle", "Gladstone", "Goulburn", "Hervey Bay", "Kalgoorlie", "Lismore", "Lithgow", "Maryborough",
"Orange", "Port Macquarie", "Port Pirie", "Boomahnoomoonah", "Tweed Heads"]
///Unique unit: Digger (replaces Infantry, and has +10% Strenght against anti-cavalry units, +10% Strenght on coastal tiles)
///Unique building: Outback Station (replaces Windmill, adds +1 Food)
},
{ /// MOD CIV
name:"Nubia",
leaderName:"Amanitore",
adjective:["Nubian"],
startBias:["Desert"],
preferredVictoryType:"Domination",
startIntroPart1: "O wise Queen of Nubia, Amanitore, we greet thee. You are the leader of the mysterious and fascinating Nubian civilization. For centuries, your people has known lots and lots of centuries of trade, friendships and warfare with the Egyptians, from which they have been culturally inspired, building pyramids and burial tombs that, while not as big as the majestic Pyramids of Kheops, Khephren and Menkaure, were no less amazing than these. After some centuries of servitude under the ambitious Pharaohs of Egypt, your ancestor Piankhi took revenge and subdued the entire land of the Pharaohs."
startIntroPart2: "Amanitore, watchful Queen of Nubia, the empire you command shall claim the horizon as its border. Fear not enemies, for your cities shall know prosperity and piety. Can you build a civilization that stands the test of time?"
declaringWar:"We have arrows, finely honed. We shall deliver them freely to your throat."
attacked:"As predicted, you know only how to take. Come, then - choose the manner of your defear."
defeated:"Though Nubia falls, our pyramids shall remain long after your plans and palaces fall to ruin."
introduction:"I am Amanitore of Nubia. All are welcome in our magnificent cities - provided they come as friends."
neutralHello:"Greetings to you."
neutralLetsHearIt:["Let us hear.","Please, talk.","What do you suggest?"]
neutralNo:["I must refuse.","Sorry, but no.","I'm afraid this is unacceptable."]
neutralYes:["How gracious of you.","So shall it be.","Of course!"]
hateHello:"You again?"
hateLetsHearIt:["What are you to say?","What is it?","Speak."]
hateNo:["The Gods forbid this!","Are you out of your mind?","I cannot do that."]
hateYes:["Hm... very well, fine.","I suppose I should agree...","Very well..."]
afterPeace:"At least you know how to speak of peace. May war never touch us again!"
tradeRequest:"Our delegation brings goodwill. Oh, here's also some fresh camel liver. Just don't cook it!"
outerColor:[255,255,51],
innerColor:[153,76,0],
uniqueName:"Ta-Seti"
unique:"+50% Production toward Ranged units, which gain +50% combat experience. +1 Production from Mines over a Strategic Resource, and +2 Gold from Mines over a Luxury Resource.",
cities:["Kerma","Napata","Nuri","El-Kurru","Kawa","Sedeinga","Heh","Qasr Ibrim","Faras","Shaat","Iken","Abu Simbel","Buhen",
"Dengeil","Miam","Tombos","Kurgus","Toshka","Soleb","Wad ban Naqa","Debba","Bugdumbush","Baki","Amara",
"Musawwarat es-Sufra","El Fura","Ukma","Pedeme","Defeia"]
//Nubians should have Pitati Archer as their unique unit, which replaces Archer and it's stronger. Can also move three tiles.
//There should also be another new Unique Improvement - but only for G&K, since it uses Faith.
},
*/

View file

@ -21,8 +21,8 @@ android {
applicationId "com.unciv.app"
minSdkVersion 14
targetSdkVersion 29
versionCode 303
versionName "3.1.1"
versionCode 304
versionName "3.1.2"
}
// Had to add this crap for Travis to build, it wanted to sign the app

View file

@ -13,46 +13,63 @@ class WorkerAutomation(val unit: MapUnit) {
fun automateWorkerAction() {
val enemyUnitsInWalkingDistance = unit.movement.getDistanceToTiles().keys
.filter { it.militaryUnit!=null && it.militaryUnit!!.civInfo!=unit.civInfo
&& unit.civInfo.isAtWarWith(it.militaryUnit!!.civInfo) }
.filter {
it.militaryUnit != null && it.militaryUnit!!.civInfo != unit.civInfo
&& unit.civInfo.isAtWarWith(it.militaryUnit!!.civInfo)
}
if(enemyUnitsInWalkingDistance.isNotEmpty()) return // Don't you dare move.
if (enemyUnitsInWalkingDistance.isNotEmpty()) return // Don't you dare move.
val tile = unit.getTile()
val currentTile = unit.getTile()
val tileToWork = findTileToWork()
if(getPriority(tileToWork,unit.civInfo) < 3){ // building roads is more important
if(tryConnectingCities()) return
if (getPriority(tileToWork, unit.civInfo) < 3) { // building roads is more important
if (tryConnectingCities()) return
}
if (tileToWork != tile) {
if (tileToWork != currentTile) {
val reachedTile = unit.movement.headTowards(tileToWork)
if(reachedTile!=tile) unit.doPreTurnAction() // otherwise, we get a situation where the worker is automated, so it tries to move but doesn't, then tries to automate, then move, etc, forever. Stack overflow exception!
if (reachedTile != currentTile) unit.doPreTurnAction() // otherwise, we get a situation where the worker is automated, so it tries to move but doesn't, then tries to automate, then move, etc, forever. Stack overflow exception!
return
}
if (tile.improvementInProgress == null && tile.isLand) {
val improvement = chooseImprovement(tile, unit.civInfo)
if (improvement != null && tile.canBuildImprovement(improvement, unit.civInfo)) {
if (currentTile.improvementInProgress == null && currentTile.isLand) {
val improvement = chooseImprovement(currentTile, unit.civInfo)
if (improvement != null && currentTile.canBuildImprovement(improvement, unit.civInfo)) {
// What if we're stuck on this tile but can't build there?
tile.startWorkingOnImprovement(improvement, unit.civInfo)
currentTile.startWorkingOnImprovement(improvement, unit.civInfo)
return
}
}
if(tile.improvementInProgress!=null) return // we're working!
if(tryConnectingCities()) return //nothing to do, try again to connect cities
if (currentTile.improvementInProgress != null) return // we're working!
if (tryConnectingCities()) return //nothing to do, try again to connect cities
val citiesToNumberOfUnimprovedTiles = HashMap<String, Int>()
for (city in unit.civInfo.cities) {
citiesToNumberOfUnimprovedTiles[city.name] =
city.getTiles().count { it.isLand && tileNeedToImprove(it, unit.civInfo) }
}
val mostUndevelopedCity = unit.civInfo.cities
.filter { citiesToNumberOfUnimprovedTiles[it.name]!! > 0 }
.sortedByDescending { citiesToNumberOfUnimprovedTiles[it.name] }
.firstOrNull { unit.movement.canReach(it.ccenterTile) } //goto most undeveloped city
if (mostUndevelopedCity != null) {
val reachedTile = unit.movement.headTowards(mostUndevelopedCity.ccenterTile)
if (reachedTile != currentTile) unit.doPreTurnAction() // since we've moved, maybe we can do something here - automate
return
}
unit.civInfo.addNotification("[${unit.name}] has no work to do.", unit.currentTile.position, Color.GRAY)
}
fun tryConnectingCities():Boolean { // returns whether we actually did anything
private fun tryConnectingCities():Boolean { // returns whether we actually did anything
val targetRoad = unit.civInfo.tech.getBestRoadAvailable()
val citiesThatNeedConnecting = unit.civInfo.cities
.filter { it.population.population>3 && !it.isCapital()
.filter { it.population.population>3 && !it.isCapital() && !it.isBeingRazed //City being razed should not be connected.
&& !it.cityStats.isConnectedToCapital(targetRoad) }
if(citiesThatNeedConnecting.isEmpty()) return false // do nothing.
@ -101,12 +118,8 @@ class WorkerAutomation(val unit: MapUnit) {
val workableTiles = currentTile.getTilesInDistance(4)
.filter {
(it.civilianUnit== null || it == currentTile)
&& (it.improvement == null || (it.hasViewableResource(unit.civInfo) && !it.containsGreatImprovement() && it.getTileResource().improvement != it.improvement))
&& it.isLand
&& !it.getBaseTerrain().impassable
&& (it.containsUnfinishedGreatImprovement() || it.canBuildImprovement(chooseImprovement(it, unit.civInfo), unit.civInfo))
&& {val city=it.getCity(); city==null || it.getCity()?.civInfo == unit.civInfo}() // don't work tiles belonging to another civ
}.sortedByDescending { getPriority(it, unit.civInfo) }.toMutableList()
&& tileNeedToImprove(it, unit.civInfo) }
.sortedByDescending { getPriority(it, unit.civInfo) }.toMutableList()
// the tile needs to be actually reachable - more difficult than it seems,
// which is why we DON'T calculate this for every possible tile in the radius,
@ -121,6 +134,15 @@ class WorkerAutomation(val unit: MapUnit) {
else return currentTile
}
private fun tileNeedToImprove(tile: TileInfo, civInfo: CivilizationInfo): Boolean {
if (!tile.isLand || tile.getBaseTerrain().impassable)
return false
val city=tile.getCity()
if (city == null || city.civInfo != civInfo)
return false
return (tile.improvement == null || (tile.hasViewableResource(civInfo) && !tile.containsGreatImprovement() && tile.getTileResource().improvement != tile.improvement))
&& (tile.containsUnfinishedGreatImprovement() || tile.canBuildImprovement(chooseImprovement(tile, civInfo), civInfo))
}
private fun getPriority(tileInfo: TileInfo, civInfo: CivilizationInfo): Int {
var priority = 0

View file

@ -11,7 +11,6 @@ class CityExpansionManager {
lateinit var cityInfo: CityInfo
var cultureStored: Int = 0
fun clone(): CityExpansionManager {
val toReturn = CityExpansionManager()
toReturn.cultureStored=cultureStored
@ -118,7 +117,6 @@ class CityExpansionManager {
cityInfo.civInfo.updateViewableTiles()
}
fun nextTurn(culture: Float) {
cultureStored += culture.toInt()
if (cultureStored >= getCultureToNextTile()) {
@ -128,7 +126,8 @@ class CityExpansionManager {
}
fun setTransients(){
for(tile in cityInfo.tiles.map { cityInfo.tileMap[it] })
val tiles = cityInfo.getTiles()
for(tile in tiles )
tile.owningCity=cityInfo
}
//endregion

View file

@ -279,6 +279,7 @@ class CityInfo {
}
isPuppet=false
cityStats.update()
UnCivGame.Current.worldScreen.shouldUpdate=true
}
@ -303,6 +304,7 @@ class CityInfo {
resistanceCounter = population.population // I checked, and even if you puppet there's resistance for conquering
isPuppet = true
health = getMaxHealth() / 2 // I think that cities recover to half health when conquered?
cityStats.update()
}
private fun diplomaticRepercussionsForConqueringCity(oldCiv: CivilizationInfo, conqueringCiv: CivilizationInfo) {
@ -342,6 +344,7 @@ class CityInfo {
if(foundingCiv.cities.size == 1) cityConstructions.addBuilding("Palace") // Resurrection!
isPuppet = false
cityStats.update()
UnCivGame.Current.worldScreen.shouldUpdate=true
}

View file

@ -3,6 +3,7 @@ package com.unciv.logic.civilization
enum class AlertType{
Defeated,
WonderBuilt,
TechResearched,
WarDeclaration,
FirstContact,
CityConquered,

View file

@ -135,6 +135,7 @@ class TechManager {
updateTransientBooleans()
civInfo.addNotification("Research of [$techName] has completed!", Color.BLUE, TechAction(techName))
civInfo.popupAlerts.add(PopupAlert(AlertType.TechResearched,techName))
val currentEra = civInfo.getEra()
if (previousEra < currentEra) {

View file

@ -38,7 +38,7 @@ class Building : NamedStats(), IConstruction{
var xpForNewUnits=0
var replaces:String?=null
var uniqueTo:String?=null
var quote:String?=null
var quote:String=""
// Uniques
private var providesFreeBuilding: String? = null

View file

@ -7,6 +7,17 @@ import com.unciv.models.gamebasics.tr
import java.util.*
class Technology : ICivilopedia {
lateinit var name: String
var cost: Int = 0
var prerequisites = HashSet<String>()
var uniques = ArrayList<String>()
var column: TechColumn? = null // The column that this tech is in the tech tree
var row: Int = 0
var quote=""
override val description: String
get() {
val lineList = ArrayList<String>() // more readable than StringBuilder, with same performance for our use-case
@ -62,15 +73,6 @@ class Technology : ICivilopedia {
return lineList.joinToString("\n") { it.tr() }
}
lateinit var name: String
var cost: Int = 0
var prerequisites = HashSet<String>()
var uniques = ArrayList<String>()
var column: TechColumn? = null // The column that this tech is in the tech tree
var row: Int = 0
override fun toString(): String {
return name
}

View file

@ -7,70 +7,75 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.utils.Align
import com.unciv.logic.civilization.TechManager
import com.unciv.models.gamebasics.GameBasics
import com.unciv.ui.utils.*
import com.unciv.ui.worldscreen.WorldScreen
import com.unciv.ui.utils.CameraStageBaseScreen
import com.unciv.ui.utils.ImageGetter
import com.unciv.ui.utils.setFontColor
import com.unciv.ui.utils.surroundWithCircle
class TechButton(techName:String, val techManager: TechManager, isWorldScreen: Boolean = true) : Table(CameraStageBaseScreen.skin) {
val text= Label("", skin).setFontColor(Color.WHITE).apply { setAlignment(Align.center) }
init {
touchable = Touchable.enabled
defaults().pad(10f)
background = ImageGetter.getDrawable("OtherIcons/civTableBackground")
if(ImageGetter.techIconExists(techName))
add(ImageGetter.getTechIconGroup(techName)) // this is 60*60
if (ImageGetter.techIconExists(techName))
add(ImageGetter.getTechIconGroup(techName, 60f))
val rightSide = Table()
val techCost = techManager.costOfTech(techName)
val remainingTech = techManager.remainingScienceToTech(techName)
if(techCost!=remainingTech){
val percentComplete = (techCost-remainingTech)/techCost.toFloat()
if (techCost != remainingTech) {
val percentComplete = (techCost - remainingTech) / techCost.toFloat()
add(ImageGetter.getProgressBarVertical(2f, 50f, percentComplete, Color.BLUE, Color.WHITE))
}
else add().width(2f)
} else add().width(2f)
if (isWorldScreen) rightSide.add(text).row()
else rightSide.add(text).height(25f).row()
// here we add little images of what the tech gives you
addTechEnabledIcons(techName, isWorldScreen, rightSide)
add(rightSide)
pack()
}
private fun addTechEnabledIcons(techName: String, isWorldScreen: Boolean, rightSide: Table) {
val techEnabledIcons = Table()
techEnabledIcons.defaults().pad(5f)
val techEnabledUnits = GameBasics.Units.values.filter { it.requiredTech==techName }
val techEnabledUnits = GameBasics.Units.values.filter { it.requiredTech == techName }
val ourUniqueUnits = techEnabledUnits.filter { it.uniqueTo == techManager.civInfo.civName }
val replacedUnits = ourUniqueUnits.map { it.replaces!! }
val ourEnabledUnits = techEnabledUnits.filter { it.uniqueTo == null && !replacedUnits.contains(it.name) }
.union(ourUniqueUnits)
for(unit in ourEnabledUnits)
for (unit in ourEnabledUnits)
techEnabledIcons.add(ImageGetter.getConstructionImage(unit.name).surroundWithCircle(30f))
val techEnabledBuildings = GameBasics.Buildings.values.filter { it.requiredTech==techName }
val ourUniqueBuildings = techEnabledBuildings.filter { it.uniqueTo==techManager.civInfo.civName }
val techEnabledBuildings = GameBasics.Buildings.values.filter { it.requiredTech == techName }
val ourUniqueBuildings = techEnabledBuildings.filter { it.uniqueTo == techManager.civInfo.civName }
val replacedBuildings = ourUniqueBuildings.map { it.replaces!! }
val ourEnabledBuildings = techEnabledBuildings.filter { it.uniqueTo==null && !replacedBuildings.contains(it.name) }
val ourEnabledBuildings = techEnabledBuildings.filter { it.uniqueTo == null && !replacedBuildings.contains(it.name) }
.union(ourUniqueBuildings)
for(building in ourEnabledBuildings)
for (building in ourEnabledBuildings)
techEnabledIcons.add(ImageGetter.getConstructionImage(building.name).surroundWithCircle(30f))
for(improvement in GameBasics.TileImprovements.values.filter { it.techRequired==techName || it.improvingTech==techName }) {
if(improvement.name.startsWith("Remove"))
for (improvement in GameBasics.TileImprovements.values.filter { it.techRequired == techName || it.improvingTech == techName }) {
if (improvement.name.startsWith("Remove"))
techEnabledIcons.add(ImageGetter.getImage("OtherIcons/Stop")).size(30f)
else techEnabledIcons.add(ImageGetter.getImprovementIcon(improvement.name, 30f))
}
for(resource in GameBasics.TileResources.values.filter { it.revealedBy==techName })
for (resource in GameBasics.TileResources.values.filter { it.revealedBy == techName })
techEnabledIcons.add(ImageGetter.getResourceImage(resource.name, 30f))
val tech = GameBasics.Technologies[techName]!!
for(unique in tech.uniques)
for (unique in tech.uniques)
techEnabledIcons.add(ImageGetter.getImage("OtherIcons/Star")
.apply { color= Color.BLACK }.surroundWithCircle(30f))
.apply { color = Color.BLACK }.surroundWithCircle(30f))
if (isWorldScreen) rightSide.add(techEnabledIcons)
else rightSide.add(techEnabledIcons).width(150f)
add(rightSide)
pack()
}
}

View file

@ -184,7 +184,7 @@ object ImageGetter {
return iconGroup
}
fun getTechIconGroup(techName: String): Group {
fun getTechIconGroup(techName: String, circleSize: Float): Group {
var techIconColor = Color.WHITE
when (GameBasics.Technologies[techName]!!.era().name) {
"Ancient" -> techIconColor = colorFromRGB(255, 87, 35)
@ -197,8 +197,7 @@ object ImageGetter {
"Future" -> techIconColor = colorFromRGB(76,176,81)
}
return getImage("TechIcons/$techName").apply { color = techIconColor.lerp(Color.BLACK,0.6f) }
.surroundWithCircle(60f)
//.apply { this.circle.color = techIconColor.lerp(Color.WHITE, 0.5f) }
.surroundWithCircle(circleSize)
}
fun getProgressBarVertical(width:Float,height:Float,percentComplete:Float,progressColor:Color,backgroundColor:Color): Table {

View file

@ -122,13 +122,23 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
addGoodSizedLabel(wonder.name)
addSeparator()
val centerTable = Table()
val wonderText = if(wonder.quote!=null) wonder.quote!! else ""
centerTable.add(wonderText.toLabel().apply { setWrap(true) }).width(worldScreen.stage.width/3)
centerTable.add(wonder.quote.toLabel().apply { setWrap(true) }).width(worldScreen.stage.width/3)
centerTable.add(ImageGetter.getConstructionImage(wonder.name).surroundWithCircle(100f)).pad(20f)
centerTable.add(wonder.getShortDescription().toLabel().apply { setWrap(true) }).width(worldScreen.stage.width/3)
add(centerTable).row()
add(getCloseButton("Close"))
}
AlertType.TechResearched -> {
val tech = GameBasics.Technologies[popupAlert.value]!!
addGoodSizedLabel(tech.name)
addSeparator()
val centerTable = Table()
centerTable.add(tech.quote.toLabel().apply { setWrap(true) }).width(worldScreen.stage.width/3)
centerTable.add(ImageGetter.getTechIconGroup(tech.name,100f)).pad(20f)
centerTable.add(tech.description.toLabel().apply { setWrap(true) }).width(worldScreen.stage.width/3)
add(centerTable).row()
add(getCloseButton("Close"))
}
}
open()
worldScreen.alertPopupIsOpen = true