Fixed a bug where the unit needs the civInfo in order to calculate the moveTo even before it's put on the map.

This commit is contained in:
Yair Morgenstern 2018-08-29 12:25:35 +03:00
parent 40db822a79
commit 9e5208dd8c
4 changed files with 12 additions and 10 deletions

View file

@ -74,8 +74,8 @@ All the following are from [the Noun Project](https://thenounproject.com) licenc
* [Factory](https://thenounproject.com/term/factory/1049531/) By RULI
* [Mine](https://thenounproject.com/term/mine/543/) By Edward Boatman
* [Corral](https://thenounproject.com/term/corral/1340751/) By Luis Prado
* [Connection](https://thenounproject.com/search/?q=connection&i=1521886) By Travis Avery
* [Connection](https://thenounproject.com/search/?q=connection&i=1521886) By Travis Avery
* [Connection](https://thenounproject.com/search/?q=connection&i=1521886) By Travis Avery
* [Connection](https://thenounproject.com/search/?q=connection&i=1521886) By Travis Avery
* [Connection](https://thenounproject.com/search/?q=connection&i=1521886) By Travis Avery
* [Plants](https://thenounproject.com/term/plants/1760916/) By hendra sudibyo
* [Pickaxe](https://thenounproject.com/term/pickaxe/175792/) By Creative Stall
* [Food stall](https://thenounproject.com/term/food-stall/1618358/) By I Putu Kharismayadi
* [Road](https://thenounproject.com/term/road/1600491/) By REVA
* [Circle](https://thenounproject.com/term/circle/1841891/) By Aybige

View file

@ -21,8 +21,8 @@ android {
applicationId "com.unciv.game"
minSdkVersion 14
targetSdkVersion 26
versionCode 130
versionName "2.7.14"
versionCode 131
versionName "2.7.15"
}
buildTypes {
release {

View file

@ -102,7 +102,7 @@ class DiplomacyManager() {
fun declareWar(){
diplomaticStatus = DiplomaticStatus.War
otherCiv().diplomacy[civInfo.civName]!!.diplomaticStatus = DiplomaticStatus.War
otherCiv().addNotification("[civName] has declared war on us!",null, Color.RED)
otherCiv().addNotification("[${civInfo.civName}] has declared war on us!",null, Color.RED)
}
//endregion
}

View file

@ -63,12 +63,14 @@ class TileMap {
val tilesInDistance = getTilesInDistance(position, 2)
unit.owner=civInfo.civName // needed in order to calculate canMoveTo
unit.assignOwner(civInfo) // both the civ name and actual civ need to be in here in order to calculate the canMoveTo...Darn
val unitToPlaceTile = tilesInDistance.firstOrNull { unit.canMoveTo(it) }
if(unitToPlaceTile!=null) {
// only once we know the unit can be placed do we add it to the civ's unit list
unit.putInTile(unitToPlaceTile)
unit.assignOwner(civInfo) // only once we know the unit can be placed do we add it to the civ's unit list
}
else civInfo.units.remove(unit) // since we added it to the civ units in the previous assignOwner
return unit
}