More unit information and combat mechanics fixes

This commit is contained in:
Yair Morgenstern
2018-05-08 11:56:51 +03:00
parent 3fcc1fd042
commit c3a51460b7
10 changed files with 44 additions and 22 deletions

View File

@ -46,8 +46,6 @@ class UnitAutomation{
if(unit.name.startsWith("Great")) return // DON'T MOVE A MUSCLE
if(unit.getTile().isCityCenter()) return // It's always good to have a unit in the city center
if (unit.health < 50) {
healUnit(unit)
return
@ -78,6 +76,9 @@ class UnitAutomation{
}
}
if(unit.getTile().isCityCenter()) return // It's always good to have a unit in the city center, so if you havn't found annyonw aroud to attack, forget it.
if (unit.health < 80) {
healUnit(unit)
return

View File

@ -94,7 +94,7 @@ class Battle(val gameInfo:GameInfo) {
var damageToDefender = calculateDamageToDefender(attacker,defender)
var damageToAttacker = calculateDamageToAttacker(attacker,defender)
if(defender.getUnitType() == CombatantType.Civilian){
if(defender.getUnitType() == UnitType.Civilian){
defender.takeDamage(100) // kill
}
else if (attacker.isRanged()) {
@ -127,7 +127,7 @@ class Battle(val gameInfo:GameInfo) {
if (attacker.isDefeated()) " was destroyed while attacking"
else " has " + (if (defender.isDefeated()) "destroyed" else "attacked")
val defenderString =
if (defender.getUnitType() == CombatantType.City) defender.getName()
if (defender.getUnitType() == UnitType.City) defender.getName()
else " our " + defender.getName()
val notificationString = "An enemy " + attacker.getName() + whatHappenedString + defenderString
gameInfo.getPlayerCivilization().addNotification(notificationString, attackedTile.position)
@ -135,7 +135,7 @@ class Battle(val gameInfo:GameInfo) {
if(defender.isDefeated()
&& defender.getUnitType() == CombatantType.City
&& defender.getUnitType() == UnitType.City
&& attacker.isMelee()){
conquerCity((defender as CityCombatant).city, attacker)
}
@ -154,7 +154,7 @@ class Battle(val gameInfo:GameInfo) {
city.civInfo = attacker.getCivilization()
city.health = city.getMaxHealth() / 2 // I think that cities recover to half health?
city.getCenterTile().unit = null
city.expansion.cultureStored = 0;
city.expansion.cultureStored = 0
city.expansion.reset()
// now that the tiles have changed, we need to reassign population

View File

@ -28,7 +28,7 @@ class CityCombatant(val city: CityInfo) : ICombatant {
// as tech progresses so does city strength
val techsPercentKnown: Float = city.civInfo.tech.techsResearched.count().toFloat() /
GameBasics.Technologies.count()
val strengthFromTechs = Math.pow(techsPercentKnown*5.0,2.0) *5
val strengthFromTechs = Math.pow(techsPercentKnown*3.0,2.0) *5
// The way all of this adds up...
// 25% of the way through the game provides an extra 3.12

View File

@ -9,15 +9,32 @@ import com.unciv.models.stats.INamed
class Unit : INamed, IConstruction, ICivilopedia {
override val description: String
get(){
val sb = StringBuilder()
sb.appendln(baseDescription)
if(unbuildable) sb.appendln("Unbuildable")
else sb.appendln("Cost: $cost")
if(strength!=0) sb.appendln("Strength: $strength")
if(rangedStrength!=0) sb.appendln("Ranged strength: $rangedStrength")
return sb.toString()
return getDescription(false)
}
fun getDescription(forPickerScreen:Boolean): String {
val sb = StringBuilder()
if(baseDescription!="") sb.appendln(baseDescription)
if(!forPickerScreen) {
if (unbuildable) sb.appendln("Unbuildable")
else sb.appendln("Cost: $cost")
if(requiredResource!=null) sb.appendln("Required resource: $requiredResource")
if(requiredTech!=null) sb.appendln("Required tech: $requiredTech")
}
if(strength!=0){
sb.append("Strength: $strength")
if(rangedStrength!=0) sb.append(", Ranged strength: $rangedStrength")
sb.appendln()
}
if(uniques!=null){
for(unique in uniques!!)
sb.appendln(unique)
}
sb.appendln("Movement: $movement")
return sb.toString()
}
override lateinit var name: String
var baseDescription: String? = null
var cost: Int = 0
@ -30,6 +47,7 @@ class Unit : INamed, IConstruction, ICivilopedia {
var requiredTech:String? = null
var requiredResource:String? = null
var uniques:HashSet<String>?=null
var upgradesTo:String? = null
fun getMapUnit(): MapUnit {
val unit = MapUnit()

View File

@ -60,7 +60,7 @@ class ConstructionPickerScreen(val city: CityInfo) : PickerScreen() {
for (unit in GameBasics.Units.values.filter { it.isBuildable(cityConstructions)}) {
units.addActor(getProductionButton(unit.name,
unit.name + "\r\n" + cityConstructions.turnsToConstruction(unit.name) + " turns",
unit.baseDescription, "Train " + unit.name))
unit.getDescription(true), "Train " + unit.name))
}
if (civInfo.tech.isResearched("Education"))

View File

@ -4,7 +4,10 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.ui.Label
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
import com.unciv.logic.battle.*
import com.unciv.logic.battle.Battle
import com.unciv.logic.battle.CityCombatant
import com.unciv.logic.battle.ICombatant
import com.unciv.logic.battle.MapUnitCombatant
import com.unciv.logic.map.TileInfo
import com.unciv.logic.map.UnitType
import com.unciv.ui.cityscreen.addClickListener
@ -120,7 +123,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
val attackerCanReachDefender:Boolean
var tileToMoveTo:TileInfo? = null
if(attacker.getCombatantType() == CombatantType.Melee){
if(attacker.isMelee()){
if(attacker.getTile().neighbors.contains(defender.getTile())){
attackerCanReachDefender=true
}

View File

@ -108,7 +108,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
when(unit.getBaseUnit().unitType){
UnitType.Civilian -> return
UnitType.Melee, UnitType.Mounted -> attackableTiles = unit.getDistanceToTiles().keys.toList()
UnitType.Ranged, UnitType.Siege -> attackableTiles = unit.getTile().getTilesInDistance(2)
UnitType.Archery, UnitType.Siege -> attackableTiles = unit.getTile().getTilesInDistance(2)
UnitType.City -> throw Exception("How are you attacking with a city?")
}

View File

@ -47,7 +47,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
unitLabelText += "\r\nHealth: " + unit.health +
"\r\nStrength: " + unit.getBaseUnit().strength
}
if (unit.getBaseUnit().unitType == UnitType.Ranged)
if (unit.getBaseUnit().rangedStrength!=0)
unitLabelText += "\r\nRanged strength: "+unit.getBaseUnit().rangedStrength
unitLabel.setText(unitLabelText)