Fixed square numbers in stats
This commit is contained in:
@@ -54,7 +54,7 @@ public class PayloadConveyor extends Block{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(Stat.payloadCapacity, (payloadLimit), StatUnit.blocksSquared);
|
||||
stats.add(Stat.payloadCapacity, StatValues.squared(payloadLimit, StatUnit.blocksSquared));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -78,7 +78,7 @@ public class PayloadMassDriver extends PayloadBlock{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(Stat.payloadCapacity, maxPayloadSize, StatUnit.blocksSquared);
|
||||
stats.add(Stat.payloadCapacity, StatValues.squared(maxPayloadSize, StatUnit.blocksSquared));
|
||||
stats.add(Stat.reload, 60f / (chargeTime + reloadTime), StatUnit.seconds);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,11 +34,22 @@ public class StatValues{
|
||||
return table -> table.add(!value ? "@no" : "@yes");
|
||||
}
|
||||
|
||||
public static String fixValue(float value){
|
||||
int precision = Math.abs((int)value - value) <= 0.001f ? 0 : Math.abs((int)(value * 10) - value * 10) <= 0.001f ? 1 : 2;
|
||||
return Strings.fixed(value, precision);
|
||||
}
|
||||
|
||||
public static StatValue squared(float value, StatUnit unit){
|
||||
return table -> {
|
||||
String fixed = fixValue(value);
|
||||
table.add(fixed + "x" + fixed);
|
||||
table.add((unit.space ? " " : "") + unit.localized());
|
||||
};
|
||||
}
|
||||
|
||||
public static StatValue number(float value, StatUnit unit, boolean merge){
|
||||
return table -> {
|
||||
int precision = Math.abs((int)value - value) <= 0.001f ? 0 : Math.abs((int)(value * 10) - value * 10) <= 0.001f ? 1 : 2;
|
||||
|
||||
String l1 = Strings.fixed(value, precision), l2 = (unit.space ? " " : "") + unit.localized();
|
||||
String l1 = fixValue(value), l2 = (unit.space ? " " : "") + unit.localized();
|
||||
|
||||
if(merge){
|
||||
table.add(l1 + l2);
|
||||
|
||||
Reference in New Issue
Block a user