Finished off promotions, adding Formation I, Formation II, Blitz, Logistics, Mobility, and Volley promotions

This commit is contained in:
Yair Morgenstern 2018-08-28 12:12:14 +03:00
parent 6e2eaa20a8
commit 40db822a79
15 changed files with 250 additions and 158 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 472 KiB

After

Width:  |  Height:  |  Size: 491 KiB

View file

@ -76,7 +76,7 @@
{
name:"Scouting II",
prerequisites:["Scouting I"],
effect:"+1 Visibility Range",
effect:"+1 Movement",
unitTypes:["Scout"]
}
{
@ -110,9 +110,15 @@
}
{
name:"Siege",
prerequisites:["Accuracy I","Barrage I","Shock II","Drill II"],
effect:"Bonus vs City 25%",
unitTypes:["Melee","Ranged","Siege","Mounted"]
prerequisites:["Shock II","Drill II"],
effect:"Bonus vs City 50%",
unitTypes:["Melee"]
}
{
name:"Volley",
prerequisites:["Accuracy I","Barrage I"],
effect:"Bonus vs City 50%",
unitTypes:["Ranged","Siege"]
}
{
name:"Sentry",
@ -133,4 +139,35 @@
unitTypes:["Ranged","Siege"]
}
{
name:"Formation I",
prerequisites:["Shock II","Drill II"],
effect:"Bonus vs Mounted 33%",
unitTypes:["Melee","Mounted"]
}
{
name:"Formation II",
prerequisites:["Formation I"],
effect:"Bonus vs Mounted 33%",
unitTypes:["Melee","Mounted"]
}
{
name:"Blitz",
prerequisites:["Shock III","Drill III"],
effect:"1 additional attack per turn",
unitTypes:["Melee","Mounted"]
}
{
name:"Logistics",
prerequisites:["Accuracy III","Barrage III"],
effect:"1 additional attack per turn",
unitTypes:["Ranged","Siege"]
}
{
name:"Mobility",
prerequisites:["Shock III","Drill III"],
effect:"+1 Movement",
unitTypes:["Mounted"]
}
]

View file

@ -76,7 +76,8 @@ class Battle(val gameInfo:GameInfo) {
if(attacker is MapUnitCombatant) {
val unit = attacker.unit
if (unit.hasUnique("Can move after attacking")){
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)
}

View file

@ -11,7 +11,7 @@ class BattleDamage{
private fun getBattleDamageModifiersOfUnit(unit:MapUnit): MutableList<BattleDamageModifier> {
val modifiers = mutableListOf<BattleDamageModifier>()
for (ability in unit.getSpecialAbilities()) {
for (ability in unit.getUniques()) {
// This beut allows us to have generic unit uniques: "Bonus vs City 75%", "Penatly vs Mounted 25%" etc.
val regexResult = Regex("""(Bonus|Penalty) vs (.*) (\d*)%""").matchEntire(ability)
if (regexResult == null) continue
@ -87,7 +87,7 @@ class BattleDamage{
}
if(attacker.isRanged()){
val defenceVsRanged = 0.25f * defender.unit.getSpecialAbilities().count{it=="+25% Defence against ranged attacks"}
val defenceVsRanged = 0.25f * defender.unit.getUniques().count{it=="+25% Defence against ranged attacks"}
if(defenceVsRanged>0) modifiers["defence vs ranged"] = defenceVsRanged
}

View file

@ -37,14 +37,18 @@ class MapUnit {
fun baseUnit(): BaseUnit = baseUnit
fun getMovementString(): String = DecimalFormat("0.#").format(currentMovement.toDouble()) + "/" + getMaxMovement()
fun getTile(): TileInfo = currentTile
fun getMaxMovement() = baseUnit.movement
fun getMaxMovement(): Int {
var movement = baseUnit.movement
movement += getUniques().count{it=="+1 Movement"}
return movement
}
fun getDistanceToTiles(): HashMap<TileInfo, Float> {
val tile = getTile()
return movementAlgs().getDistanceToTilesWithinTurn(tile.position,currentMovement)
}
fun getSpecialAbilities(): MutableList<String> {
fun getUniques(): MutableList<String> {
val abilities = mutableListOf<String>()
val baseUnit = baseUnit()
if(baseUnit.uniques!=null) abilities.addAll(baseUnit.uniques!!)
@ -53,12 +57,12 @@ class MapUnit {
}
fun hasUnique(unique:String): Boolean {
return getSpecialAbilities().contains(unique)
return getUniques().contains(unique)
}
fun getViewableTiles(): MutableList<TileInfo> {
var visibilityRange = 2
visibilityRange += getSpecialAbilities().count{it=="+1 Visibility Range"}
visibilityRange += getUniques().count{it=="+1 Visibility Range"}
if(hasUnique("Limited Visibility")) visibilityRange-=1
val tile = getTile()
if (tile.baseTerrain == "Hill") visibilityRange += 1
@ -102,7 +106,8 @@ class MapUnit {
fun canAttack(): Boolean {
if(currentMovement==0f) return false
if(attacksThisTurn>0) return false
if(attacksThisTurn>0 && !hasUnique("1 additional attack per turn")) return false
if(attacksThisTurn>1) return false
if(hasUnique("Must set up to ranged attack") && action != "Set Up") return false
return true
}
@ -211,7 +216,7 @@ class MapUnit {
fun endTurn() {
doPostTurnAction()
if(currentMovement== getMaxMovement().toFloat() // didn't move this turn
|| getSpecialAbilities().contains("Unit will heal every turn, even if it performs an action")){
|| getUniques().contains("Unit will heal every turn, even if it performs an action")){
heal()
}
}

View file

@ -76,8 +76,8 @@ class BaseUnit : INamed, IConstruction, ICivilopedia {
fun getMapUnit(): MapUnit {
val unit = MapUnit()
unit.name = name
unit.currentMovement = movement.toFloat()
unit.setTransients()
unit.setTransients() // must be after setting name because it sets the bseUnit according to the name
unit.currentMovement = unit.getMaxMovement().toFloat() // must be after setTransients because it relies on having the baseUnit set
return unit
}