Better Ability Stats (#9654)

* Fix armor plate multiplier + change Math.round to Strings.autoFixed

* Missing ability name bundles

* Center ability name

* SuppressionFieldAbility stats

* Is two per row is acceptable?

I can revert this commit if not.

* LiquidExplodeAbility stat display

* MoveLightningAbility stat display

* Better SpawnDeathAbility display

* Fix multiplier coloring inconsistencies

Some had [lightgray] before %/x, some had it after

* Consistent content name display

Match with bullet status effects

* Consistent stat formatting

Convert from some being "stat: #" and some being "# stat" to all being "# stat"

* Re-order stats

* Optimize Imports

* Add ability descriptions

* Apparently I forgot LiquidRegenAbility

* Mention healing allies if displayHeal = true
This commit is contained in:
MEEPofFaith
2024-03-29 21:11:39 -07:00
committed by GitHub
parent d8c1ea17e1
commit 2fb5bc56c6
18 changed files with 182 additions and 80 deletions

View File

@@ -6,6 +6,7 @@ import mindustry.gen.*;
import mindustry.type.*;
public abstract class Ability implements Cloneable{
protected static final float descriptionWidth = 350f;
/** If false, this ability does not show in unit stats. */
public boolean display = true;
//the one and only data variable that is synced.
@@ -16,7 +17,16 @@ public abstract class Ability implements Cloneable{
public void death(Unit unit){}
public void init(UnitType type){}
public void displayBars(Unit unit, Table bars){}
public void addStats(Table t){}
public void addStats(Table t){
if(Core.bundle.has(getBundle() + ".description")){
t.add(Core.bundle.get(getBundle() + ".description")).wrap().width(descriptionWidth);
t.row();
}
}
public String abilityStat(String stat, Object... values){
return Core.bundle.format("ability.stat." + stat, values);
}
public Ability copy(){
try{
@@ -29,7 +39,11 @@ public abstract class Ability implements Cloneable{
/** @return localized ability name; mods should override this. */
public String localized(){
return Core.bundle.get(getBundle());
}
public String getBundle(){
var type = getClass();
return Core.bundle.get("ability." + (type.isAnonymousClass() ? type.getSuperclass() : type).getSimpleName().replace("Ability", "").toLowerCase());
return "ability." + (type.isAnonymousClass() ? type.getSuperclass() : type).getSimpleName().replace("Ability", "").toLowerCase();
}
}