mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 06:51:30 -04:00
Polynesia works!
This commit is contained in:
commit
e77fdd2993
BIN
android/Images/UnitIcons/Maori Warrior.png
Normal file
BIN
android/Images/UnitIcons/Maori Warrior.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
android/Images/UnitPromotionIcons/Haka War Dance.png
Normal file
BIN
android/Images/UnitPromotionIcons/Haka War Dance.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 1008 KiB After Width: | Height: | Size: 1015 KiB |
@ -618,6 +618,43 @@
|
||||
"Gaugamela","Harmozeia","Ekatompylos","Izata","Kampada","Kapisa","Karmana","Kounaxa","Kuganaka","Nautaka",
|
||||
"Paishiyauvada","Patigrbana","Phrada"]
|
||||
},
|
||||
{
|
||||
name:"Polynesia",
|
||||
leaderName:"Kamehameha I",
|
||||
adjective:["Polynesia"],
|
||||
startBias:["Coast"],
|
||||
preferredVictoryType:"Cultural",
|
||||
|
||||
startIntroPart1: "Greetings and blessings be upon you, Kamehameha the Great, chosen by the heavens to unite your scattered peoples. Oh mighty King, you were the first to bring the Big Island of Hawai'I under one solitary rule in 1791 AD. This was followed by the merging of all the remaining islands under your standard in 1810. As the first King of Hawai'I, you standardized the legal and taxation systems and instituted the Mamalahoe Kawanai, an edict protecting civilians in times of war. You ensured the continued unification and sovereignty of the islands by your strong laws and deeds, even after your death in 1819."
|
||||
startIntroPart2: "Oh wise and exalted King, your people wish for a kingdom of their own once more and require a leader of unparalleled greatness! Will you answer their call and don the mantle of the Lion of the Pacific? Will you build a kingdom that stands the test of time?"
|
||||
|
||||
declaringWar:"The ancient fire flashing across the sky is what proclaimed that this day would come, though I had foolishly hoped for a different outcome."
|
||||
attacked:"It is obvious now that I misjudged you and your true intentions."
|
||||
defeated:"The hard-shelled crab yields, and the lion lies down to sleep. Kanaloa comes for me now."
|
||||
introduction:"Aloha! Greetings and blessings upon you, friend. I am Kamehameha, Great King of this strand of islands."
|
||||
|
||||
neutralHello:"Welcome, friend!"
|
||||
neutralLetsHearIt:["Proceed.","And?","What is it?"]
|
||||
hateNo:["Certainly not.","We will have to decline."]
|
||||
hateYes:["It is agreed, then.","Excellent!"]
|
||||
|
||||
hateHello:"Oh, it's you."
|
||||
hateLetsHearIt:["Proceed.","I'm listening","What is it?"]
|
||||
hateNo:["Certainly not!","That's not acceptable!"]
|
||||
hateYes:["Yes, I suppost I must.","Yes, so be it."]
|
||||
|
||||
afterPeace:"Perhaps the stars were mistakenly placed... I will consult my Kahuna."
|
||||
tradeRequest:"Come, let our people feast together!"
|
||||
|
||||
outerColor:[210,51,0],
|
||||
innerColor:[255,255,78],
|
||||
uniqueName:"Wayfinding"
|
||||
unique:"Can embark and move over Coasts and Oceans immediately. +1 Sight when embarked. +10% Combat Strength bonus if within 2 tiles of a Moai.",
|
||||
cities:["Honolulu","Samoa","Tonga","Nuku Hiva","Raiatea","Aotearoa","Tahiti","Hilo","Te Wai Pounamu","Rapa Nui",
|
||||
"Tuamotu","Rarotonga","Tuvalu","Tubuai","Mangareva","Oahu","Kiritimati","Ontong Java","Niue","Rekohu",
|
||||
"Rakahanga","Bora Bora","Kailua","Uvea","Futuna","Rotuma","Tokelau","Lahaina","Bellona","Mungava","Tikopia",
|
||||
"Emae","Kapingamarangi","Takuu","Nukuoro","Sikaiana","Anuta","Nuguria","Pileni","Nukumanu"]
|
||||
},
|
||||
|
||||
/*
|
||||
|
||||
@ -771,43 +808,6 @@
|
||||
"Huaras","Riobamba","Caxamalca","Sausa","Tambo Colorado","Huaca","Tumbes","Chan Chan","Sipan","Pachacamac",
|
||||
"Llactapata","Pisac","Kuelap","Pajaten","Chucuito","Choquequirao"]
|
||||
}
|
||||
{
|
||||
name:"Polynesia",
|
||||
leaderName:"Kamehameha I",
|
||||
adjective:["Polynesia"],
|
||||
startBias:["Coast"],
|
||||
preferredVictoryType:"Cultural",
|
||||
|
||||
startIntroPart1: "Greetings and blessings be upon you, Kamehameha the Great, chosen by the heavens to unite your scattered peoples. Oh mighty King, you were the first to bring the Big Island of Hawai'I under one solitary rule in 1791 AD. This was followed by the merging of all the remaining islands under your standard in 1810. As the first King of Hawai'I, you standardized the legal and taxation systems and instituted the Mamalahoe Kawanai, an edict protecting civilians in times of war. You ensured the continued unification and sovereignty of the islands by your strong laws and deeds, even after your death in 1819."
|
||||
startIntroPart2: "Oh wise and exalted King, your people wish for a kingdom of their own once more and require a leader of unparalleled greatness! Will you answer their call and don the mantle of the Lion of the Pacific? Will you build a kingdom that stands the test of time?"
|
||||
|
||||
declaringWar:"The ancient fire flashing across the sky is what proclaimed that this day would come, though I had foolishly hoped for a different outcome."
|
||||
attacked:"It is obvious now that I misjudged you and your true intentions."
|
||||
defeated:"The hard-shelled crab yields, and the lion lies down to sleep. Kanaloa comes for me now."
|
||||
introduction:"Aloha! Greetings and blessings upon you, friend. I am Kamehameha, Great King of this strand of islands."
|
||||
|
||||
neutralHello:"Welcome, friend!"
|
||||
neutralLetsHearIt:["Proceed.","And?","What is it?"]
|
||||
hateNo:["Certainly not.","We will have to decline."]
|
||||
hateYes:["It is agreed, then.","Excellent!"]
|
||||
|
||||
hateHello:"Oh, it's you."
|
||||
hateLetsHearIt:["Proceed.","I'm listening","What is it?"]
|
||||
hateNo:["Certainly not!","That's not acceptable!"]
|
||||
hateYes:["Yes, I suppost I must.","Yes, so be it."]
|
||||
|
||||
afterPeace:"Perhaps the stars were mistakenly placed... I will consult my Kahuna."
|
||||
tradeRequest:"Come, let our people feast together!"
|
||||
|
||||
outerColor:[210,51,0],
|
||||
innerColor:[255,255,78],
|
||||
uniqueName:"Wayfinding"
|
||||
unique:"Can embark and move over Costs and Oceans immediately. +1 Sight when embarked",
|
||||
cities:["Honolulu","Samoa","Tonga","Nuku Hiva","Raiatea","Aotearoa","Tahiti","Hilo","Te Wai Pounamu","Rapa Nui",
|
||||
"Tuamotu","Rarotonga","Tuvalu","Tubuai","Mangareva","Oahu","Kiritimati","Ontong Java","Niue","Rekohu",
|
||||
"Rakahanga","Bora Bora","Kailua","Uvea","Futuna","Rotuma","Tokelau","Lahaina","Bellona","Mungava","Tikopia",
|
||||
"Emae","Kapingamarangi","Takuu","Nukuoro","Sikaiana","Anuta","Nuguria","Pileni","Nukumanu"]
|
||||
},
|
||||
{
|
||||
name:"Songhai",
|
||||
leaderName:"Askia",
|
||||
|
@ -155,7 +155,6 @@
|
||||
techRequired:"Construction",
|
||||
improvingTech:"Flight",
|
||||
improvingTechStats:{gold:1}
|
||||
//It can be colored in orange
|
||||
},
|
||||
/*
|
||||
{
|
||||
|
@ -1014,6 +1014,7 @@
|
||||
}
|
||||
|
||||
"'The introduction of so powerful an agent as steam to a carriage on wheels will make a great change in the situation of man.' - Thomas Jefferson":{//"Railroad" Technology quotes, it has been translated somewhere.
|
||||
Italian: "'L'introduzione sui carri a ruote di un agente potente come il vapore apporterà un grande cambiamento alla condizione dell'uomo.' - Thomas Jefferson"
|
||||
Simplified_Chinese:"“引入蒸汽这样一个强大的助手来驱动车轮进行运输,将极大地改变人类的境地。”——托马斯·杰斐逊"
|
||||
}
|
||||
|
||||
|
@ -402,4 +402,10 @@
|
||||
effect:"Bonus vs water units 15%",
|
||||
unitTypes:["WaterRanged"]
|
||||
}
|
||||
|
||||
// Uniques
|
||||
{
|
||||
name:"Haka War Dance", // only for Maori Warrior and subsequent upgrades
|
||||
effect:"-10% combat strength for adjacent enemy units"
|
||||
}
|
||||
]
|
@ -39,6 +39,20 @@
|
||||
upgradesTo:"Swordsman",
|
||||
attackSound:"nonmetalhit"
|
||||
},
|
||||
{
|
||||
name:"Maori Warrior",
|
||||
unitType:"Melee",
|
||||
uniqueTo:"Polynesia",
|
||||
replaces:"Warrior",
|
||||
movement:2,
|
||||
strength:8,
|
||||
cost: 40,
|
||||
hurryCostModifier:20,
|
||||
obsoleteTech:"Metal Casting",
|
||||
promotions:["Haka War Dance"],
|
||||
upgradesTo:"Swordsman",
|
||||
attackSound:"nonmetalhit"
|
||||
},
|
||||
/*
|
||||
{
|
||||
name:"Jaguar",
|
||||
@ -55,21 +69,6 @@
|
||||
attackSound:"nonmetalhit"
|
||||
//Aztec unique unit, moves faster and fights better in Forest and Jungle. He also heals 25 if he kills an enemy.
|
||||
},
|
||||
{
|
||||
name:"Maori Warrior",
|
||||
unitType:"Melee",
|
||||
uniqueTo:"Polynesia",
|
||||
replaces:"Warrior",
|
||||
movement:2,
|
||||
strength:8,
|
||||
cost: 40,
|
||||
hurryCostModifier:20,
|
||||
obsoleteTech:"Metal Casting",
|
||||
uniques:["Haka War Dance"],
|
||||
upgradesTo:"Swordsman",
|
||||
attackSound:"nonmetalhit"
|
||||
//Polynesian unique unit. All nearby enemy Units have -10% strenght
|
||||
},
|
||||
*/
|
||||
{
|
||||
name:"Brute",
|
||||
|
@ -190,7 +190,7 @@ class GameInfo {
|
||||
if(currentPlayer=="") currentPlayer=civilizations.first { it.isPlayerCivilization() }.civName
|
||||
currentPlayerCiv=getCivilization(currentPlayer)
|
||||
|
||||
// this is separated into 2 loops because when we activate updateViewableTiles in civ.setTransients,
|
||||
// this is separated into 2 loops because when we activate updateVisibleTiles in civ.setTransients,
|
||||
// we try to find new civs, and we check if civ is barbarian, which we can't know unless the gameInfo is already set.
|
||||
for (civInfo in civilizations) civInfo.gameInfo = this
|
||||
|
||||
@ -238,7 +238,7 @@ class GameInfo {
|
||||
|
||||
for (civInfo in civilizations){
|
||||
for(unit in civInfo.getCivUnits())
|
||||
unit.updateViewableTiles() // this needs to be done after all the units are assigned to their civs and all other transients are set
|
||||
unit.updateVisibleTiles() // this needs to be done after all the units are assigned to their civs and all other transients are set
|
||||
|
||||
// Since this depends on the cities of ALL civilizations,
|
||||
// we need to wait until we've set the transients of all the cities before we can run this.
|
||||
|
@ -74,12 +74,12 @@ class GameStarter{
|
||||
val startingLocation = startingLocations[civ]!!
|
||||
|
||||
civ.placeUnitNearTile(startingLocation.position, Constants.settler)
|
||||
civ.placeUnitNearTile(startingLocation.position, "Warrior")
|
||||
civ.placeUnitNearTile(startingLocation.position, civ.getEquivalentUnit("Warrior").name)
|
||||
civ.placeUnitNearTile(startingLocation.position, "Scout")
|
||||
|
||||
if (!civ.isPlayerCivilization() && civ.isMajorCiv()) {
|
||||
for (unit in gameInfo.getDifficulty().aiFreeUnits) {
|
||||
civ.placeUnitNearTile(startingLocation.position, unit)
|
||||
civ.placeUnitNearTile(startingLocation.position, civ.getEquivalentUnit(unit).name)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -101,6 +101,17 @@ class GameStarter{
|
||||
landTilesInBigEnoughGroup.addAll(tilesInGroup)
|
||||
}
|
||||
|
||||
val tilesWithStartingLocations = tileMap.values
|
||||
.filter { it.improvement!=null && it.improvement!!.startsWith("StartingLocation ") }
|
||||
|
||||
val civsOrderedByAvailableLocations = civs.sortedBy {civ ->
|
||||
when {
|
||||
tilesWithStartingLocations.any { it.improvement=="StartingLocation "+civ.civName } -> 1 // harshest requirements
|
||||
civ.nation.startBias.isNotEmpty() -> 2 // less harsh
|
||||
else -> 3
|
||||
} // no requirements
|
||||
}
|
||||
|
||||
for(minimumDistanceBetweenStartingLocations in tileMap.tileMatrix.size/3 downTo 0){
|
||||
val freeTiles = landTilesInBigEnoughGroup
|
||||
.filter { vectorIsAtLeastNTilesAwayFromEdge(it.position,minimumDistanceBetweenStartingLocations,tileMap)}
|
||||
@ -108,17 +119,6 @@ class GameStarter{
|
||||
|
||||
val startingLocations = HashMap<CivilizationInfo,TileInfo>()
|
||||
|
||||
val tilesWithStartingLocations = tileMap.values
|
||||
.filter { it.improvement!=null && it.improvement!!.startsWith("StartingLocation ") }
|
||||
|
||||
val civsOrderedByAvailableLocations = civs.sortedBy {civ ->
|
||||
when {
|
||||
tilesWithStartingLocations.any { it.improvement=="StartingLocation "+civ.civName } -> 1 // harshest requirements
|
||||
civ.nation.startBias.isNotEmpty() -> 2 // less harsh
|
||||
else -> 3
|
||||
} // no requirements
|
||||
}
|
||||
|
||||
for(civ in civsOrderedByAvailableLocations){
|
||||
var startingLocation:TileInfo
|
||||
val presetStartingLocation = tilesWithStartingLocations.firstOrNull { it.improvement=="StartingLocation "+civ.civName }
|
||||
|
@ -23,24 +23,24 @@ class Automation {
|
||||
return rank
|
||||
}
|
||||
|
||||
fun rankTileForCityWork(tile:TileInfo, city: CityInfo): Float {
|
||||
fun rankTileForCityWork(tile:TileInfo, city: CityInfo, foodWeight: Float = 1f): Float {
|
||||
val stats = tile.getTileStats(city, city.civInfo)
|
||||
return rankStatsForCityWork(stats, city)
|
||||
return rankStatsForCityWork(stats, city, foodWeight)
|
||||
}
|
||||
|
||||
private fun rankStatsForCityWork(stats: Stats, city: CityInfo): Float {
|
||||
private fun rankStatsForCityWork(stats: Stats, city: CityInfo, foodWeight: Float = 1f): Float {
|
||||
var rank = 0f
|
||||
if(city.population.population < 5){
|
||||
// "small city" - we care more about food and less about global problems like gold science and culture
|
||||
rank += stats.food * 1.2f
|
||||
rank += stats.food * 1.2f * foodWeight
|
||||
rank += stats.production
|
||||
rank += stats.science/2
|
||||
rank += stats.culture/2
|
||||
rank += stats.gold / 5 // it's barely worth anything at this points
|
||||
}
|
||||
else{
|
||||
if (stats.food <= 2 || city.civInfo.getHappiness() > 5) rank += (stats.food * 1.2f) //food get more value to keep city growing
|
||||
else rank += (2.4f + (stats.food - 2) / 2) // 1.2 point for each food up to 2, from there on half a point
|
||||
if (stats.food <= 2 || city.civInfo.getHappiness() > 5) rank += (stats.food * 1.2f * foodWeight) //food get more value to keep city growing
|
||||
else rank += ((2.4f + (stats.food - 2) / 2) * foodWeight) // 1.2 point for each food up to 2, from there on half a point
|
||||
|
||||
if (city.civInfo.gold < 0 && city.civInfo.statsForNextTurn.gold <= 0) rank += stats.gold // we have a global problem
|
||||
else rank += stats.gold / 3 // 3 gold is worse than 2 production
|
||||
|
@ -2,6 +2,7 @@ package com.unciv.logic.automation
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.unciv.Constants
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.map.BFS
|
||||
import com.unciv.logic.map.MapUnit
|
||||
@ -24,7 +25,7 @@ class WorkerAutomation(val unit: MapUnit) {
|
||||
val tileToWork = findTileToWork()
|
||||
|
||||
if (getPriority(tileToWork, unit.civInfo) < 3) { // building roads is more important
|
||||
if (tryConnectingCities()) return
|
||||
if (tryConnectingCities(unit)) return
|
||||
}
|
||||
|
||||
if (tileToWork != currentTile) {
|
||||
@ -41,7 +42,7 @@ class WorkerAutomation(val unit: MapUnit) {
|
||||
}
|
||||
}
|
||||
if (currentTile.improvementInProgress != null) return // we're working!
|
||||
if (tryConnectingCities()) return //nothing to do, try again to connect cities
|
||||
if (tryConnectingCities(unit)) return //nothing to do, try again to connect cities
|
||||
|
||||
val citiesToNumberOfUnimprovedTiles = HashMap<String, Int>()
|
||||
for (city in unit.civInfo.cities) {
|
||||
@ -53,7 +54,7 @@ class WorkerAutomation(val unit: MapUnit) {
|
||||
.filter { citiesToNumberOfUnimprovedTiles[it.name]!! > 0 }
|
||||
.sortedByDescending { citiesToNumberOfUnimprovedTiles[it.name] }
|
||||
.firstOrNull { unit.movement.canReach(it.ccenterTile) } //goto most undeveloped city
|
||||
if (mostUndevelopedCity != null) {
|
||||
if (mostUndevelopedCity != null && mostUndevelopedCity != unit.currentTile.owningCity) {
|
||||
val reachedTile = unit.movement.headTowards(mostUndevelopedCity.ccenterTile)
|
||||
if (reachedTile != currentTile) unit.doPreTurnAction() // since we've moved, maybe we can do something here - automate
|
||||
return
|
||||
@ -64,7 +65,10 @@ class WorkerAutomation(val unit: MapUnit) {
|
||||
|
||||
|
||||
|
||||
private fun tryConnectingCities():Boolean { // returns whether we actually did anything
|
||||
private fun tryConnectingCities(unit: MapUnit):Boolean { // returns whether we actually did anything
|
||||
//Player can choose not to auto-build roads & railroads.
|
||||
if (unit.civInfo.isPlayerCivilization() && !UnCivGame.Current.settings.autoBuildingRoads)
|
||||
return false
|
||||
|
||||
val targetRoad = unit.civInfo.tech.getBestRoadAvailable()
|
||||
|
||||
|
@ -265,7 +265,7 @@ class Battle(val gameInfo:GameInfo) {
|
||||
|
||||
capturedUnit.civInfo.removeUnit(capturedUnit)
|
||||
capturedUnit.assignOwner(attacker.getCivInfo())
|
||||
capturedUnit.updateViewableTiles()
|
||||
capturedUnit.updateVisibleTiles()
|
||||
}
|
||||
|
||||
private fun tryInterceptAirAttack(attacker:MapUnitCombatant, defender: ICombatant) {
|
||||
|
@ -173,6 +173,16 @@ class BattleDamage{
|
||||
if(!isFriendlyTerritory && unit.unit.hasUnique("+20% bonus outside friendly territory"))
|
||||
modifiers["Foreign Land"] = 0.2f
|
||||
|
||||
|
||||
if(unit.getCivInfo().nation.unique == "Can embark and move over Coasts and Oceans immediately. +1 Sight when embarked. +10% Combat Strength bonus if within 2 tiles of a Moai."
|
||||
&& tile.getTilesInDistance(2).any { it.improvement=="Moai" })
|
||||
modifiers["Moai"] = 0.1f
|
||||
|
||||
if(tile.neighbors.flatMap { it.getUnits() }
|
||||
.any { it.hasUnique("-10% combat strength for adjacent enemy units") && it.civInfo.isAtWarWith(unit.getCivInfo()) })
|
||||
modifiers["Haka War Dance"] = -0.1f
|
||||
|
||||
|
||||
if(unit.unit.hasUnique("+33% combat bonus in Forest/Jungle")
|
||||
&& (tile.terrainFeature== Constants.forest || tile.terrainFeature==Constants.jungle))
|
||||
modifiers[tile.terrainFeature!!]=0.33f
|
||||
|
@ -229,11 +229,18 @@ class CityInfo {
|
||||
}
|
||||
|
||||
fun reassignWorkers() {
|
||||
workedTiles = hashSetOf()
|
||||
population.specialists.clear()
|
||||
for (i in 0..population.population)
|
||||
population.autoAssignPopulation()
|
||||
cityStats.update()
|
||||
var foodWeight = 1f
|
||||
var foodPerTurn = 0f
|
||||
while (foodWeight < 3 && foodPerTurn <= 0) {
|
||||
workedTiles = hashSetOf()
|
||||
population.specialists.clear()
|
||||
for (i in 0..population.population)
|
||||
population.autoAssignPopulation(foodWeight)
|
||||
cityStats.update()
|
||||
|
||||
foodPerTurn = cityStats.currentCityStats.food
|
||||
foodWeight += 0.5f
|
||||
}
|
||||
}
|
||||
|
||||
fun endTurn() {
|
||||
|
@ -73,16 +73,16 @@ class PopulationManager {
|
||||
// todo - change tile choice according to city!
|
||||
// if small city, favor production above all, ignore gold!
|
||||
// if larger city, food should be worth less!
|
||||
internal fun autoAssignPopulation() {
|
||||
internal fun autoAssignPopulation(foodWeight: Float = 1f) {
|
||||
if(getFreePopulation()==0) return
|
||||
|
||||
//evaluate tiles
|
||||
val bestTile: TileInfo? = cityInfo.getTiles()
|
||||
.filter { it.arialDistanceTo(cityInfo.getCenterTile()) <= 3 }
|
||||
.filterNot { cityInfo.workedTiles.contains(it.position) || cityInfo.location==it.position}
|
||||
.maxBy { Automation().rankTileForCityWork(it,cityInfo) }
|
||||
.maxBy { Automation().rankTileForCityWork(it,cityInfo, foodWeight) }
|
||||
val valueBestTile = if(bestTile==null) 0f
|
||||
else Automation().rankTileForCityWork(bestTile, cityInfo)
|
||||
else Automation().rankTileForCityWork(bestTile, cityInfo, foodWeight)
|
||||
|
||||
//evaluate specialists
|
||||
val maxSpecialistsMap = getMaxSpecialists().toHashMap()
|
||||
|
@ -17,6 +17,7 @@ import com.unciv.logic.trade.TradeRequest
|
||||
import com.unciv.models.gamebasics.*
|
||||
import com.unciv.models.gamebasics.tech.TechEra
|
||||
import com.unciv.models.gamebasics.tile.ResourceSupplyList
|
||||
import com.unciv.models.gamebasics.unit.BaseUnit
|
||||
import com.unciv.models.stats.Stats
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
@ -230,6 +231,13 @@ class CivilizationInfo {
|
||||
return baseBuilding
|
||||
}
|
||||
|
||||
fun getEquivalentUnit(baseUnitName:String):BaseUnit {
|
||||
for (unit in GameBasics.Units.values)
|
||||
if (unit.replaces == baseUnitName && unit.uniqueTo == civName)
|
||||
return unit
|
||||
return GameBasics.Units[baseUnitName]!!
|
||||
}
|
||||
|
||||
fun meetCivilization(otherCiv: CivilizationInfo) {
|
||||
diplomacy[otherCiv.civName] = DiplomacyManager(this, otherCiv.civName)
|
||||
.apply { diplomaticStatus = DiplomaticStatus.Peace }
|
||||
@ -278,7 +286,7 @@ class CivilizationInfo {
|
||||
//region state-changing functions
|
||||
|
||||
/** This is separate because the REGULAR setTransients updates the viewable ties,
|
||||
* and the updateViewableTiles tries to meet civs...
|
||||
* and the updateVisibleTiles tries to meet civs...
|
||||
* And if they civs on't yet know who they are then they don;t know if they're barbarians =\
|
||||
* */
|
||||
fun setNationTransient(){
|
||||
|
@ -6,7 +6,6 @@ import com.unciv.Constants
|
||||
import com.unciv.logic.map.RoadStatus
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tech.Technology
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.models.gamebasics.unit.BaseUnit
|
||||
import com.unciv.ui.utils.withItem
|
||||
import java.util.*
|
||||
@ -202,8 +201,14 @@ class TechManager {
|
||||
}
|
||||
|
||||
fun updateTransientBooleans(){
|
||||
if(researchedTechUniques.contains("Enables embarkation for land units")) unitsCanEmbark=true
|
||||
if(researchedTechUniques.contains("Enables embarked units to enter ocean tiles")) embarkedUnitsCanEnterOcean=true
|
||||
if(researchedTechUniques.contains("Enables embarkation for land units")
|
||||
|| civInfo.nation.unique=="Can embark and move over Coasts and Oceans immediately. +1 Sight when embarked. +10% Combat Strength bonus if within 2 tiles of a Moai.")
|
||||
unitsCanEmbark=true
|
||||
|
||||
if(researchedTechUniques.contains("Enables embarked units to enter ocean tiles")
|
||||
|| civInfo.nation.unique=="Can embark and move over Coasts and Oceans immediately. +1 Sight when embarked. +10% Combat Strength bonus if within 2 tiles of a Moai.")
|
||||
embarkedUnitsCanEnterOcean=true
|
||||
|
||||
if(researchedTechUniques.contains("Improves movement speed on roads")) movementSpeedOnRoadsImproved = true
|
||||
}
|
||||
|
||||
|
@ -126,8 +126,7 @@ class MapUnit {
|
||||
return getUniques().contains(unique)
|
||||
}
|
||||
|
||||
// we need to map all the places that this could change: Unit changes locations, owners, gets promotion?
|
||||
fun updateViewableTiles() {
|
||||
fun updateVisibleTiles() {
|
||||
if(type.isAirUnit()){
|
||||
if(hasUnique("6 tiles in every direction always visible"))
|
||||
viewableTiles = getTile().getTilesInDistance(6) // it's that simple
|
||||
@ -142,6 +141,8 @@ class MapUnit {
|
||||
if (type.isWaterUnit() && !type.isCivilian()
|
||||
&& civInfo.containsBuildingUnique("All military naval units receive +1 movement and +1 sight"))
|
||||
visibilityRange += 1
|
||||
if (isEmbarked() && civInfo.nation.unique == "Can embark and move over Coasts and Oceans immediately. +1 Sight when embarked. +10% Combat Strength bonus if within 2 tiles of a Moai.")
|
||||
visibilityRange += 1
|
||||
val tile = getTile()
|
||||
if (tile.baseTerrain == Constants.hill && type.isLandUnit()) visibilityRange += 1
|
||||
|
||||
@ -409,7 +410,7 @@ class MapUnit {
|
||||
clearEncampment(tile)
|
||||
|
||||
currentTile = tile
|
||||
updateViewableTiles()
|
||||
updateVisibleTiles()
|
||||
}
|
||||
|
||||
fun putInTile(tile:TileInfo){
|
||||
|
@ -187,6 +187,9 @@ open class TileInfo {
|
||||
stats.add(improvement) // again, for the double effect
|
||||
if (containsGreatImprovement() && city != null && city.civInfo.nation.unique == "+2 Science for all specialists and Great Person tile improvements")
|
||||
stats.science += 2
|
||||
|
||||
if(improvement.uniques.contains("+1 additional Culture for each adjacent Moai"))
|
||||
stats.culture += neighbors.count{it.improvement=="Moai"}
|
||||
}
|
||||
|
||||
if(city!=null && isWater && city.containsBuildingUnique("+1 gold from worked water tiles in city"))
|
||||
|
@ -27,9 +27,9 @@ class UnitPromotions{
|
||||
unit.updateUniques()
|
||||
|
||||
// Since some units get promotions upon construction, they will get the addPromotion from the unit.postBuildEvent
|
||||
// upon creation, BEFORE they are assigned to a tile, so the updateViewableTiles() would crash.
|
||||
// upon creation, BEFORE they are assigned to a tile, so the updateVisibleTiles() would crash.
|
||||
// So, if the addPromotion was triggered from there, simply don't update
|
||||
unit.updateViewableTiles() // some promotions/uniques give the unit bonus sight
|
||||
unit.updateVisibleTiles() // some promotions/uniques give the unit bonus sight
|
||||
}
|
||||
|
||||
fun getAvailablePromotions(): List<Promotion> {
|
||||
|
@ -162,10 +162,7 @@ class BaseUnit : INamed, IConstruction, ICivilopedia {
|
||||
}
|
||||
|
||||
fun getDirectUpgradeUnit(civInfo: CivilizationInfo):BaseUnit{
|
||||
val uniqueUnitReplacesUpgrade: BaseUnit? = GameBasics.Units.values
|
||||
.firstOrNull{it.uniqueTo==civInfo.civName && it.replaces == upgradesTo}
|
||||
if(uniqueUnitReplacesUpgrade!=null) return uniqueUnitReplacesUpgrade
|
||||
return GameBasics.Units[upgradesTo!!]!!
|
||||
return civInfo.getEquivalentUnit(upgradesTo!!)
|
||||
}
|
||||
|
||||
override fun toString(): String = name
|
||||
|
@ -17,6 +17,7 @@ class GameSettings {
|
||||
var tileSet:String = "FantasyHex"
|
||||
var showTutorials: Boolean = true
|
||||
var autoAssignCityProduction: Boolean = true
|
||||
var autoBuildingRoads: Boolean = true
|
||||
var showMinimap: Boolean = true
|
||||
|
||||
var userName:String=""
|
||||
|
@ -10,8 +10,9 @@ import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.utils.*
|
||||
|
||||
class NationTable(val nation: Nation, width:Float, onClick:()->Unit)
|
||||
: Table(CameraStageBaseScreen.skin){
|
||||
: Table(CameraStageBaseScreen.skin) {
|
||||
private val innerTable = Table()
|
||||
|
||||
init {
|
||||
background = ImageGetter.getBackground(nation.getInnerColor())
|
||||
innerTable.pad(10f)
|
||||
@ -39,58 +40,76 @@ class NationTable(val nation: Nation, width:Float, onClick:()->Unit)
|
||||
textList += ""
|
||||
}
|
||||
|
||||
for (building in GameBasics.Buildings.values)
|
||||
if (building.uniqueTo == nation.name) {
|
||||
val originalBuilding = GameBasics.Buildings[building.replaces!!]!!
|
||||
|
||||
textList += building.name.tr() + " - {replaces} " + originalBuilding.name.tr()
|
||||
val originalBuildingStatMap = originalBuilding.toHashMap()
|
||||
for (stat in building.toHashMap())
|
||||
if (stat.value != originalBuildingStatMap[stat.key])
|
||||
textList += " " + stat.key.toString().tr() + " " + stat.value.toInt() + " vs " + originalBuildingStatMap[stat.key]!!.toInt()
|
||||
|
||||
for (unique in building.uniques.filter { it !in originalBuilding.uniques })
|
||||
textList += " " + unique.tr()
|
||||
if (building.maintenance != originalBuilding.maintenance)
|
||||
textList += " {Maintenance} " + building.maintenance + " vs " + originalBuilding.maintenance
|
||||
if (building.cost != originalBuilding.cost)
|
||||
textList += " {Cost} " + building.cost + " vs " + originalBuilding.cost
|
||||
if (building.cityStrength != originalBuilding.cityStrength)
|
||||
textList += " {City strength} " + building.cityStrength + " vs " + originalBuilding.cityStrength
|
||||
if (building.cityHealth != originalBuilding.cityHealth)
|
||||
textList += " {City health} " + building.cityHealth + " vs " + originalBuilding.cityHealth
|
||||
textList += ""
|
||||
}
|
||||
|
||||
for (unit in GameBasics.Units.values)
|
||||
if (unit.uniqueTo == nation.name) {
|
||||
val originalUnit = GameBasics.Units[unit.replaces!!]!!
|
||||
|
||||
textList += unit.name.tr() + " - {replaces} " + originalUnit.name.tr()
|
||||
if (unit.cost != originalUnit.cost)
|
||||
textList += " {Cost} " + unit.cost + " vs " + originalUnit.cost
|
||||
if (unit.strength != originalUnit.strength)
|
||||
textList += " {Strength} " + unit.strength + " vs " + originalUnit.strength
|
||||
if (unit.rangedStrength != originalUnit.rangedStrength)
|
||||
textList += " {Ranged strength} " + unit.rangedStrength + " vs " + originalUnit.rangedStrength
|
||||
if (unit.range != originalUnit.range)
|
||||
textList += " {Range} " + unit.range + " vs " + originalUnit.range
|
||||
if (unit.movement != originalUnit.movement)
|
||||
textList += " {Movement} " + unit.movement + " vs " + originalUnit.movement
|
||||
if (originalUnit.requiredResource != null && unit.requiredResource == null)
|
||||
textList += " " + "[${originalUnit.requiredResource}] not required".tr()
|
||||
for (unique in unit.uniques.filterNot { it in originalUnit.uniques })
|
||||
textList += " " + Translations.translateBonusOrPenalty(unique)
|
||||
for(unique in originalUnit.uniques.filterNot { it in unit.uniques })
|
||||
textList += " "+"Lost ability".tr()+"(vs "+originalUnit.name.tr()+"): "+Translations.translateBonusOrPenalty(unique)
|
||||
for (promotion in unit.promotions.filter { it !in originalUnit.promotions })
|
||||
textList += " " + promotion.tr() + " (" + Translations.translateBonusOrPenalty(GameBasics.UnitPromotions[promotion]!!.effect) + ")"
|
||||
|
||||
textList += ""
|
||||
}
|
||||
|
||||
addUniqueBuildingsText(nation, textList)
|
||||
addUniqueUnitsText(nation, textList)
|
||||
addUniqueImprovementsText(nation, textList)
|
||||
|
||||
return textList.joinToString("\n").tr().trim().toLabel()
|
||||
}
|
||||
|
||||
private fun addUniqueBuildingsText(nation: Nation, textList: ArrayList<String>) {
|
||||
for (building in GameBasics.Buildings.values
|
||||
.filter { it.uniqueTo == nation.name }) {
|
||||
val originalBuilding = GameBasics.Buildings[building.replaces!!]!!
|
||||
|
||||
textList += building.name.tr() + " - {replaces} " + originalBuilding.name.tr()
|
||||
val originalBuildingStatMap = originalBuilding.toHashMap()
|
||||
for (stat in building.toHashMap())
|
||||
if (stat.value != originalBuildingStatMap[stat.key])
|
||||
textList += " " + stat.key.toString().tr() + " " + stat.value.toInt() + " vs " + originalBuildingStatMap[stat.key]!!.toInt()
|
||||
|
||||
for (unique in building.uniques.filter { it !in originalBuilding.uniques })
|
||||
textList += " " + unique.tr()
|
||||
if (building.maintenance != originalBuilding.maintenance)
|
||||
textList += " {Maintenance} " + building.maintenance + " vs " + originalBuilding.maintenance
|
||||
if (building.cost != originalBuilding.cost)
|
||||
textList += " {Cost} " + building.cost + " vs " + originalBuilding.cost
|
||||
if (building.cityStrength != originalBuilding.cityStrength)
|
||||
textList += " {City strength} " + building.cityStrength + " vs " + originalBuilding.cityStrength
|
||||
if (building.cityHealth != originalBuilding.cityHealth)
|
||||
textList += " {City health} " + building.cityHealth + " vs " + originalBuilding.cityHealth
|
||||
textList += ""
|
||||
}
|
||||
}
|
||||
|
||||
private fun addUniqueUnitsText(nation: Nation, textList: ArrayList<String>) {
|
||||
for (unit in GameBasics.Units.values
|
||||
.filter { it.uniqueTo == nation.name }) {
|
||||
val originalUnit = GameBasics.Units[unit.replaces!!]!!
|
||||
|
||||
textList += unit.name.tr() + " - {replaces} " + originalUnit.name.tr()
|
||||
if (unit.cost != originalUnit.cost)
|
||||
textList += " {Cost} " + unit.cost + " vs " + originalUnit.cost
|
||||
if (unit.strength != originalUnit.strength)
|
||||
textList += " {Strength} " + unit.strength + " vs " + originalUnit.strength
|
||||
if (unit.rangedStrength != originalUnit.rangedStrength)
|
||||
textList += " {Ranged strength} " + unit.rangedStrength + " vs " + originalUnit.rangedStrength
|
||||
if (unit.range != originalUnit.range)
|
||||
textList += " {Range} " + unit.range + " vs " + originalUnit.range
|
||||
if (unit.movement != originalUnit.movement)
|
||||
textList += " {Movement} " + unit.movement + " vs " + originalUnit.movement
|
||||
if (originalUnit.requiredResource != null && unit.requiredResource == null)
|
||||
textList += " " + "[${originalUnit.requiredResource}] not required".tr()
|
||||
for (unique in unit.uniques.filterNot { it in originalUnit.uniques })
|
||||
textList += " " + Translations.translateBonusOrPenalty(unique)
|
||||
for (unique in originalUnit.uniques.filterNot { it in unit.uniques })
|
||||
textList += " " + "Lost ability".tr() + "(vs " + originalUnit.name.tr() + "): " + Translations.translateBonusOrPenalty(unique)
|
||||
for (promotion in unit.promotions.filter { it !in originalUnit.promotions })
|
||||
textList += " " + promotion.tr() + " (" + Translations.translateBonusOrPenalty(GameBasics.UnitPromotions[promotion]!!.effect) + ")"
|
||||
|
||||
textList += ""
|
||||
}
|
||||
}
|
||||
|
||||
private fun addUniqueImprovementsText(nation: Nation, textList: ArrayList<String>) {
|
||||
for (improvement in GameBasics.TileImprovements.values
|
||||
.filter { it.uniqueTo == nation.name }) {
|
||||
|
||||
textList += improvement.name.tr()
|
||||
textList += " "+improvement.clone().toString()
|
||||
for(unique in improvement.uniques)
|
||||
textList += " "+unique.tr()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -43,8 +43,10 @@ class TechButton(techName:String, val techManager: TechManager, isWorldScreen: B
|
||||
val techEnabledIcons = Table()
|
||||
techEnabledIcons.defaults().pad(5f)
|
||||
|
||||
val civName = techManager.civInfo.civName
|
||||
|
||||
val techEnabledUnits = GameBasics.Units.values.filter { it.requiredTech == techName }
|
||||
val ourUniqueUnits = techEnabledUnits.filter { it.uniqueTo == techManager.civInfo.civName }
|
||||
val ourUniqueUnits = techEnabledUnits.filter { it.uniqueTo == civName }
|
||||
val replacedUnits = ourUniqueUnits.map { it.replaces!! }
|
||||
val ourEnabledUnits = techEnabledUnits.filter { it.uniqueTo == null && !replacedUnits.contains(it.name) }
|
||||
.union(ourUniqueUnits)
|
||||
@ -53,15 +55,18 @@ class TechButton(techName:String, val techManager: TechManager, isWorldScreen: B
|
||||
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 ourUniqueBuildings = techEnabledBuildings.filter { it.uniqueTo == 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)
|
||||
techEnabledIcons.add(ImageGetter.getConstructionImage(building.name).surroundWithCircle(30f))
|
||||
|
||||
for (improvement in GameBasics.TileImprovements.values.filter { it.techRequired == techName || it.improvingTech == techName }) {
|
||||
for (improvement in GameBasics.TileImprovements.values
|
||||
.filter { it.techRequired == techName || it.improvingTech == techName }
|
||||
.filter { it.uniqueTo==null || it.uniqueTo==civName }) {
|
||||
if (improvement.name.startsWith("Remove"))
|
||||
techEnabledIcons.add(ImageGetter.getImage("OtherIcons/Stop")).size(30f)
|
||||
else techEnabledIcons.add(ImageGetter.getImprovementIcon(improvement.name, 30f))
|
||||
|
@ -80,6 +80,12 @@ class WorldScreenOptionsTable(val worldScreen:WorldScreen) : PopupTable(worldScr
|
||||
update()
|
||||
}
|
||||
|
||||
innerTable.add("Auto-build roads".toLabel())
|
||||
innerTable.addButton(if(settings.autoBuildingRoads) "Yes".tr() else "No".tr()) {
|
||||
settings.autoBuildingRoads= !settings.autoBuildingRoads
|
||||
update()
|
||||
}
|
||||
|
||||
innerTable.add("Show minimap".toLabel())
|
||||
innerTable.addButton(if(settings.showMinimap) "Yes".tr() else "No".tr()) {
|
||||
settings.showMinimap= !settings.showMinimap
|
||||
|
@ -99,7 +99,7 @@ class UnitActions {
|
||||
newunit.promotions.addPromotion(promotion, true)
|
||||
|
||||
newunit.updateUniques()
|
||||
newunit.updateViewableTiles()
|
||||
newunit.updateVisibleTiles()
|
||||
newunit.currentMovement = 0f
|
||||
worldScreen.shouldUpdate = true
|
||||
}.sound("upgrade")
|
||||
|
Loading…
x
Reference in New Issue
Block a user