mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 22:37:02 -04:00
Organized unit image credits
Sea civilian units are now universally recognized as civilian units
This commit is contained in:
parent
1111a23c14
commit
a855bc0e7b
89
Credits.md
89
Credits.md
@ -9,60 +9,79 @@ All the following are from [the Noun Project](https://thenounproject.com) licenc
|
|||||||
|
|
||||||
## Units
|
## Units
|
||||||
|
|
||||||
* [Sword](https://thenounproject.com/search/?q=Sword&i=1215443) By Guilherme Furtado
|
### Ancient Era
|
||||||
* [Sword](https://thenounproject.com/search/?q=Sword&i=1432662) By uzeir syarief
|
|
||||||
* [Flag](https://thenounproject.com/search/?q=Flag&i=50114) By Melvin Poppelaars
|
* [Hammer](https://thenounproject.com/search/?q=Hammer&i=667666) By Hea Poh Lin for Worker
|
||||||
* [Eagle](https://thenounproject.com/search/?q=Eagle&i=1619932) By anggun
|
* [Flag](https://thenounproject.com/search/?q=Flag&i=50114) By Melvin Poppelaars for Settler
|
||||||
* [Bow And Arrow](https://thenounproject.com/search/?q=Bow%20and%20Arrow&i=338261) By Viktor Ostrovsky
|
* [Eagle](https://thenounproject.com/search/?q=Eagle&i=1619932) By anggun for Scout
|
||||||
* [Chariot](https://thenounproject.com/search/?q=Chariot&i=1189930) By Andrew Doane
|
* [Axe](https://thenounproject.com/search/?q=Axe&i=1688143) By ehab.abdullah for Warrior
|
||||||
* [Pallet](https://thenounproject.com/search/?q=Pallet&i=6862) By James Keuning
|
* [Bow And Arrow](https://thenounproject.com/search/?q=Bow%20and%20Arrow&i=338261) By Viktor Ostrovsky for Archer
|
||||||
* [Gear](https://thenounproject.com/search/?q=Gear&i=17369) By Melvin Salas
|
* [Bow](https://thenounproject.com/search/?q=bow&i=101736) By Arthur Shlain for Bowman
|
||||||
* [Beaker](https://thenounproject.com/search/?q=Beaker&i=621510) By Delwar Hossain
|
* Work Boats
|
||||||
* [Horse](https://thenounproject.com/search/?q=Horse&i=1373793) By AFY Studio
|
* [Chariot](https://thenounproject.com/search/?q=Chariot&i=1189930) By Andrew Doane for Chariot Archer
|
||||||
* [Axe](https://thenounproject.com/search/?q=Axe&i=1688143) By ehab.abdullah
|
* [Spear](https://thenounproject.com/search/?q=Spear&i=11432) By Stephen Copinger for Spearman
|
||||||
* [Hammer](https://thenounproject.com/search/?q=Hammer&i=667666) By Hea Poh Lin
|
|
||||||
* [Spear](https://thenounproject.com/search/?q=Spear&i=11432) By Stephen Copinger
|
### Classical Era
|
||||||
* [Spear](https://thenounproject.com/search/?q=Spear&i=1233840) By Alvaro Cabrera
|
|
||||||
* [Catapult](https://thenounproject.com/search/?q=Spear&i=1233840) By Jakub Ukrop
|
* [Catapult](https://thenounproject.com/search/?q=Spear&i=1233840) By Jakub Ukrop
|
||||||
* [Crossbow](https://thenounproject.com/term/crossbow/965389/) By Creaticca Creative Agency
|
* [Unloaded Crossbow](https://thenounproject.com/term/unloaded-crossbow/815992/) By Hamish as Ballista
|
||||||
|
* [Sword](https://thenounproject.com/search/?q=Sword&i=1215443) By Guilherme Furtado for Swordsman
|
||||||
|
* [Horse](https://thenounproject.com/search/?q=Horse&i=1373793) By AFY Studio for Horseman
|
||||||
|
* [Horse Head](https://thenounproject.com/search/?q=Cavalry&i=374037) By Juan Pablo Bravo for Companion Cavalry
|
||||||
|
|
||||||
|
### Medieval Era
|
||||||
|
|
||||||
|
* [Crossbow](https://thenounproject.com/term/crossbow/965389/) By Creaticca Creative Agency for Crossbowman
|
||||||
|
* [Longbow](https://thenounproject.com/search/?q=longbow&i=815991) By Hamish for Longbowman
|
||||||
* [Trebuchet](https://thenounproject.com/search/?q=Trebuchet&i=827987) By Ben Davis
|
* [Trebuchet](https://thenounproject.com/search/?q=Trebuchet&i=827987) By Ben Davis
|
||||||
|
* [Sword](https://thenounproject.com/search/?q=Sword&i=1432662) By uzeir syarief for Longswordsman
|
||||||
|
* [Spear](https://thenounproject.com/search/?q=Spear&i=1233840) By Alvaro Cabrera for Pikeman
|
||||||
* [Knight](https://thenounproject.com/search/?q=Knight&i=30912) By Tyler Glaude
|
* [Knight](https://thenounproject.com/search/?q=Knight&i=30912) By Tyler Glaude
|
||||||
* [Lance](https://thenounproject.com/search/?q=Lance&i=440122) By parkjisun
|
|
||||||
* [Musket](https://thenounproject.com/search/?q=Musket&i=298302) By Cezary Lopacinski
|
### Renaissance Era
|
||||||
|
|
||||||
* [Cannon](https://thenounproject.com/search/?q=Cannon&i=1618747) By Orin Zuu
|
* [Cannon](https://thenounproject.com/search/?q=Cannon&i=1618747) By Orin Zuu
|
||||||
* [Bow](https://thenounproject.com/search/?q=bow&i=101736) By Arthur Shlain
|
* [Musket](https://thenounproject.com/search/?q=Musket&i=298302) By Cezary Lopacinski for Musketman
|
||||||
* [Longbow](https://thenounproject.com/search/?q=longbow&i=815991) By Hamish
|
* [Rapier](https://thenounproject.com/search/?q=musketeer&i=819822) By Hamish for Musketeer
|
||||||
* [Horse Head](https://thenounproject.com/search/?q=Cavalry&i=374037) By Juan Pablo Bravo
|
* [Lance](https://thenounproject.com/search/?q=Lance&i=440122) By parkjisun for Lancer
|
||||||
* [Rifle](https://thenounproject.com/search/?q=Rifle&i=604291) By Chameleon Design
|
|
||||||
* [Horse](https://thenounproject.com/search/?q=Horse&i=1023745) By Bakunetso Kaito
|
### Industrial
|
||||||
|
|
||||||
|
* [Rifle](https://thenounproject.com/search/?q=Rifle&i=604291) By Chameleon Design for Rifleman
|
||||||
|
* [Horse](https://thenounproject.com/search/?q=Horse&i=1023745) By Bakunetso Kaito for Cavalry
|
||||||
* [Artillery](https://thenounproject.com/search/?q=Artillery&i=1165261) By Creative Mania
|
* [Artillery](https://thenounproject.com/search/?q=Artillery&i=1165261) By Creative Mania
|
||||||
* [Rapier](https://thenounproject.com/search/?q=musketeer&i=819822) By Hamish
|
|
||||||
* [Unloaded Crossbow](https://thenounproject.com/term/unloaded-crossbow/815992/) By Hamish
|
### Great People
|
||||||
|
|
||||||
|
* [Pallet](https://thenounproject.com/search/?q=Pallet&i=6862) By James Keuning for Great Artist
|
||||||
|
* [Gear](https://thenounproject.com/search/?q=Gear&i=17369) By Melvin Salas for Great Engineer
|
||||||
|
* [Beaker](https://thenounproject.com/search/?q=Beaker&i=621510) By Delwar Hossain for Great Scientist
|
||||||
|
|
||||||
|
|
||||||
## Resources
|
## Resources
|
||||||
|
|
||||||
* [Saffron](https://thenounproject.com/term/saffron/1576606/) By parkjisun
|
* [Saffron](https://thenounproject.com/term/saffron/1576606/) By parkjisun for Dye
|
||||||
* [Can](https://thenounproject.com/term/can/708971/) By Nick Bluth
|
* [Can](https://thenounproject.com/term/can/708971/) By Nick Bluth for Aluminum
|
||||||
* [Coal](https://thenounproject.com/term/coal/213892/) By Michael Wohlwend
|
* [Coal](https://thenounproject.com/term/coal/213892/) By Michael Wohlwend
|
||||||
* [Anvil](https://thenounproject.com/term/anvil/166414/) By Jason Dilworth
|
* [Anvil](https://thenounproject.com/term/anvil/166414/) By Jason Dilworth for Iron
|
||||||
* [Deer](https://thenounproject.com/term/deer/338013/) By Richard Nixon
|
* [Deer](https://thenounproject.com/term/deer/338013/) By Richard Nixon
|
||||||
* [Banana](https://thenounproject.com/term/banana/1262865/) By Adrian Coquet
|
* [Banana](https://thenounproject.com/term/banana/1262865/) By Adrian Coquet
|
||||||
* [Oil](https://thenounproject.com/term/oil/88649/) By Tiago Maricate
|
* [Oil](https://thenounproject.com/term/oil/88649/) By Tiago Maricate
|
||||||
* [Statue](https://thenounproject.com/term/statue/5221/) By Joris Hoogendoorn
|
* [Statue](https://thenounproject.com/term/statue/5221/) By Joris Hoogendoorn for Marble
|
||||||
* [Ribbon](https://thenounproject.com/term/ribbon/418996) By Anton
|
* [Ribbon](https://thenounproject.com/term/ribbon/418996) By Anton for Silk
|
||||||
* [Stone](https://thenounproject.com/term/stone/1373902/) By AFY Studio
|
* [Stone](https://thenounproject.com/term/stone/1373902/) By AFY Studio
|
||||||
* [Goblet](https://thenounproject.com/term/goblet/1005208/) By Pedro Santos
|
* [Goblet](https://thenounproject.com/term/goblet/1005208/) By Pedro Santos for Silver
|
||||||
* [Sugar](https://thenounproject.com/term/sugar/1689203/) By ahmad
|
* [Sugar](https://thenounproject.com/term/sugar/1689203/) By ahmad
|
||||||
* [Spice](https://thenounproject.com/term/spice/1689206/) By ahmad
|
* [Spice](https://thenounproject.com/term/spice/1689206/) By ahmad
|
||||||
* [Radiation symbol](https://thenounproject.com/term/radiation-symbol/211059/) By icon 54
|
* [Radiation symbol](https://thenounproject.com/term/radiation-symbol/211059/) By icon 54 for Uranium
|
||||||
* [Wine](https://thenounproject.com/term/wine/1290951/) By Adrien Coquet
|
* [Wine](https://thenounproject.com/term/wine/1290951/) By Adrien Coquet
|
||||||
* [Wheat](https://thenounproject.com/term/wheat/1048428/) By Juraj Sedlak
|
* [Wheat](https://thenounproject.com/term/wheat/1048428/) By Juraj Sedlak
|
||||||
* [Sheep](https://thenounproject.com/term/sheep/8389/) By Unrecognized
|
* [Sheep](https://thenounproject.com/term/sheep/8389/) By Unrecognized
|
||||||
* [Elephant](https://thenounproject.com/term/elephant/1853192/) By Kelsey Armstrong
|
* [Elephant](https://thenounproject.com/term/elephant/1853192/) By Kelsey Armstrong for Ivory
|
||||||
* [Cattle](https://thenounproject.com/term/cattle/781342/) By Daniela Baptista
|
* [Cattle](https://thenounproject.com/term/cattle/781342/) By Daniela Baptista
|
||||||
* [Leather](https://thenounproject.com/term/leather/16499/) By Alen Krummenacher
|
* [Leather](https://thenounproject.com/term/leather/16499/) By Alen Krummenacher for Furs
|
||||||
* [Gem](https://thenounproject.com/term/gem/948920/) By Lluisa Iborra
|
* [Gem](https://thenounproject.com/term/gem/948920/) By Lluisa Iborra
|
||||||
* [Joss Stick](https://thenounproject.com/search/?q=incense&i=583033) By Hea Poh Lin
|
* [Joss Stick](https://thenounproject.com/search/?q=incense&i=583033) By Hea Poh Lin for Incense
|
||||||
|
|
||||||
## Improvements
|
## Improvements
|
||||||
|
|
||||||
@ -74,7 +93,7 @@ All the following are from [the Noun Project](https://thenounproject.com) licenc
|
|||||||
* [Academy](https://thenounproject.com/term/academy/1689703/) By CJS
|
* [Academy](https://thenounproject.com/term/academy/1689703/) By CJS
|
||||||
* [Factory](https://thenounproject.com/term/factory/1049531/) By RULI
|
* [Factory](https://thenounproject.com/term/factory/1049531/) By RULI
|
||||||
* [Mine](https://thenounproject.com/term/mine/543/) By Edward Boatman
|
* [Mine](https://thenounproject.com/term/mine/543/) By Edward Boatman
|
||||||
* [Corral](https://thenounproject.com/term/corral/1340751/) By Luis Prado
|
* [Corral](https://thenounproject.com/term/corral/1340751/) By Luis Prado for Pasture
|
||||||
* [Plants](https://thenounproject.com/term/plants/1760916/) By hendra sudibyo
|
* [Plants](https://thenounproject.com/term/plants/1760916/) By hendra sudibyo
|
||||||
* [Pickaxe](https://thenounproject.com/term/pickaxe/175792/) By Creative Stall
|
* [Pickaxe](https://thenounproject.com/term/pickaxe/175792/) By Creative Stall
|
||||||
* [Food stall](https://thenounproject.com/term/food-stall/1618358/) By I Putu Kharismayadi
|
* [Food stall](https://thenounproject.com/term/food-stall/1618358/) By I Putu Kharismayadi
|
||||||
|
@ -5,6 +5,7 @@ import com.unciv.logic.GameInfo
|
|||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
import com.unciv.logic.map.TileMap
|
import com.unciv.logic.map.TileMap
|
||||||
import com.unciv.models.gamebasics.GameBasics
|
import com.unciv.models.gamebasics.GameBasics
|
||||||
|
import com.unciv.models.gamebasics.tile.TerrainType
|
||||||
import com.unciv.ui.NewGameScreen
|
import com.unciv.ui.NewGameScreen
|
||||||
import com.unciv.ui.utils.getRandom
|
import com.unciv.ui.utils.getRandom
|
||||||
|
|
||||||
@ -24,7 +25,9 @@ class GameStarter(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
val distanceAroundStartingPointNoOneElseWillStartIn = 5
|
val distanceAroundStartingPointNoOneElseWillStartIn = 5
|
||||||
val freeTiles = gameInfo.tileMap.values.toMutableList().filter { vectorIsWithinNTilesOfEdge(it.position,3)}.toMutableList()
|
val freeTiles = gameInfo.tileMap.values
|
||||||
|
.filter { it.getBaseTerrain().type==TerrainType.Land && vectorIsWithinNTilesOfEdge(it.position,3)}
|
||||||
|
.toMutableList()
|
||||||
val playerPosition = freeTiles.getRandom().position
|
val playerPosition = freeTiles.getRandom().position
|
||||||
val playerCiv = CivilizationInfo(newGameParameters.nation, gameInfo)
|
val playerCiv = CivilizationInfo(newGameParameters.nation, gameInfo)
|
||||||
playerCiv.difficulty=newGameParameters.difficulty
|
playerCiv.difficulty=newGameParameters.difficulty
|
||||||
@ -63,15 +66,6 @@ class GameStarter(){
|
|||||||
freeTiles.removeAll(gameInfo.tileMap.getTilesInDistance(startingLocation, distanceAroundStartingPointNoOneElseWillStartIn ))
|
freeTiles.removeAll(gameInfo.tileMap.getTilesInDistance(startingLocation, distanceAroundStartingPointNoOneElseWillStartIn ))
|
||||||
}
|
}
|
||||||
|
|
||||||
(1..5).forEach {
|
|
||||||
val freeTilesList = freeTiles.toList()
|
|
||||||
if(freeTilesList.isNotEmpty()){
|
|
||||||
val placedTile = freeTilesList.getRandom()
|
|
||||||
gameInfo.placeBarbarianUnit(placedTile)
|
|
||||||
freeTiles.remove(placedTile)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return gameInfo
|
return gameInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,12 +7,12 @@ import kotlin.math.max
|
|||||||
|
|
||||||
class HexMath {
|
class HexMath {
|
||||||
|
|
||||||
fun GetVectorForAngle(angle: Float): Vector2 {
|
private fun getVectorForAngle(angle: Float): Vector2 {
|
||||||
return Vector2(Math.sin(angle.toDouble()).toFloat(), Math.cos(angle.toDouble()).toFloat())
|
return Vector2(Math.sin(angle.toDouble()).toFloat(), Math.cos(angle.toDouble()).toFloat())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun GetVectorByClockHour(hour: Int): Vector2 {
|
private fun getVectorByClockHour(hour: Int): Vector2 {
|
||||||
return GetVectorForAngle((2 * Math.PI * (hour / 12f)).toFloat())
|
return getVectorForAngle((2 * Math.PI * (hour / 12f)).toFloat())
|
||||||
}
|
}
|
||||||
|
|
||||||
// HexCoordinates are a (x,y) vector, where x is the vector getting us to the top-left hex (e.g. 10 o'clock)
|
// HexCoordinates are a (x,y) vector, where x is the vector getting us to the top-left hex (e.g. 10 o'clock)
|
||||||
@ -22,54 +22,54 @@ class HexMath {
|
|||||||
// For example, to get to the cell above me, I'll use a (1,1) vector.
|
// For example, to get to the cell above me, I'll use a (1,1) vector.
|
||||||
// To get to the cell below the cell to my bottom-right, I'll use a (-1,-2) vector.
|
// To get to the cell below the cell to my bottom-right, I'll use a (-1,-2) vector.
|
||||||
|
|
||||||
fun Hex2WorldCoords(hexCoord: Vector2): Vector2 {
|
fun hex2WorldCoords(hexCoord: Vector2): Vector2 {
|
||||||
// Distance between cells = 2* normal of triangle = 2* (sqrt(3)/2) = sqrt(3)
|
// Distance between cells = 2* normal of triangle = 2* (sqrt(3)/2) = sqrt(3)
|
||||||
val xVector = GetVectorByClockHour(10).scl(Math.sqrt(3.0).toFloat())
|
val xVector = getVectorByClockHour(10).scl(Math.sqrt(3.0).toFloat())
|
||||||
val yVector = GetVectorByClockHour(2).scl(Math.sqrt(3.0).toFloat())
|
val yVector = getVectorByClockHour(2).scl(Math.sqrt(3.0).toFloat())
|
||||||
return xVector.scl(hexCoord.x).add(yVector.scl(hexCoord.y))
|
return xVector.scl(hexCoord.x).add(yVector.scl(hexCoord.y))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun GetAdjacentVectors(origin: Vector2): ArrayList<Vector2> {
|
fun getAdjacentVectors(origin: Vector2): ArrayList<Vector2> {
|
||||||
val vectors = ArrayList<Vector2>()
|
val vectors = ArrayList<Vector2>()
|
||||||
vectors.add(Vector2(1f, 0f))
|
vectors += Vector2(1f, 0f)
|
||||||
vectors.add(Vector2(1f, 1f))
|
vectors += Vector2(1f, 1f)
|
||||||
vectors.add(Vector2(0f, 1f))
|
vectors += Vector2(0f, 1f)
|
||||||
vectors.add(Vector2(-1f, 0f))
|
vectors += Vector2(-1f, 0f)
|
||||||
vectors.add(Vector2(-1f, -1f))
|
vectors += Vector2(-1f, -1f)
|
||||||
vectors.add(Vector2(0f, -1f))
|
vectors += Vector2(0f, -1f)
|
||||||
for (vector in vectors) vector.add(origin)
|
for (vector in vectors) vector.add(origin)
|
||||||
return vectors
|
return vectors
|
||||||
}
|
}
|
||||||
|
|
||||||
fun GetVectorsAtDistance(origin: Vector2, distance: Int): List<Vector2> {
|
fun getVectorsAtDistance(origin: Vector2, distance: Int): List<Vector2> {
|
||||||
val vectors = mutableListOf<Vector2>()
|
val vectors = mutableListOf<Vector2>()
|
||||||
if (distance == 0) {
|
if (distance == 0) {
|
||||||
vectors.add(origin.cpy())
|
vectors += origin.cpy()
|
||||||
return vectors
|
return vectors
|
||||||
}
|
}
|
||||||
val Current = origin.cpy().sub(distance.toFloat(), distance.toFloat()) // start at 6 o clock
|
val current = origin.cpy().sub(distance.toFloat(), distance.toFloat()) // start at 6 o clock
|
||||||
for (i in 0 until distance) { // From 6 to 8
|
for (i in 0 until distance) { // From 6 to 8
|
||||||
vectors.add(Current.cpy())
|
vectors += current.cpy()
|
||||||
vectors.add(origin.cpy().scl(2f).sub(Current)) // Get vector on other side of cloick
|
vectors += origin.cpy().scl(2f).sub(current) // Get vector on other side of cloick
|
||||||
Current.add(1f, 0f)
|
current.add(1f, 0f)
|
||||||
}
|
}
|
||||||
for (i in 0 until distance) { // 8 to 10
|
for (i in 0 until distance) { // 8 to 10
|
||||||
vectors.add(Current.cpy())
|
vectors += current.cpy()
|
||||||
vectors.add(origin.cpy().scl(2f).sub(Current)) // Get vector on other side of clock
|
vectors += origin.cpy().scl(2f).sub(current) // Get vector on other side of clock
|
||||||
Current.add(1f, 1f)
|
current.add(1f, 1f)
|
||||||
}
|
}
|
||||||
for (i in 0 until distance) { // 10 to 12
|
for (i in 0 until distance) { // 10 to 12
|
||||||
vectors.add(Current.cpy())
|
vectors += current.cpy()
|
||||||
vectors.add(origin.cpy().scl(2f).sub(Current)) // Get vector on other side of clock
|
vectors += origin.cpy().scl(2f).sub(current) // Get vector on other side of clock
|
||||||
Current.add(0f, 1f)
|
current.add(0f, 1f)
|
||||||
}
|
}
|
||||||
return vectors
|
return vectors
|
||||||
}
|
}
|
||||||
|
|
||||||
fun GetVectorsInDistance(origin: Vector2, distance: Int): List<Vector2> {
|
fun getVectorsInDistance(origin: Vector2, distance: Int): List<Vector2> {
|
||||||
val hexesToReturn = mutableListOf<Vector2>()
|
val hexesToReturn = mutableListOf<Vector2>()
|
||||||
for (i in 0 .. distance) {
|
for (i in 0 .. distance) {
|
||||||
hexesToReturn.addAll(GetVectorsAtDistance(origin, i))
|
hexesToReturn += getVectorsAtDistance(origin, i)
|
||||||
}
|
}
|
||||||
return hexesToReturn
|
return hexesToReturn
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ class Automation {
|
|||||||
// Declare war?
|
// Declare war?
|
||||||
if(civInfo.cities.isNotEmpty() && civInfo.diplomacy.isNotEmpty()
|
if(civInfo.cities.isNotEmpty() && civInfo.diplomacy.isNotEmpty()
|
||||||
&& !civInfo.isAtWar()
|
&& !civInfo.isAtWar()
|
||||||
&& civInfo.getCivUnits().filter { it.baseUnit.unitType != UnitType.Civilian }.size > civInfo.cities.size*2) {
|
&& civInfo.getCivUnits().filter { !it.baseUnit.unitType.isCivilian() }.size > civInfo.cities.size*2) {
|
||||||
|
|
||||||
val enemyCivsByDistanceToOurs = civInfo.diplomacy.values.map { it.otherCiv() }
|
val enemyCivsByDistanceToOurs = civInfo.diplomacy.values.map { it.otherCiv() }
|
||||||
.filterNot { it == civInfo || it.cities.isEmpty() || !civInfo.diplomacy[it.civName]!!.canDeclareWar() }
|
.filterNot { it == civInfo || it.cities.isEmpty() || !civInfo.diplomacy[it.civName]!!.canDeclareWar() }
|
||||||
@ -142,7 +142,7 @@ class Automation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun trainCombatUnit(city: CityInfo) {
|
private fun trainCombatUnit(city: CityInfo) {
|
||||||
val combatUnits = city.cityConstructions.getConstructableUnits().filter { it.unitType != UnitType.Civilian }
|
val combatUnits = city.cityConstructions.getConstructableUnits().filter { !it.unitType.isCivilian() }
|
||||||
val chosenUnit: BaseUnit
|
val chosenUnit: BaseUnit
|
||||||
if(!city.civInfo.isAtWar() && city.civInfo.cities.any { it.getCenterTile().militaryUnit==null}
|
if(!city.civInfo.isAtWar() && city.civInfo.cities.any { it.getCenterTile().militaryUnit==null}
|
||||||
&& combatUnits.any { it.unitType== UnitType.Ranged }) // this is for city defence so get an archery unit if we can
|
&& combatUnits.any { it.unitType== UnitType.Ranged }) // this is for city defence so get an archery unit if we can
|
||||||
@ -166,7 +166,7 @@ class Automation {
|
|||||||
val buildableWonders = getBuildableBuildings().filter { it.isWonder }
|
val buildableWonders = getBuildableBuildings().filter { it.isWonder }
|
||||||
|
|
||||||
val civUnits = cityInfo.civInfo.getCivUnits()
|
val civUnits = cityInfo.civInfo.getCivUnits()
|
||||||
val militaryUnits = civUnits.filter { it.baseUnit().unitType != UnitType.Civilian }.size
|
val militaryUnits = civUnits.filter { !it.baseUnit().unitType.isCivilian()}.size
|
||||||
val workers = civUnits.filter { it.name == CityConstructions.Worker }.size
|
val workers = civUnits.filter { it.name == CityConstructions.Worker }.size
|
||||||
val cities = cityInfo.civInfo.cities.size
|
val cities = cityInfo.civInfo.cities.size
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import com.unciv.logic.civilization.DiplomaticStatus
|
|||||||
import com.unciv.logic.map.MapUnit
|
import com.unciv.logic.map.MapUnit
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.models.gamebasics.GameBasics
|
import com.unciv.models.gamebasics.GameBasics
|
||||||
|
import com.unciv.models.gamebasics.tile.TerrainType
|
||||||
import com.unciv.ui.utils.getRandom
|
import com.unciv.ui.utils.getRandom
|
||||||
import com.unciv.ui.worldscreen.unit.UnitAction
|
import com.unciv.ui.worldscreen.unit.UnitAction
|
||||||
import com.unciv.ui.worldscreen.unit.UnitActions
|
import com.unciv.ui.worldscreen.unit.UnitActions
|
||||||
@ -29,6 +30,11 @@ class UnitAutomation{
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(unit.name=="Work Boats"){
|
||||||
|
automateWorkBoats(unit)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if(unit.name.startsWith("Great")) return // I don't know what to do with you yet.
|
if(unit.name.startsWith("Great")) return // I don't know what to do with you yet.
|
||||||
|
|
||||||
val unitActions = UnitActions().getUnitActions(unit,UnCivGame.Current.worldScreen)
|
val unitActions = UnitActions().getUnitActions(unit,UnCivGame.Current.worldScreen)
|
||||||
@ -75,6 +81,26 @@ class UnitAutomation{
|
|||||||
// if both failed, then... there aren't any reachable tiles. Which is possible.
|
// if both failed, then... there aren't any reachable tiles. Which is possible.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun hasWorkableSeaResource(tileInfo: TileInfo): Boolean {
|
||||||
|
return tileInfo.resource!=null && tileInfo.getBaseTerrain().type==TerrainType.Water && tileInfo.improvement==null
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun automateWorkBoats(unit: MapUnit) {
|
||||||
|
val seaResourcesInCities = unit.civInfo.cities.flatMap { it.getTilesInRange() }
|
||||||
|
.filter { hasWorkableSeaResource(it) && (unit.canMoveTo(it) || unit.currentTile==it) }
|
||||||
|
if (seaResourcesInCities.any()) {
|
||||||
|
val reachableResource = seaResourcesInCities.asSequence().sortedBy { it.arialDistanceTo(unit.currentTile) }
|
||||||
|
.firstOrNull { unit.movementAlgs().canReach(it) }
|
||||||
|
if (reachableResource != null) {
|
||||||
|
unit.movementAlgs().headTowards(reachableResource)
|
||||||
|
if(unit.currentMovement>0 && hasWorkableSeaResource(unit.currentTile))
|
||||||
|
UnitActions().getUnitActions(unit,UnCivGame.Current.worldScreen)
|
||||||
|
.first { it.name=="Create Fishing Boats" }.action()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
explore(unit, unit.getDistanceToTiles())
|
||||||
|
}
|
||||||
|
|
||||||
fun rankTileForHealing(tileInfo: TileInfo, unit: MapUnit): Int {
|
fun rankTileForHealing(tileInfo: TileInfo, unit: MapUnit): Int {
|
||||||
val tileOwner = tileInfo.getOwner()
|
val tileOwner = tileInfo.getOwner()
|
||||||
when{
|
when{
|
||||||
@ -127,8 +153,8 @@ class UnitAutomation{
|
|||||||
for(reachableTile in tilesToAttackFrom){ // tiles we'll still have energy after we reach there
|
for(reachableTile in tilesToAttackFrom){ // tiles we'll still have energy after we reach there
|
||||||
val tilesInAttackRange = if (unit.hasUnique("Indirect fire")) reachableTile.getTilesInDistance(rangeOfAttack)
|
val tilesInAttackRange = if (unit.hasUnique("Indirect fire")) reachableTile.getTilesInDistance(rangeOfAttack)
|
||||||
else reachableTile.getViewableTiles(rangeOfAttack)
|
else reachableTile.getViewableTiles(rangeOfAttack)
|
||||||
attackableTiles += tilesInAttackRange.filter { it in tilesWithEnemies }
|
attackableTiles += tilesInAttackRange.asSequence().filter { it in tilesWithEnemies }
|
||||||
.map { AttackableTile(reachableTile,it) }
|
.map { AttackableTile(reachableTile,it) }.toList()
|
||||||
}
|
}
|
||||||
return attackableTiles
|
return attackableTiles
|
||||||
}
|
}
|
||||||
@ -150,15 +176,14 @@ class UnitAutomation{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun tryAccompanySettler(unit: MapUnit, unitDistanceToTiles: HashMap<TileInfo, Float>): Boolean {
|
private fun tryAccompanySettler(unit: MapUnit, unitDistanceToTiles: HashMap<TileInfo, Float>): Boolean {
|
||||||
val closeTileWithSettler = unitDistanceToTiles.keys.firstOrNull {
|
val settlerToAccompany = unit.civInfo.getCivUnits()
|
||||||
it.civilianUnit != null && it.civilianUnit!!.name == "Settler"
|
.firstOrNull { val tile = it.currentTile;
|
||||||
}
|
it.name=="Settler" && tile.militaryUnit==null
|
||||||
if (closeTileWithSettler != null && unit.canMoveTo(closeTileWithSettler)) {
|
&& unit.canMoveTo(tile) && unit.movementAlgs().canReach(tile) }
|
||||||
unit.movementAlgs().headTowards(closeTileWithSettler)
|
if(settlerToAccompany==null) return false
|
||||||
|
unit.movementAlgs().headTowards(settlerToAccompany.currentTile)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun tryUpgradeUnit(unit: MapUnit, unitActions: List<UnitAction>): Boolean {
|
private fun tryUpgradeUnit(unit: MapUnit, unitActions: List<UnitAction>): Boolean {
|
||||||
if (unit.baseUnit().upgradesTo != null) {
|
if (unit.baseUnit().upgradesTo != null) {
|
||||||
@ -303,11 +328,15 @@ class UnitAutomation{
|
|||||||
|
|
||||||
fun rankTileAsCityCenter(tileInfo: TileInfo, nearbyTileRankings: Map<TileInfo, Float>): Float {
|
fun rankTileAsCityCenter(tileInfo: TileInfo, nearbyTileRankings: Map<TileInfo, Float>): Float {
|
||||||
val bestTilesFromOuterLayer = tileInfo.getTilesAtDistance(2)
|
val bestTilesFromOuterLayer = tileInfo.getTilesAtDistance(2)
|
||||||
|
.asSequence()
|
||||||
.sortedByDescending { nearbyTileRankings[it] }.take(2)
|
.sortedByDescending { nearbyTileRankings[it] }.take(2)
|
||||||
|
.toList()
|
||||||
val top5Tiles = tileInfo.neighbors.union(bestTilesFromOuterLayer)
|
val top5Tiles = tileInfo.neighbors.union(bestTilesFromOuterLayer)
|
||||||
|
.asSequence()
|
||||||
.sortedByDescending { nearbyTileRankings[it] }
|
.sortedByDescending { nearbyTileRankings[it] }
|
||||||
.take(5)
|
.take(5)
|
||||||
var rank = top5Tiles.map { nearbyTileRankings[it]!! }.sum()
|
.toList()
|
||||||
|
var rank = top5Tiles.asSequence().map { nearbyTileRankings[it]!! }.sum()
|
||||||
if(tileInfo.neighbors.any{it.baseTerrain == "Coast"}) rank += 5
|
if(tileInfo.neighbors.any{it.baseTerrain == "Coast"}) rank += 5
|
||||||
return rank
|
return rank
|
||||||
}
|
}
|
||||||
@ -315,18 +344,18 @@ class UnitAutomation{
|
|||||||
private fun automateSettlerActions(unit: MapUnit) {
|
private fun automateSettlerActions(unit: MapUnit) {
|
||||||
if(unit.getTile().militaryUnit==null) return // Don't move until you're accompanied by a military unit
|
if(unit.getTile().militaryUnit==null) return // Don't move until you're accompanied by a military unit
|
||||||
|
|
||||||
// find best city location within 5 tiles
|
|
||||||
val tilesNearCities = unit.civInfo.gameInfo.civilizations.flatMap { it.cities }
|
val tilesNearCities = unit.civInfo.gameInfo.civilizations.flatMap { it.cities }
|
||||||
.flatMap { it.getCenterTile().getTilesInDistance(3) }
|
.flatMap { it.getCenterTile().getTilesInDistance(3) }.toHashSet()
|
||||||
|
|
||||||
// This is to improve performance - instead of ranking each tile in the area up to 19 times, do it once.
|
// This is to improve performance - instead of ranking each tile in the area up to 19 times, do it once.
|
||||||
val nearbyTileRankings = unit.getTile().getTilesInDistance(7)
|
val nearbyTileRankings = unit.getTile().getTilesInDistance(7)
|
||||||
.associateBy ( {it},{ Automation().rankTile(it,unit.civInfo) })
|
.associateBy ( {it},{ Automation().rankTile(it,unit.civInfo) })
|
||||||
|
|
||||||
val possibleTiles = unit.getTile().getTilesInDistance(5)
|
val possibleCityLocations = unit.getTile().getTilesInDistance(5)
|
||||||
.minus(tilesNearCities)
|
.filter { (unit.canMoveTo(it) || unit.currentTile==it) && it !in tilesNearCities }
|
||||||
|
|
||||||
val bestCityLocation: TileInfo? = possibleTiles
|
val bestCityLocation: TileInfo? = possibleCityLocations
|
||||||
|
.asSequence()
|
||||||
.sortedByDescending { rankTileAsCityCenter(it, nearbyTileRankings) }
|
.sortedByDescending { rankTileAsCityCenter(it, nearbyTileRankings) }
|
||||||
.firstOrNull { unit.movementAlgs().canReach(it) }
|
.firstOrNull { unit.movementAlgs().canReach(it) }
|
||||||
|
|
||||||
@ -336,7 +365,10 @@ class UnitAutomation{
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit.getTile() == bestCityLocation) // already there!
|
if(bestCityLocation.getTilesInDistance(3).any { it.isCityCenter() })
|
||||||
|
throw Exception("City within distance")
|
||||||
|
|
||||||
|
if (unit.getTile() == bestCityLocation)
|
||||||
UnitActions().getUnitActions(unit, UnCivGame.Current.worldScreen).first { it.name == "Found city" }.action()
|
UnitActions().getUnitActions(unit, UnCivGame.Current.worldScreen).first { it.name == "Found city" }.action()
|
||||||
else {
|
else {
|
||||||
unit.movementAlgs().headTowards(bestCityLocation)
|
unit.movementAlgs().headTowards(bestCityLocation)
|
||||||
|
@ -18,7 +18,7 @@ class Battle(val gameInfo:GameInfo) {
|
|||||||
var damageToDefender = BattleDamage().calculateDamageToDefender(attacker,defender)
|
var damageToDefender = BattleDamage().calculateDamageToDefender(attacker,defender)
|
||||||
var damageToAttacker = BattleDamage().calculateDamageToAttacker(attacker,defender)
|
var damageToAttacker = BattleDamage().calculateDamageToAttacker(attacker,defender)
|
||||||
|
|
||||||
if(defender.getUnitType() == UnitType.Civilian && attacker.isMelee()){
|
if(defender.getUnitType().isCivilian() && attacker.isMelee()){
|
||||||
captureCivilianUnit(attacker,defender)
|
captureCivilianUnit(attacker,defender)
|
||||||
}
|
}
|
||||||
else if (attacker.isRanged()) {
|
else if (attacker.isRanged()) {
|
||||||
@ -98,7 +98,7 @@ class Battle(val gameInfo:GameInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(attacker.isMelee()){
|
if(attacker.isMelee()){
|
||||||
if(defender.getUnitType()!=UnitType.Civilian) // unit was not captured but actually attacked
|
if(!defender.getUnitType().isCivilian()) // unit was not captured but actually attacked
|
||||||
{
|
{
|
||||||
addXp(attacker,5,defender)
|
addXp(attacker,5,defender)
|
||||||
addXp(defender,4,attacker)
|
addXp(defender,4,attacker)
|
||||||
@ -109,7 +109,7 @@ class Battle(val gameInfo:GameInfo) {
|
|||||||
addXp(defender,2,attacker)
|
addXp(defender,2,attacker)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(defender.isDefeated() && defender is MapUnitCombatant && defender.getUnitType()!=UnitType.Civilian
|
if(defender.isDefeated() && defender is MapUnitCombatant && !defender.getUnitType().isCivilian()
|
||||||
&& attacker.getCivilization().policies.isAdopted("Honor Complete"))
|
&& attacker.getCivilization().policies.isAdopted("Honor Complete"))
|
||||||
attacker.getCivilization().gold += defender.unit.baseUnit.getGoldCost(hashSetOf()) / 10
|
attacker.getCivilization().gold += defender.unit.baseUnit.getGoldCost(hashSetOf()) / 10
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class BattleDamage{
|
|||||||
|
|
||||||
if(combatant.getCivilization().policies.isAdopted("Dicipline") && combatant.isMelee()
|
if(combatant.getCivilization().policies.isAdopted("Dicipline") && combatant.isMelee()
|
||||||
&& combatant.getTile().neighbors.flatMap { it.getUnits() }
|
&& combatant.getTile().neighbors.flatMap { it.getUnits() }
|
||||||
.any { it.civInfo==combatant.getCivilization() && it.baseUnit.unitType!=UnitType.Civilian})
|
.any { it.civInfo==combatant.getCivilization() && !it.baseUnit.unitType.isCivilian()})
|
||||||
modifiers["Dicipline"] = 0.15f
|
modifiers["Dicipline"] = 0.15f
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ class BattleDamage{
|
|||||||
|
|
||||||
fun calculateDamageToAttacker(attacker: ICombatant, defender: ICombatant): Int {
|
fun calculateDamageToAttacker(attacker: ICombatant, defender: ICombatant): Int {
|
||||||
if(attacker.isRanged()) return 0
|
if(attacker.isRanged()) return 0
|
||||||
if(defender.getUnitType()== UnitType.Civilian) return 0
|
if(defender.getUnitType().isCivilian()) return 0
|
||||||
val ratio = getDefendingStrength(attacker,defender) / getAttackingStrength(attacker,defender)
|
val ratio = getDefendingStrength(attacker,defender) / getAttackingStrength(attacker,defender)
|
||||||
return (ratio * 30 * getHealthDependantDamageRatio(defender)).toInt()
|
return (ratio * 30 * getHealthDependantDamageRatio(defender)).toInt()
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,7 @@ class CityExpansionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun takeOwnership(tileInfo: TileInfo){
|
private fun takeOwnership(tileInfo: TileInfo){
|
||||||
|
if(tileInfo.isCityCenter()) throw Exception("What?")
|
||||||
if(tileInfo.getCity()!=null) tileInfo.getCity()!!.expansion.relinquishOwnership(tileInfo)
|
if(tileInfo.getCity()!=null) tileInfo.getCity()!!.expansion.relinquishOwnership(tileInfo)
|
||||||
|
|
||||||
cityInfo.tiles.add(tileInfo.position)
|
cityInfo.tiles.add(tileInfo.position)
|
||||||
|
@ -212,7 +212,7 @@ class CityStats {
|
|||||||
stats.gold += 25f
|
stats.gold += 25f
|
||||||
if (policies.contains("Sovereignty") && cityInfo.civInfo.happiness >= 0)
|
if (policies.contains("Sovereignty") && cityInfo.civInfo.happiness >= 0)
|
||||||
stats.science += 15f
|
stats.science += 15f
|
||||||
if (policies.contains("Total War") && currentConstruction is BaseUnit && currentConstruction.unitType!=UnitType.Civilian )
|
if (policies.contains("Total War") && currentConstruction is BaseUnit && !currentConstruction.unitType.isCivilian() )
|
||||||
stats.production += 15f
|
stats.production += 15f
|
||||||
if (policies.contains("Aristocracy")
|
if (policies.contains("Aristocracy")
|
||||||
&& currentConstruction is Building
|
&& currentConstruction is Building
|
||||||
|
@ -265,7 +265,7 @@ class CivilizationInfo {
|
|||||||
// disband units until there are none left OR the gold values are normal
|
// disband units until there are none left OR the gold values are normal
|
||||||
if(!isBarbarianCivilization() && gold < -100 && nextTurnStats.gold.toInt() < 0) {
|
if(!isBarbarianCivilization() && gold < -100 && nextTurnStats.gold.toInt() < 0) {
|
||||||
for (i in 1 until (gold / -100)) {
|
for (i in 1 until (gold / -100)) {
|
||||||
var civMilitaryUnits = getCivUnits().filter { it.baseUnit().unitType != UnitType.Civilian }
|
var civMilitaryUnits = getCivUnits().filter { !it.baseUnit().unitType.isCivilian() }
|
||||||
if (civMilitaryUnits.isNotEmpty()) {
|
if (civMilitaryUnits.isNotEmpty()) {
|
||||||
val unitToDisband = civMilitaryUnits.first()
|
val unitToDisband = civMilitaryUnits.first()
|
||||||
unitToDisband.destroy()
|
unitToDisband.destroy()
|
||||||
|
@ -110,7 +110,7 @@ class MapUnit {
|
|||||||
if(tileOwner!=null && tileOwner.civName!=owner
|
if(tileOwner!=null && tileOwner.civName!=owner
|
||||||
&& (tile.isCityCenter() || !civInfo.canEnterTiles(tileOwner))) return false
|
&& (tile.isCityCenter() || !civInfo.canEnterTiles(tileOwner))) return false
|
||||||
|
|
||||||
if (baseUnit().unitType== UnitType.Civilian)
|
if (baseUnit().unitType.isCivilian())
|
||||||
return tile.civilianUnit==null && (tile.militaryUnit==null || tile.militaryUnit!!.owner==owner)
|
return tile.civilianUnit==null && (tile.militaryUnit==null || tile.militaryUnit!!.owner==owner)
|
||||||
else return tile.militaryUnit==null && (tile.civilianUnit==null || tile.civilianUnit!!.owner==owner)
|
else return tile.militaryUnit==null && (tile.civilianUnit==null || tile.civilianUnit!!.owner==owner)
|
||||||
}
|
}
|
||||||
@ -264,13 +264,13 @@ class MapUnit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun removeFromTile(){
|
fun removeFromTile(){
|
||||||
if (baseUnit().unitType== UnitType.Civilian) getTile().civilianUnit=null
|
if (baseUnit().unitType.isCivilian()) getTile().civilianUnit=null
|
||||||
else getTile().militaryUnit=null
|
else getTile().militaryUnit=null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun putInTile(tile:TileInfo){
|
fun putInTile(tile:TileInfo){
|
||||||
if(!canMoveTo(tile)) throw Exception("I can't go there!")
|
if(!canMoveTo(tile)) throw Exception("I can't go there!")
|
||||||
if(baseUnit().unitType== UnitType.Civilian)
|
if(baseUnit().unitType.isCivilian())
|
||||||
tile.civilianUnit=this
|
tile.civilianUnit=this
|
||||||
else tile.militaryUnit=this
|
else tile.militaryUnit=this
|
||||||
currentTile = tile
|
currentTile = tile
|
||||||
@ -302,7 +302,7 @@ class MapUnit {
|
|||||||
civInfo.addNotification("A [$chosenUnit] has joined us!",null, Color.BLUE)
|
civInfo.addNotification("A [$chosenUnit] has joined us!",null, Color.BLUE)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(baseUnit.unitType!=UnitType.Civilian)
|
if(!baseUnit.unitType.isCivilian())
|
||||||
actions.add {
|
actions.add {
|
||||||
promotions.XP+=10
|
promotions.XP+=10
|
||||||
civInfo.addNotification("An ancient tribe trains our [$name] in their ways of combat!",null, Color.RED)
|
civInfo.addNotification("An ancient tribe trains our [$name] in their ways of combat!",null, Color.RED)
|
||||||
|
@ -15,7 +15,7 @@ class PerlinNoiseRandomMapGenerator:SeedRandomMapGenerator(){
|
|||||||
override fun generateMap(distance: Int): HashMap<String, TileInfo> {
|
override fun generateMap(distance: Int): HashMap<String, TileInfo> {
|
||||||
val map = HashMap<Vector2, TileInfo>()
|
val map = HashMap<Vector2, TileInfo>()
|
||||||
val mapRandomSeed = Random().nextDouble() // without this, all the "random" maps would look the same
|
val mapRandomSeed = Random().nextDouble() // without this, all the "random" maps would look the same
|
||||||
for (vector in HexMath().GetVectorsInDistance(Vector2.Zero, distance))
|
for (vector in HexMath().getVectorsInDistance(Vector2.Zero, distance))
|
||||||
map[vector] = generateTile(vector,mapRandomSeed)
|
map[vector] = generateTile(vector,mapRandomSeed)
|
||||||
|
|
||||||
divideIntoAreas(6, 0f, map)
|
divideIntoAreas(6, 0f, map)
|
||||||
@ -50,7 +50,7 @@ class AlexanderRandomMapGenerator:RandomMapGenerator(){
|
|||||||
fun generateMap(distance: Int, landExpansionChance:Float): HashMap<String, TileInfo> {
|
fun generateMap(distance: Int, landExpansionChance:Float): HashMap<String, TileInfo> {
|
||||||
val map = HashMap<Vector2, TileInfo?>()
|
val map = HashMap<Vector2, TileInfo?>()
|
||||||
|
|
||||||
for (vector in HexMath().GetVectorsInDistance(Vector2.Zero, distance))
|
for (vector in HexMath().getVectorsInDistance(Vector2.Zero, distance))
|
||||||
map[vector] = null
|
map[vector] = null
|
||||||
|
|
||||||
val sparkList = ArrayList<Vector2>()
|
val sparkList = ArrayList<Vector2>()
|
||||||
@ -64,7 +64,7 @@ class AlexanderRandomMapGenerator:RandomMapGenerator(){
|
|||||||
|
|
||||||
while(sparkList.any()){
|
while(sparkList.any()){
|
||||||
val currentSpark = sparkList.getRandom()
|
val currentSpark = sparkList.getRandom()
|
||||||
val emptyTilesAroundSpark = HexMath().GetAdjacentVectors(currentSpark)
|
val emptyTilesAroundSpark = HexMath().getAdjacentVectors(currentSpark)
|
||||||
.filter { map.containsKey(it) && map[it]==null }
|
.filter { map.containsKey(it) && map[it]==null }
|
||||||
if(map[currentSpark]!!.baseTerrain==grassland){
|
if(map[currentSpark]!!.baseTerrain==grassland){
|
||||||
for(tile in emptyTilesAroundSpark){
|
for(tile in emptyTilesAroundSpark){
|
||||||
@ -84,7 +84,7 @@ class AlexanderRandomMapGenerator:RandomMapGenerator(){
|
|||||||
for(entry in map){
|
for(entry in map){
|
||||||
entry.value!!.position = entry.key
|
entry.value!!.position = entry.key
|
||||||
if(entry.value!!.baseTerrain==ocean
|
if(entry.value!!.baseTerrain==ocean
|
||||||
&& HexMath().GetAdjacentVectors(entry.key).all { !map.containsKey(it) || map[it]!!.baseTerrain==grassland })
|
&& HexMath().getAdjacentVectors(entry.key).all { !map.containsKey(it) || map[it]!!.baseTerrain==grassland })
|
||||||
entry.value!!.baseTerrain=grassland
|
entry.value!!.baseTerrain=grassland
|
||||||
|
|
||||||
newmap[entry.key.toString()] = entry.value!!
|
newmap[entry.key.toString()] = entry.value!!
|
||||||
@ -117,7 +117,7 @@ open class SeedRandomMapGenerator : RandomMapGenerator() {
|
|||||||
|
|
||||||
val map = HashMap<Vector2, TileInfo>()
|
val map = HashMap<Vector2, TileInfo>()
|
||||||
|
|
||||||
for (vector in HexMath().GetVectorsInDistance(Vector2.Zero, distance))
|
for (vector in HexMath().getVectorsInDistance(Vector2.Zero, distance))
|
||||||
map[vector] = TileInfo().apply { position=vector; baseTerrain="" }
|
map[vector] = TileInfo().apply { position=vector; baseTerrain="" }
|
||||||
|
|
||||||
|
|
||||||
@ -182,14 +182,14 @@ open class SeedRandomMapGenerator : RandomMapGenerator() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
val availableExpansionVectors = areaToExpand.locations
|
val availableExpansionVectors = areaToExpand.locations
|
||||||
.flatMap { HexMath().GetAdjacentVectors(it) }.asSequence().distinct()
|
.flatMap { HexMath().getAdjacentVectors(it) }.asSequence().distinct()
|
||||||
.filter { map.containsKey(it) && map[it]!!.baseTerrain=="" }.toList()
|
.filter { map.containsKey(it) && map[it]!!.baseTerrain=="" }.toList()
|
||||||
if (availableExpansionVectors.isEmpty()) expandableAreas -= areaToExpand
|
if (availableExpansionVectors.isEmpty()) expandableAreas -= areaToExpand
|
||||||
else {
|
else {
|
||||||
val expansionVector = availableExpansionVectors.getRandom()
|
val expansionVector = availableExpansionVectors.getRandom()
|
||||||
areaToExpand.addTile(map[expansionVector]!!)
|
areaToExpand.addTile(map[expansionVector]!!)
|
||||||
|
|
||||||
val neighbors = HexMath().GetAdjacentVectors(expansionVector)
|
val neighbors = HexMath().getAdjacentVectors(expansionVector)
|
||||||
val areasToJoin = areas.filter {
|
val areasToJoin = areas.filter {
|
||||||
it.terrain == areaToExpand.terrain
|
it.terrain == areaToExpand.terrain
|
||||||
&& it != areaToExpand
|
&& it != areaToExpand
|
||||||
@ -261,7 +261,7 @@ open class RandomMapGenerator {
|
|||||||
|
|
||||||
open fun generateMap(distance: Int): HashMap<String, TileInfo> {
|
open fun generateMap(distance: Int): HashMap<String, TileInfo> {
|
||||||
val map = HashMap<String, TileInfo>()
|
val map = HashMap<String, TileInfo>()
|
||||||
for (vector in HexMath().GetVectorsInDistance(Vector2.Zero, distance))
|
for (vector in HexMath().getVectorsInDistance(Vector2.Zero, distance))
|
||||||
map[vector.toString()] = addRandomTile(vector)
|
map[vector.toString()] = addRandomTile(vector)
|
||||||
return map
|
return map
|
||||||
}
|
}
|
||||||
@ -278,7 +278,7 @@ open class RandomMapGenerator {
|
|||||||
|
|
||||||
fun setWaterTiles(map: HashMap<String, TileInfo>) {
|
fun setWaterTiles(map: HashMap<String, TileInfo>) {
|
||||||
for (tile in map.values.filter { it.baseTerrain == "Ocean" }) {
|
for (tile in map.values.filter { it.baseTerrain == "Ocean" }) {
|
||||||
if (HexMath().GetVectorsInDistance(tile.position,2).any { hasWaterTile(map,it) })
|
if (HexMath().getVectorsInDistance(tile.position,2).any { hasWaterTile(map,it) })
|
||||||
tile.baseTerrain = "Coast"
|
tile.baseTerrain = "Coast"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,11 +51,13 @@ class TileMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getTilesInDistance(origin: Vector2, distance: Int): List<TileInfo> {
|
fun getTilesInDistance(origin: Vector2, distance: Int): List<TileInfo> {
|
||||||
return HexMath().GetVectorsInDistance(origin, distance).filter {contains(it)}.map { get(it) }
|
return HexMath().getVectorsInDistance(origin, distance).asSequence()
|
||||||
|
.filter {contains(it)}.map { get(it) }.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getTilesAtDistance(origin: Vector2, distance: Int): List<TileInfo> {
|
fun getTilesAtDistance(origin: Vector2, distance: Int): List<TileInfo> {
|
||||||
return HexMath().GetVectorsAtDistance(origin, distance).filter {contains(it)}.map { get(it) }
|
return HexMath().getVectorsAtDistance(origin, distance).asSequence()
|
||||||
|
.filter {contains(it)}.map { get(it) }.toList()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,10 +90,10 @@ class TileMap {
|
|||||||
if(tiles.any()) //
|
if(tiles.any()) //
|
||||||
tileList.addAll(tiles.values)
|
tileList.addAll(tiles.values)
|
||||||
|
|
||||||
val topY=tileList.map { it.position.y.toInt() }.max()!!
|
val topY= tileList.asSequence().map { it.position.y.toInt() }.max()!!
|
||||||
bottomY= tileList.map { it.position.y.toInt() }.min()!!
|
bottomY= tileList.asSequence().map { it.position.y.toInt() }.min()!!
|
||||||
val rightX=tileList.map { it.position.x.toInt() }.max()!!
|
val rightX= tileList.asSequence().map { it.position.x.toInt() }.max()!!
|
||||||
leftX = tileList.map { it.position.x.toInt() }.min()!!
|
leftX = tileList.asSequence().map { it.position.x.toInt() }.min()!!
|
||||||
|
|
||||||
for(x in leftX..rightX){
|
for(x in leftX..rightX){
|
||||||
val row = ArrayList<TileInfo?>()
|
val row = ArrayList<TileInfo?>()
|
||||||
|
@ -89,18 +89,24 @@ class BaseUnit : INamed, IConstruction, ICivilopedia {
|
|||||||
return (cost / 10).toInt() * 10 // rounded down o nearest ten
|
return (cost / 10).toInt() * 10 // rounded down o nearest ten
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isBuildable(construction: CityConstructions): Boolean {
|
fun isBuildable(civInfo:CivilizationInfo): Boolean {
|
||||||
val civInfo = construction.cityInfo.civInfo
|
|
||||||
if (unbuildable) return false
|
if (unbuildable) return false
|
||||||
if (requiredTech!=null && !civInfo.tech.isResearched(requiredTech!!)) return false
|
if (requiredTech!=null && !civInfo.tech.isResearched(requiredTech!!)) return false
|
||||||
if (obsoleteTech!=null && civInfo.tech.isResearched(obsoleteTech!!)) return false
|
if (obsoleteTech!=null && civInfo.tech.isResearched(obsoleteTech!!)) return false
|
||||||
if (uniqueTo!=null && uniqueTo!=civInfo.civName) return false
|
if (uniqueTo!=null && uniqueTo!=civInfo.civName) return false
|
||||||
if (GameBasics.Units.values.any { it.uniqueTo==civInfo.civName && it.replaces==name }) return false
|
if (GameBasics.Units.values.any { it.uniqueTo==civInfo.civName && it.replaces==name }) return false
|
||||||
if (requiredResource!=null && !civInfo.getCivResources().keys.any { it.name == requiredResource }) return false
|
if (requiredResource!=null && !civInfo.getCivResources().keys.any { it.name == requiredResource }) return false
|
||||||
if(unitType.isWaterUnit() && construction.cityInfo.getCenterTile().neighbors.none { it.baseTerrain=="Coast" })
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun isBuildable(construction: CityConstructions): Boolean {
|
||||||
|
if(!isBuildable(construction.cityInfo.civInfo)) return false
|
||||||
|
if(unitType.isWaterUnit() && construction.cityInfo.getCenterTile().neighbors.none { it.baseTerrain=="Coast" })
|
||||||
|
return false
|
||||||
|
return true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
override fun postBuildEvent(construction: CityConstructions) {
|
override fun postBuildEvent(construction: CityConstructions) {
|
||||||
val unit = construction.cityInfo.civInfo.placeUnitNearTile(construction.cityInfo.location, name)
|
val unit = construction.cityInfo.civInfo.placeUnitNearTile(construction.cityInfo.location, name)
|
||||||
unit.promotions.XP += construction.getBuiltBuildings().sumBy { it.xpForNewUnits }
|
unit.promotions.XP += construction.getBuiltBuildings().sumBy { it.xpForNewUnits }
|
||||||
|
@ -28,6 +28,12 @@ enum class UnitType{
|
|||||||
|| this == Ranged
|
|| this == Ranged
|
||||||
|| this == Siege
|
|| this == Siege
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isCivilian(): Boolean {
|
||||||
|
return this == Civilian
|
||||||
|
|| this == WaterCivilian
|
||||||
|
}
|
||||||
|
|
||||||
fun isWaterUnit(): Boolean {
|
fun isWaterUnit(): Boolean {
|
||||||
return this == WaterCivilian
|
return this == WaterCivilian
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val positionalVector = HexMath().Hex2WorldCoords(tileInfo.position.cpy().sub(cityInfo.location))
|
val positionalVector = HexMath().hex2WorldCoords(tileInfo.position.cpy().sub(cityInfo.location))
|
||||||
val groupSize = 50
|
val groupSize = 50
|
||||||
tileGroup.setPosition(stage.width / 2 + positionalVector.x * 0.8f * groupSize.toFloat(),
|
tileGroup.setPosition(stage.width / 2 + positionalVector.x * 0.8f * groupSize.toFloat(),
|
||||||
stage.height / 2 + positionalVector.y * 0.8f * groupSize.toFloat())
|
stage.height / 2 + positionalVector.y * 0.8f * groupSize.toFloat())
|
||||||
|
@ -179,7 +179,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
if (neigborOwner != tileOwner && !borderImages.containsKey(neighbor)) { // there should be a border here but there isn't
|
if (neigborOwner != tileOwner && !borderImages.containsKey(neighbor)) { // there should be a border here but there isn't
|
||||||
|
|
||||||
val relativeHexPosition = tileInfo.position.cpy().sub(neighbor.position)
|
val relativeHexPosition = tileInfo.position.cpy().sub(neighbor.position)
|
||||||
val relativeWorldPosition = HexMath().Hex2WorldCoords(relativeHexPosition)
|
val relativeWorldPosition = HexMath().hex2WorldCoords(relativeHexPosition)
|
||||||
|
|
||||||
// This is some crazy voodoo magic so I'll explain.
|
// This is some crazy voodoo magic so I'll explain.
|
||||||
val images = mutableListOf<Image>()
|
val images = mutableListOf<Image>()
|
||||||
@ -233,7 +233,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
roadImage.image = image
|
roadImage.image = image
|
||||||
|
|
||||||
val relativeHexPosition = tileInfo.position.cpy().sub(neighbor.position)
|
val relativeHexPosition = tileInfo.position.cpy().sub(neighbor.position)
|
||||||
val relativeWorldPosition = HexMath().Hex2WorldCoords(relativeHexPosition)
|
val relativeWorldPosition = HexMath().hex2WorldCoords(relativeHexPosition)
|
||||||
|
|
||||||
// This is some crazy voodoo magic so I'll explain.
|
// This is some crazy voodoo magic so I'll explain.
|
||||||
image.moveBy(25f, 25f) // Move road to center of tile
|
image.moveBy(25f, 25f) // Move road to center of tile
|
||||||
@ -327,7 +327,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
newImage.center(this)
|
newImage.center(this)
|
||||||
newImage.y += yFromCenter
|
newImage.y += yFromCenter
|
||||||
|
|
||||||
if (!unit.isIdle()) newImage.color.a = 0.5f
|
if (!unit.isIdle() && unit.civInfo.isPlayerCivilization()) newImage.color.a = 0.5f
|
||||||
}
|
}
|
||||||
return newImage
|
return newImage
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ import com.unciv.logic.city.SpecialConstruction
|
|||||||
import com.unciv.logic.map.MapUnit
|
import com.unciv.logic.map.MapUnit
|
||||||
import com.unciv.logic.map.RoadStatus
|
import com.unciv.logic.map.RoadStatus
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.models.gamebasics.unit.UnitType
|
|
||||||
import com.unciv.ui.cityscreen.CityScreen
|
import com.unciv.ui.cityscreen.CityScreen
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
|
|
||||||
@ -25,7 +24,7 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
|||||||
val whiteHalo = if(unit.isFortified()) ImageGetter.getImage("OtherIcons/Shield.png")
|
val whiteHalo = if(unit.isFortified()) ImageGetter.getImage("OtherIcons/Shield.png")
|
||||||
else ImageGetter.getImage("OtherIcons/Circle.png")
|
else ImageGetter.getImage("OtherIcons/Circle.png")
|
||||||
whiteHalo.setSize(30f,30f)
|
whiteHalo.setSize(30f,30f)
|
||||||
val unitImage = if(unit.baseUnit().unitType== UnitType.Civilian) civilianUnitImage
|
val unitImage = if(unit.baseUnit().unitType.isCivilian()) civilianUnitImage
|
||||||
else militaryUnitImage
|
else militaryUnitImage
|
||||||
if(unitImage==null) //Stuff has changed since we requested this, the unit is no longer here...
|
if(unitImage==null) //Stuff has changed since we requested this, the unit is no longer here...
|
||||||
return
|
return
|
||||||
|
@ -10,6 +10,7 @@ import com.unciv.UnCivGame
|
|||||||
import com.unciv.logic.HexMath
|
import com.unciv.logic.HexMath
|
||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
|
import com.unciv.models.gamebasics.tile.TerrainType
|
||||||
import com.unciv.ui.utils.ImageGetter
|
import com.unciv.ui.utils.ImageGetter
|
||||||
import com.unciv.ui.utils.onClick
|
import com.unciv.ui.utils.onClick
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ class Minimap(val tileMapHolder: TileMapHolder) : ScrollPane(null){
|
|||||||
for (tileInfo in tileMapHolder.tileMap.values) {
|
for (tileInfo in tileMapHolder.tileMap.values) {
|
||||||
val hex = ImageGetter.getImage("TerrainIcons/Hexagon.png")
|
val hex = ImageGetter.getImage("TerrainIcons/Hexagon.png")
|
||||||
|
|
||||||
val positionalVector = HexMath().Hex2WorldCoords(tileInfo.position)
|
val positionalVector = HexMath().hex2WorldCoords(tileInfo.position)
|
||||||
val groupSize = 10f
|
val groupSize = 10f
|
||||||
hex.setSize(groupSize,groupSize)
|
hex.setSize(groupSize,groupSize)
|
||||||
hex.setPosition(positionalVector.x * 0.5f * groupSize,
|
hex.setPosition(positionalVector.x * 0.5f * groupSize,
|
||||||
@ -73,9 +74,10 @@ class Minimap(val tileMapHolder: TileMapHolder) : ScrollPane(null){
|
|||||||
val exploredTiles = cloneCivilization.exploredTiles
|
val exploredTiles = cloneCivilization.exploredTiles
|
||||||
for(tileInfo in tileMapHolder.tileMap.values) {
|
for(tileInfo in tileMapHolder.tileMap.values) {
|
||||||
val hex = tileImages[tileInfo]!!
|
val hex = tileImages[tileInfo]!!
|
||||||
|
val isWaterTile = tileInfo.getBaseTerrain().type==TerrainType.Water
|
||||||
if (!(exploredTiles.contains(tileInfo.position) || UnCivGame.Current.viewEntireMapForDebug)) hex.color = Color.BLACK
|
if (!(exploredTiles.contains(tileInfo.position) || UnCivGame.Current.viewEntireMapForDebug)) hex.color = Color.BLACK
|
||||||
else if (tileInfo.isCityCenter()) hex.color = tileInfo.getOwner()!!.getNation().getSecondaryColor()
|
else if (tileInfo.isCityCenter() && !isWaterTile) hex.color = tileInfo.getOwner()!!.getNation().getSecondaryColor()
|
||||||
else if (tileInfo.getCity() != null) hex.color = tileInfo.getOwner()!!.getNation().getColor()
|
else if (tileInfo.getCity() != null && !isWaterTile) hex.color = tileInfo.getOwner()!!.getNation().getColor()
|
||||||
else hex.color = tileInfo.getBaseTerrain().getColor().lerp(Color.GRAY, 0.5f) // Todo add to baseterrain as function
|
else hex.color = tileInfo.getBaseTerrain().getColor().lerp(Color.GRAY, 0.5f) // Todo add to baseterrain as function
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
val positionalVector = HexMath().Hex2WorldCoords(tileInfo.position)
|
val positionalVector = HexMath().hex2WorldCoords(tileInfo.position)
|
||||||
val groupSize = 50
|
val groupSize = 50
|
||||||
group.setPosition(worldScreen.stage.width / 2 + positionalVector.x * 0.8f * groupSize.toFloat(),
|
group.setPosition(worldScreen.stage.width / 2 + positionalVector.x * 0.8f * groupSize.toFloat(),
|
||||||
worldScreen.stage.height / 2 + positionalVector.y * 0.8f * groupSize.toFloat())
|
worldScreen.stage.height / 2 + positionalVector.y * 0.8f * groupSize.toFloat())
|
||||||
@ -156,7 +156,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
|
|
||||||
val unitType = unit.baseUnit().unitType
|
val unitType = unit.baseUnit().unitType
|
||||||
val attackableTiles: List<TileInfo> = when{
|
val attackableTiles: List<TileInfo> = when{
|
||||||
unitType==UnitType.Civilian -> unit.getDistanceToTiles().keys.toList()
|
unitType.isCivilian() -> unit.getDistanceToTiles().keys.toList()
|
||||||
else -> UnitAutomation().getAttackableEnemies(unit, unit.getDistanceToTiles()).map { it.tileToAttack }
|
else -> UnitAutomation().getAttackableEnemies(unit, unit.getDistanceToTiles()).map { it.tileToAttack }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
it.getUnits().isNotEmpty()
|
it.getUnits().isNotEmpty()
|
||||||
&& it.getUnits().first().owner != unit.owner
|
&& it.getUnits().first().owner != unit.owner
|
||||||
&& (playerViewableTilePositions.contains(it.position) || UnCivGame.Current.viewEntireMapForDebug)}) {
|
&& (playerViewableTilePositions.contains(it.position) || UnCivGame.Current.viewEntireMapForDebug)}) {
|
||||||
if(unit.baseUnit().unitType== UnitType.Civilian) tileGroups[tile]!!.hideCircle()
|
if(unit.baseUnit().unitType.isCivilian()) tileGroups[tile]!!.hideCircle()
|
||||||
else {
|
else {
|
||||||
tileGroups[tile]!!.showCircle(colorFromRGB(237, 41, 57))
|
tileGroups[tile]!!.showCircle(colorFromRGB(237, 41, 57))
|
||||||
tileGroups[tile]!!.showCrosshair()
|
tileGroups[tile]!!.showCrosshair()
|
||||||
|
@ -31,7 +31,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
|||||||
fun update() {
|
fun update() {
|
||||||
val unitTable = worldScreen.bottomBar.unitTable
|
val unitTable = worldScreen.bottomBar.unitTable
|
||||||
if (unitTable.selectedUnit == null
|
if (unitTable.selectedUnit == null
|
||||||
|| unitTable.selectedUnit!!.baseUnit().unitType == UnitType.Civilian){
|
|| unitTable.selectedUnit!!.baseUnit().unitType.isCivilian()){
|
||||||
hide()
|
hide()
|
||||||
return
|
return
|
||||||
} // no attacker
|
} // no attacker
|
||||||
@ -102,7 +102,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
|||||||
else if (damageToDefender>defender.getHealth()) damageToDefender=defender.getHealth()
|
else if (damageToDefender>defender.getHealth()) damageToDefender=defender.getHealth()
|
||||||
|
|
||||||
|
|
||||||
if(attacker.isMelee() && (defender.getUnitType()==UnitType.Civilian
|
if(attacker.isMelee() && (defender.getUnitType().isCivilian()
|
||||||
|| defender.getUnitType()==UnitType.City && defender.isDefeated())) {
|
|| defender.getUnitType()==UnitType.City && defender.isDefeated())) {
|
||||||
add("")
|
add("")
|
||||||
add("{Captured!}".tr())
|
add("{Captured!}".tr())
|
||||||
|
@ -42,7 +42,7 @@ class UnitActions {
|
|||||||
},true)
|
},true)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(unit.baseUnit().unitType!= UnitType.Civilian
|
if(!unit.baseUnit().unitType.isCivilian()
|
||||||
&& !unit.hasUnique("No defensive terrain bonus") && !unit.isFortified()) {
|
&& !unit.hasUnique("No defensive terrain bonus") && !unit.isFortified()) {
|
||||||
actionList += UnitAction("Fortify", { unit.action = "Fortify 0" }, unit.currentMovement != 0f)
|
actionList += UnitAction("Fortify", { unit.action = "Fortify 0" }, unit.currentMovement != 0f)
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ class UnitActions {
|
|||||||
actionList += UnitAction("Stop exploration", { unit.action = null }, true)
|
actionList += UnitAction("Stop exploration", { unit.action = null }, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(unit.baseUnit().unitType!= UnitType.Civilian && unit.promotions.canBePromoted()){
|
if(!unit.baseUnit().unitType.isCivilian() && unit.promotions.canBePromoted()){
|
||||||
actionList += UnitAction("Promote",
|
actionList += UnitAction("Promote",
|
||||||
{UnCivGame.Current.screen = PromotionPickerScreen(unit)},
|
{UnCivGame.Current.screen = PromotionPickerScreen(unit)},
|
||||||
unit.currentMovement != 0f)
|
unit.currentMovement != 0f)
|
||||||
|
@ -4,7 +4,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.unciv.logic.map.MapUnit
|
import com.unciv.logic.map.MapUnit
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.models.gamebasics.unit.UnitType
|
|
||||||
import com.unciv.ui.tilegroups.TileGroup
|
import com.unciv.ui.tilegroups.TileGroup
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
import com.unciv.ui.worldscreen.WorldScreen
|
import com.unciv.ui.worldscreen.WorldScreen
|
||||||
@ -65,13 +64,13 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
unitNameLabel.setText(nameLabelText)
|
unitNameLabel.setText(nameLabelText)
|
||||||
|
|
||||||
var unitLabelText = "Movement".tr()+": " + unit.getMovementString()
|
var unitLabelText = "Movement".tr()+": " + unit.getMovementString()
|
||||||
if (unit.baseUnit().unitType != UnitType.Civilian)
|
if (!unit.baseUnit().unitType.isCivilian())
|
||||||
unitLabelText += "\n"+"Strength".tr()+": " + unit.baseUnit().strength
|
unitLabelText += "\n"+"Strength".tr()+": " + unit.baseUnit().strength
|
||||||
|
|
||||||
if (unit.baseUnit().rangedStrength!=0)
|
if (unit.baseUnit().rangedStrength!=0)
|
||||||
unitLabelText += "\n"+"Ranged strength".tr()+": "+unit.baseUnit().rangedStrength
|
unitLabelText += "\n"+"Ranged strength".tr()+": "+unit.baseUnit().rangedStrength
|
||||||
|
|
||||||
if (unit.baseUnit().unitType != UnitType.Civilian)
|
if (!unit.baseUnit().unitType.isCivilian())
|
||||||
unitLabelText += "\n"+"XP".tr()+": "+unit.promotions.XP+"/"+unit.promotions.xpForNextPromotion()
|
unitLabelText += "\n"+"XP".tr()+": "+unit.promotions.XP+"/"+unit.promotions.xpForNextPromotion()
|
||||||
|
|
||||||
if(unit.isFortified() && unit.getFortificationTurns()>0)
|
if(unit.isFortified() && unit.getFortificationTurns()>0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user