mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-23 22:30:18 +07:00
More unit information and combat mechanics fixes
This commit is contained in:
@ -17,7 +17,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"Scout",
|
name:"Scout",
|
||||||
baseDescription: "Has no abilites, can only explore",
|
baseDescription: "",
|
||||||
cost:25,
|
cost:25,
|
||||||
unitType:"Melee",
|
unitType:"Melee",
|
||||||
strength:5,
|
strength:5,
|
||||||
|
@ -21,8 +21,8 @@ android {
|
|||||||
applicationId "com.unciv.game"
|
applicationId "com.unciv.game"
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 47
|
versionCode 48
|
||||||
versionName "2.0.4"
|
versionName "2.1.0"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
@ -46,8 +46,6 @@ class UnitAutomation{
|
|||||||
|
|
||||||
if(unit.name.startsWith("Great")) return // DON'T MOVE A MUSCLE
|
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) {
|
if (unit.health < 50) {
|
||||||
healUnit(unit)
|
healUnit(unit)
|
||||||
return
|
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) {
|
if (unit.health < 80) {
|
||||||
healUnit(unit)
|
healUnit(unit)
|
||||||
return
|
return
|
||||||
|
@ -94,7 +94,7 @@ class Battle(val gameInfo:GameInfo) {
|
|||||||
var damageToDefender = calculateDamageToDefender(attacker,defender)
|
var damageToDefender = calculateDamageToDefender(attacker,defender)
|
||||||
var damageToAttacker = calculateDamageToAttacker(attacker,defender)
|
var damageToAttacker = calculateDamageToAttacker(attacker,defender)
|
||||||
|
|
||||||
if(defender.getUnitType() == CombatantType.Civilian){
|
if(defender.getUnitType() == UnitType.Civilian){
|
||||||
defender.takeDamage(100) // kill
|
defender.takeDamage(100) // kill
|
||||||
}
|
}
|
||||||
else if (attacker.isRanged()) {
|
else if (attacker.isRanged()) {
|
||||||
@ -127,7 +127,7 @@ class Battle(val gameInfo:GameInfo) {
|
|||||||
if (attacker.isDefeated()) " was destroyed while attacking"
|
if (attacker.isDefeated()) " was destroyed while attacking"
|
||||||
else " has " + (if (defender.isDefeated()) "destroyed" else "attacked")
|
else " has " + (if (defender.isDefeated()) "destroyed" else "attacked")
|
||||||
val defenderString =
|
val defenderString =
|
||||||
if (defender.getUnitType() == CombatantType.City) defender.getName()
|
if (defender.getUnitType() == UnitType.City) defender.getName()
|
||||||
else " our " + defender.getName()
|
else " our " + defender.getName()
|
||||||
val notificationString = "An enemy " + attacker.getName() + whatHappenedString + defenderString
|
val notificationString = "An enemy " + attacker.getName() + whatHappenedString + defenderString
|
||||||
gameInfo.getPlayerCivilization().addNotification(notificationString, attackedTile.position)
|
gameInfo.getPlayerCivilization().addNotification(notificationString, attackedTile.position)
|
||||||
@ -135,7 +135,7 @@ class Battle(val gameInfo:GameInfo) {
|
|||||||
|
|
||||||
|
|
||||||
if(defender.isDefeated()
|
if(defender.isDefeated()
|
||||||
&& defender.getUnitType() == CombatantType.City
|
&& defender.getUnitType() == UnitType.City
|
||||||
&& attacker.isMelee()){
|
&& attacker.isMelee()){
|
||||||
conquerCity((defender as CityCombatant).city, attacker)
|
conquerCity((defender as CityCombatant).city, attacker)
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ class Battle(val gameInfo:GameInfo) {
|
|||||||
city.civInfo = attacker.getCivilization()
|
city.civInfo = attacker.getCivilization()
|
||||||
city.health = city.getMaxHealth() / 2 // I think that cities recover to half health?
|
city.health = city.getMaxHealth() / 2 // I think that cities recover to half health?
|
||||||
city.getCenterTile().unit = null
|
city.getCenterTile().unit = null
|
||||||
city.expansion.cultureStored = 0;
|
city.expansion.cultureStored = 0
|
||||||
city.expansion.reset()
|
city.expansion.reset()
|
||||||
|
|
||||||
// now that the tiles have changed, we need to reassign population
|
// now that the tiles have changed, we need to reassign population
|
||||||
|
@ -28,7 +28,7 @@ class CityCombatant(val city: CityInfo) : ICombatant {
|
|||||||
// as tech progresses so does city strength
|
// as tech progresses so does city strength
|
||||||
val techsPercentKnown: Float = city.civInfo.tech.techsResearched.count().toFloat() /
|
val techsPercentKnown: Float = city.civInfo.tech.techsResearched.count().toFloat() /
|
||||||
GameBasics.Technologies.count()
|
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...
|
// The way all of this adds up...
|
||||||
// 25% of the way through the game provides an extra 3.12
|
// 25% of the way through the game provides an extra 3.12
|
||||||
|
@ -9,15 +9,32 @@ import com.unciv.models.stats.INamed
|
|||||||
class Unit : INamed, IConstruction, ICivilopedia {
|
class Unit : INamed, IConstruction, ICivilopedia {
|
||||||
override val description: String
|
override val description: String
|
||||||
get(){
|
get(){
|
||||||
val sb = StringBuilder()
|
return getDescription(false)
|
||||||
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()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
override lateinit var name: String
|
||||||
var baseDescription: String? = null
|
var baseDescription: String? = null
|
||||||
var cost: Int = 0
|
var cost: Int = 0
|
||||||
@ -30,6 +47,7 @@ class Unit : INamed, IConstruction, ICivilopedia {
|
|||||||
var requiredTech:String? = null
|
var requiredTech:String? = null
|
||||||
var requiredResource:String? = null
|
var requiredResource:String? = null
|
||||||
var uniques:HashSet<String>?=null
|
var uniques:HashSet<String>?=null
|
||||||
|
var upgradesTo:String? = null
|
||||||
|
|
||||||
fun getMapUnit(): MapUnit {
|
fun getMapUnit(): MapUnit {
|
||||||
val unit = MapUnit()
|
val unit = MapUnit()
|
||||||
|
@ -60,7 +60,7 @@ class ConstructionPickerScreen(val city: CityInfo) : PickerScreen() {
|
|||||||
for (unit in GameBasics.Units.values.filter { it.isBuildable(cityConstructions)}) {
|
for (unit in GameBasics.Units.values.filter { it.isBuildable(cityConstructions)}) {
|
||||||
units.addActor(getProductionButton(unit.name,
|
units.addActor(getProductionButton(unit.name,
|
||||||
unit.name + "\r\n" + cityConstructions.turnsToConstruction(unit.name) + " turns",
|
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"))
|
if (civInfo.tech.isResearched("Education"))
|
||||||
|
@ -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.Label
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
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.TileInfo
|
||||||
import com.unciv.logic.map.UnitType
|
import com.unciv.logic.map.UnitType
|
||||||
import com.unciv.ui.cityscreen.addClickListener
|
import com.unciv.ui.cityscreen.addClickListener
|
||||||
@ -120,7 +123,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
|||||||
val attackerCanReachDefender:Boolean
|
val attackerCanReachDefender:Boolean
|
||||||
var tileToMoveTo:TileInfo? = null
|
var tileToMoveTo:TileInfo? = null
|
||||||
|
|
||||||
if(attacker.getCombatantType() == CombatantType.Melee){
|
if(attacker.isMelee()){
|
||||||
if(attacker.getTile().neighbors.contains(defender.getTile())){
|
if(attacker.getTile().neighbors.contains(defender.getTile())){
|
||||||
attackerCanReachDefender=true
|
attackerCanReachDefender=true
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
when(unit.getBaseUnit().unitType){
|
when(unit.getBaseUnit().unitType){
|
||||||
UnitType.Civilian -> return
|
UnitType.Civilian -> return
|
||||||
UnitType.Melee, UnitType.Mounted -> attackableTiles = unit.getDistanceToTiles().keys.toList()
|
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?")
|
UnitType.City -> throw Exception("How are you attacking with a city?")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
unitLabelText += "\r\nHealth: " + unit.health +
|
unitLabelText += "\r\nHealth: " + unit.health +
|
||||||
"\r\nStrength: " + unit.getBaseUnit().strength
|
"\r\nStrength: " + unit.getBaseUnit().strength
|
||||||
}
|
}
|
||||||
if (unit.getBaseUnit().unitType == UnitType.Ranged)
|
if (unit.getBaseUnit().rangedStrength!=0)
|
||||||
unitLabelText += "\r\nRanged strength: "+unit.getBaseUnit().rangedStrength
|
unitLabelText += "\r\nRanged strength: "+unit.getBaseUnit().rangedStrength
|
||||||
|
|
||||||
unitLabel.setText(unitLabelText)
|
unitLabel.setText(unitLabelText)
|
||||||
|
Reference in New Issue
Block a user