Once a unit has gained more than 30 XP it won't gain XP from barbarians

AI units now always unfortify/unsetup after moving
This commit is contained in:
Yair Morgenstern
2018-08-30 22:13:07 +03:00
parent 1227a47ea2
commit 2605ce6b71
7 changed files with 213 additions and 179 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 627 KiB

After

Width:  |  Height:  |  Size: 630 KiB

View File

@ -21,8 +21,8 @@ android {
applicationId "com.unciv.game"
minSdkVersion 14
targetSdkVersion 26
versionCode 132
versionName "2.8.0"
versionCode 133
versionName "2.8.1"
}
buildTypes {
release {

View File

@ -87,16 +87,23 @@ class Battle(val gameInfo:GameInfo) {
}
// XP!
fun addXp(thisCombatant:ICombatant, amount:Int, otherCombatant:ICombatant){
if(thisCombatant !is MapUnitCombatant) return
if(thisCombatant.unit.promotions.totalXpProduced() >= 30 && otherCombatant.getCivilization().isBarbarianCivilization())
return
thisCombatant.unit.promotions.XP += amount
}
if(attacker.isMelee()){
if(defender.getUnitType()!=UnitType.Civilian) // unit was not captured but actually attacked
{
if (attacker is MapUnitCombatant) attacker.unit.promotions.XP += 5
if (defender is MapUnitCombatant) defender.unit.promotions.XP += 4
addXp(attacker,5,defender)
addXp(defender,4,attacker)
}
}
else{ // ranged attack
if(attacker is MapUnitCombatant) attacker.unit.promotions.XP += 2
if(defender is MapUnitCombatant) defender.unit.promotions.XP += 2
addXp(attacker,2,defender)
addXp(defender,2,attacker)
}
if(attacker is MapUnitCombatant && attacker.unit.action!=null && attacker.unit.action!!.startsWith("moveTo"))

View File

@ -209,6 +209,7 @@ class MapUnit {
currentMovement -= distanceToTiles[otherTile]!!
if (currentMovement < 0.1) currentMovement = 0f // silly floats which are "almost zero"
if(isFortified() || action=="Set Up") action=null // unfortify/setup after moving
removeFromTile()
putInTile(otherTile)
}

View File

@ -7,7 +7,10 @@ class UnitPromotions{
@Transient lateinit var unit:MapUnit
var XP=0
var promotions = HashSet<String>()
var numberOfPromotions = 0 // The number of times this unit has been promoted - some promotions don't come from being promoted but from other things!
// The number of times this unit has been promoted
// some promotions don't come from being promoted but from other things,
// like from being constructed in a specific city etc.
var numberOfPromotions = 0
fun xpForNextPromotion() = (numberOfPromotions+1)*10
fun canBePromoted() = XP >= xpForNextPromotion()
@ -31,4 +34,11 @@ class UnitPromotions{
toReturn.numberOfPromotions=numberOfPromotions
return toReturn
}
fun totalXpProduced(): Int {
var sum = XP
for(i in 1..numberOfPromotions) sum += 10*i
return sum
}
}

View File

@ -2,20 +2,22 @@ package com.unciv.game.desktop;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.tools.texturepacker.TexturePacker;
import com.unciv.UnCivGame;
class DesktopLauncher {
public static void main (String[] arg) {
// TexturePacker.Settings settings = new TexturePacker.Settings();
// settings.maxWidth = 2048;
// settings.maxHeight = 2048;
// settings.combineSubdirectories=true;
//
// // This is so they don't look all pixelated
// settings.filterMag = Texture.TextureFilter.MipMapLinearLinear;
// settings.filterMin = Texture.TextureFilter.MipMapLinearLinear;
// TexturePacker.process(settings, "../images", ".", "game");
TexturePacker.Settings settings = new TexturePacker.Settings();
settings.maxWidth = 2048;
settings.maxHeight = 2048;
settings.combineSubdirectories=true;
// This is so they don't look all pixelated
settings.filterMag = Texture.TextureFilter.MipMapLinearLinear;
settings.filterMin = Texture.TextureFilter.MipMapLinearLinear;
TexturePacker.process(settings, "../images", ".", "game");
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
new LwjglApplication(new UnCivGame(), config);