Resolved #407 - Add pillaging terrain improvements

This commit is contained in:
Yair Morgenstern 2019-01-07 21:56:02 +02:00
parent b8aa4932a0
commit eeb494364b
13 changed files with 435 additions and 410 deletions

View file

@ -389,8 +389,8 @@ All the following are from [the Noun Project](https://thenounproject.com) licenc
* [Banner](https://thenounproject.com/term/banner/866282/) By Emir Palavan for embarked units
* [Arrow](https://thenounproject.com/term/arrow/18123/) By uzeir syarief for moving between idle units
* [Replace](https://thenounproject.com/search/?q=replace&i=17858) By Mike Rowe, AU
* [Resistance](https://thenounproject.com/term/revolution/1315305/) By By HeadsOfBirds, GB
* [Resistance](https://thenounproject.com/term/revolution/1315305/) By HeadsOfBirds
* [Viking Hat](https://thenounproject.com/search/?q=pillage&i=185405) By my name is mud
# Sound credits

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 837 KiB

After

Width:  |  Height:  |  Size: 847 KiB

View file

@ -47,7 +47,7 @@
name:"France",
mainColor:[ 38, 98, 255],
secondaryColor:[239,236,148],
unique:"+2 Culture per turn from Cities before discovering Steam Power"
unique:"+2 Culture per turn from cities before discovering Steam Power",
cities:["Paris","Orleans","Lyon","Troyes","Tours","Marseille","Chartres","Avignon","Rouen","Grenoble",
"Dijon","Amiens","Cherbourg","Poitiers","Toulouse","Bayonne","Strasbourg","Brest","Bordeaux","Rennes",
"Nice","Saint Etienne","Nantes","Reims","Le Mans","Montpellier","Limoges","Nancy","Lille","Caen"]

View file

@ -255,6 +255,8 @@
Spanish:"Explorar"
}
"Pillage":{}
"Do you really want to disband this unit?":{
Italian:"Vuoi davvero sciogliere questa unità?"
Russian:"Вы действительно хотите распустить этот юнит?"
@ -285,7 +287,6 @@
Simplified_Chinese:"不"
Portuguese:"Sim"
}
// Stats
"Gold":{

View file

@ -21,8 +21,8 @@ android {
applicationId "com.unciv.app"
minSdkVersion 14
targetSdkVersion 28
versionCode 187
versionName "2.11.5"
versionCode 188
versionName "2.11.6"
}
// Had to add this crap for Travis to build, it wanted to sign the app

View file

@ -136,7 +136,7 @@ class UnitAutomation{
class AttackableTile(val tileToAttackFrom:TileInfo, val tileToAttack:TileInfo)
fun getAttackableEnemies(unit: MapUnit, unitDistanceToTiles: HashMap<TileInfo, Float>, minMovBeforeAtaack: Float = 0.1f): ArrayList<AttackableTile> {
fun getAttackableEnemies(unit: MapUnit, unitDistanceToTiles: HashMap<TileInfo, Float>, minMovementBeforeAttack: Float = 0.1f): ArrayList<AttackableTile> {
val tilesWithEnemies = unit.civInfo.viewableTiles
.filter { containsAttackableEnemy(it,unit) }
@ -149,7 +149,7 @@ class UnitAutomation{
// So the poor unit thought it could attack from the tile, but when it comes to do so it has no movement points!
// Silly floats, basically
var tilesToAttackFrom = unitDistanceToTiles.asSequence()
.filter { unit.currentMovement - it.value >= minMovBeforeAtaack }
.filter { unit.currentMovement - it.value >= minMovementBeforeAttack }
.map { it.key }
.filter { unit.canMoveTo(it) || it==unit.getTile() }

View file

@ -6,7 +6,6 @@ import com.unciv.logic.city.CityInfo
import com.unciv.logic.map.TileInfo
import com.unciv.models.gamebasics.unit.UnitType
import java.util.*
import kotlin.math.max
/**
* Damage calculations according to civ v wiki and https://steamcommunity.com/sharedfiles/filedetails/?id=170194443
@ -80,7 +79,7 @@ class Battle(val gameInfo:GameInfo) {
if (unit.hasUnique("Can move after attacking")
|| (unit.hasUnique("1 additional attack per turn") && unit.attacksThisTurn==0)){
if(!attacker.getUnitType().isMelee() || !defender.isDefeated()) // if it was a melee attack and we won, then the unit ALREADY got movement points deducted, for the movement to the enemie's tile!
unit.currentMovement = max(0f, unit.currentMovement - 1)
unit.useMovementPoints(1f)
}
else unit.currentMovement = 0f
unit.attacksThisTurn+=1

View file

@ -121,7 +121,7 @@ class CityStats {
if(civUnique == "+2 Culture per turn from cities before discovering Steam Power")
stats.culture += 2
return stats
}

View file

@ -212,6 +212,12 @@ class MapUnit {
baseUnit=GameBasics.Units[name]!!
updateUniques()
}
fun useMovementPoints(amount:Float){
currentMovement -= amount
if(currentMovement<0) currentMovement = 0f
}
fun doPreTurnAction() {
val currentTile = getTile()
if (currentMovement == 0f) return // We've already done stuff this turn, and can't do any more stuff
@ -232,7 +238,7 @@ class MapUnit {
if(gotTo==currentTile) // We didn't move at all
return
if (gotTo.position == destinationVector) action = null
if (currentMovement != 0f) doPreTurnAction()
if (currentMovement >0) doPreTurnAction()
return
}

View file

@ -15,7 +15,7 @@ import com.unciv.ui.pickerscreens.TechPickerScreen
import com.unciv.ui.worldscreen.WorldScreen
import com.unciv.ui.worldscreen.optionstable.YesNoPopupTable
import java.util.*
import kotlin.math.max
import kotlin.math.min
class UnitAction(var name: String, var canAct:Boolean, var action:()->Unit){
var sound="click"
@ -39,24 +39,24 @@ class UnitActions {
if(!unit.type.isCivilian() && !unit.isEmbarked() && !unit.type.isWaterUnit()
&& !unit.hasUnique("No defensive terrain bonus") && !unit.isFortified()) {
actionList += UnitAction("Fortify", unit.currentMovement != 0f)
actionList += UnitAction("Fortify", unit.currentMovement >0)
{ unit.action = "Fortify 0" }.sound("fortify")
}
if(!unit.isFortified() && actionList.none{it.name=="Fortify"} && unit.action!="Sleep") {
actionList += UnitAction("Sleep",unit.currentMovement != 0f) { unit.action = "Sleep" }
actionList += UnitAction("Sleep",unit.currentMovement >0) { unit.action = "Sleep" }
}
if(unit.type == UnitType.Scout){
if(unit.action != "explore")
actionList += UnitAction("Explore",unit.currentMovement != 0f)
actionList += UnitAction("Explore",unit.currentMovement >0)
{ UnitAutomation().automatedExplore(unit); unit.action = "explore" }
else
actionList += UnitAction("Stop exploration", true) { unit.action = null }
}
if(!unit.type.isCivilian() && unit.promotions.canBePromoted()) {
actionList += UnitAction("Promote", unit.currentMovement != 0f)
actionList += UnitAction("Promote", unit.currentMovement >0)
{ UnCivGame.Current.screen = PromotionPickerScreen(unit) }.sound("promote")
}
@ -96,13 +96,24 @@ class UnitActions {
}
}
if(!unit.type.isCivilian() && tile.improvement !=null && unit.health<100){
actionList += UnitAction("Pillage", unit.currentMovement>0)
{
tile.improvementInProgress = tile.improvement
tile.turnsToImprovement = 2
tile.improvement = null
unit.useMovementPoints(1f)
unit.health = min(100,unit.health+25)
}
}
if(unit.hasUnique("Must set up to ranged attack") && unit.action != "Set Up" && !unit.isEmbarked())
actionList+=UnitAction("Set up",unit.currentMovement != 0f)
{unit.action="Set Up"; unit.currentMovement = max(0f, unit.currentMovement-1)}.sound("setup")
actionList+=UnitAction("Set up",unit.currentMovement >0)
{unit.action="Set Up"; unit.useMovementPoints(1f)}.sound("setup")
if (unit.hasUnique("Founds a new city") && !unit.isEmbarked()) {
actionList += UnitAction("Found city",
unit.currentMovement != 0f &&
unit.currentMovement >0 &&
!tile.getTilesInDistance(3).any { it.isCityCenter() })
{
worldScreen.displayTutorials("CityFounded")
@ -116,7 +127,7 @@ class UnitActions {
if (unit.hasUnique("Can build improvements on tiles") && !unit.isEmbarked()) {
actionList += UnitAction("Construct improvement",
unit.currentMovement != 0f
unit.currentMovement >0
&& !tile.isCityCenter()
&& GameBasics.TileImprovements.values.any { tile.canBuildImprovement(it, unit.civInfo) }
) { worldScreen.game.screen = ImprovementPickerScreen(tile) }
@ -125,7 +136,7 @@ class UnitActions {
actionList += UnitAction("Stop automation",true) {unit.action = null}
}
else {
actionList += UnitAction("Automate", unit.currentMovement != 0f)
actionList += UnitAction("Automate", unit.currentMovement >0)
{
unit.action = "automation"
WorkerAutomation(unit).automateWorkerAction()
@ -139,7 +150,7 @@ class UnitActions {
&& tile.getTileResource().improvement == improvement
&& unit.civInfo.tech.isResearched(GameBasics.TileImprovements[improvement]!!.techRequired!!)
)
actionList += UnitAction("Create [$improvement]", unit.currentMovement != 0f) {
actionList += UnitAction("Create [$improvement]", unit.currentMovement >0) {
tile.improvement = improvement
unit.destroy()
}
@ -148,7 +159,7 @@ class UnitActions {
for(unique in unit.getUniques().filter { it.startsWith("Can build improvement: ") }){
val improvementName = unique.replace("Can build improvement: ","")
actionList += UnitAction("Create [$improvementName]",
unit.currentMovement != 0f && !tile.isCityCenter()
unit.currentMovement >0f && !tile.isCityCenter()
) {
unit.getTile().terrainFeature=null // remove forest/jungle/marsh
unit.getTile().improvement = improvementName
@ -160,7 +171,7 @@ class UnitActions {
if (unit.name == "Great Scientist" && !unit.isEmbarked()) {
actionList += UnitAction( "Discover Technology",unit.currentMovement != 0f
actionList += UnitAction( "Discover Technology",unit.currentMovement >0
) {
unit.civInfo.tech.freeTechs += 1
unit.destroy()
@ -169,7 +180,7 @@ class UnitActions {
}
if (unit.hasUnique("Can start an 8-turn golden age") && !unit.isEmbarked()) {
actionList += UnitAction( "Start Golden Age",unit.currentMovement != 0f
actionList += UnitAction( "Start Golden Age",unit.currentMovement >0
) {
unit.civInfo.goldenAges.enterGoldenAge()
unit.destroy()
@ -178,7 +189,7 @@ class UnitActions {
if (unit.name == "Great Engineer" && !unit.isEmbarked()) {
actionList += UnitAction( "Hurry Wonder",
unit.currentMovement != 0f &&
unit.currentMovement >0 &&
tile.isCityCenter() &&
tile.getCity()!!.cityConstructions.getCurrentConstruction() is Building &&
(tile.getCity()!!.cityConstructions.getCurrentConstruction() as Building).isWonder
@ -189,7 +200,7 @@ class UnitActions {
}
if (unit.name == "Great Merchant" && !unit.isEmbarked()) {
actionList += UnitAction("Conduct Trade Mission", unit.currentMovement != 0f
actionList += UnitAction("Conduct Trade Mission", unit.currentMovement >0
) {
// http://civilization.wikia.com/wiki/Great_Merchant_(Civ5)
val goldGained = 350 + 50 * unit.civInfo.getEra().ordinal
@ -199,7 +210,7 @@ class UnitActions {
}.sound("chimes")
}
actionList += UnitAction("Disband unit",unit.currentMovement != 0f
actionList += UnitAction("Disband unit",unit.currentMovement >0
) {
YesNoPopupTable("Do you really want to disband this unit?".tr(),
{unit.destroy(); worldScreen.shouldUpdate=true} )

View file

@ -23,11 +23,11 @@ class UnitActionsTable(val worldScreen: WorldScreen) : Table(){
when(unitAction){
"Move unit" -> return ImageGetter.getStatIcon("Movement")
"Stop movement"-> return ImageGetter.getStatIcon("Movement").apply { color= Color.RED }
"Fortify" -> return ImageGetter.getImage("OtherIcons/Shield.png").apply { color= Color.BLACK }
"Promote" -> return ImageGetter.getImage("OtherIcons/Star.png").apply { color= Color.GOLD }
"Fortify" -> return ImageGetter.getImage("OtherIcons/Shield").apply { color= Color.BLACK }
"Promote" -> return ImageGetter.getImage("OtherIcons/Star").apply { color= Color.GOLD }
"Construct improvement" -> return ImageGetter.getUnitIcon("Worker")
"Automate" -> return ImageGetter.getUnitIcon("Great Engineer")
"Stop automation" -> return ImageGetter.getImage("OtherIcons/Stop.png")
"Stop automation" -> return ImageGetter.getImage("OtherIcons/Stop")
"Found city" -> return ImageGetter.getUnitIcon("Settler")
"Discover Technology" -> return ImageGetter.getUnitIcon("Great Scientist")
"Construct Academy" -> return ImageGetter.getImprovementIcon("Academy")
@ -38,13 +38,14 @@ class UnitActionsTable(val worldScreen: WorldScreen) : Table(){
"Conduct Trade Mission" -> return ImageGetter.getUnitIcon("Great Merchant")
"Construct Customs House" -> return ImageGetter.getImprovementIcon("Customs house")
"Set up" -> return ImageGetter.getUnitIcon("Catapult")
"Disband unit" -> return ImageGetter.getImage("OtherIcons/DisbandUnit.png")
"Sleep" -> return ImageGetter.getImage("OtherIcons/Sleep.png")
"Disband unit" -> return ImageGetter.getImage("OtherIcons/DisbandUnit")
"Sleep" -> return ImageGetter.getImage("OtherIcons/Sleep")
"Explore" -> return ImageGetter.getUnitIcon("Scout")
"Stop exploration" -> return ImageGetter.getImage("OtherIcons/Stop.png")
"Create Fishing Boats" -> return ImageGetter.getImprovementIcon("Fishing Boats")
"Create Oil well" -> return ImageGetter.getImprovementIcon("Oil well")
else -> return ImageGetter.getImage("OtherIcons/Star.png")
"Pillage" -> return ImageGetter.getImage("OtherIcons/Pillage")
else -> return ImageGetter.getImage("OtherIcons/Star")
}
}