StackFormatter: remove quantityToRSStackSize

This is nearly unused, and serves no great purpose as
quantityToStackSize can display the same information in a more readable
format
This commit is contained in:
Max Weber
2019-10-10 03:49:44 -06:00
parent 7ea68d7e72
commit 32f624e1d5
4 changed files with 8 additions and 59 deletions

View File

@@ -340,7 +340,7 @@ public class ItemStatPlugin extends Plugin
createSeparator(invContainer, invContainer.getHeight() - 40);
final String coinText = "You have " + StackFormatter.quantityToRSStackSize(getCurrentGP())
final String coinText = "You have " + StackFormatter.quantityToStackSize(getCurrentGP())
+ (getCurrentGP() == 1 ? " coin." : " coins.");
final Widget coinWidget = createText(invContainer, coinText, FontID.PLAIN_12, ORANGE_TEXT,

View File

@@ -48,6 +48,6 @@ public class KingdomCounter extends Counter
public String getTooltip()
{
return "Favor: " + plugin.getFavor() + "/127" + "</br>"
+ "Coffer: " + StackFormatter.quantityToRSStackSize(plugin.getCoffer());
+ "Coffer: " + StackFormatter.quantityToStackSize(plugin.getCoffer());
}
}

View File

@@ -33,8 +33,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* A set of utility functions to use when
* formatting numbers for to stack sizes.
* A set of utility functions to use when formatting quantities
*/
public class StackFormatter
{
@@ -70,12 +69,12 @@ public class StackFormatter
);
/**
* Convert a quantity to a nicely formatted stack size.
* See the StackFormatterTest to see expected output.
* Convert a quantity to a short, comma separated, SI-prefix style string
*
* example: {@code 9,450}, {@code 2.14B}, {@code 100K}
*
* @param quantity The quantity to convert.
* @return A condensed version, with commas, K, M or B
* as needed to 3 significant figures.
* @return a 6 or less character string, possibly with a decimal point, commas or K/M/B suffix
*/
public static String quantityToStackSize(long quantity)
{
@@ -115,41 +114,7 @@ public class StackFormatter
}
/**
* Convert a quantity to stack size as it would
* appear in RuneScape.
*
* @param quantity The quantity to convert.
* @return The stack size as it would appear in RS,
* with K after 100,000 and M after 10,000,000
*/
public static String quantityToRSStackSize(int quantity)
{
if (quantity == Integer.MIN_VALUE)
{
// Integer.MIN_VALUE = Integer.MIN_VALUE * -1 so we need to correct for it.
return "-" + quantityToRSStackSize(Integer.MAX_VALUE);
}
else if (quantity < 0)
{
return "-" + quantityToRSStackSize(-quantity);
}
else if (quantity < 100_000)
{
return Integer.toString(quantity);
}
else if (quantity < 10_000_000)
{
return quantity / 1_000 + "K";
}
else
{
return quantity / 1_000_000 + "M";
}
}
/**
* Convert a quantity to stack size as it would
* appear in RuneScape. (with decimals)
* Convert a quantity to a short SI-prefix style string with decimals
* <p>
* This differs from quantityToRSStack in that it displays
* decimals. Ex: 27100 is 27.1k (not 27k)

View File

@@ -59,22 +59,6 @@ public class StackFormatterTest
assertEquals("2.1B", StackFormatter.quantityToRSDecimalStack(Integer.MAX_VALUE));
}
@Test
public void quantityToRSStackSize()
{
assertEquals("0", StackFormatter.quantityToRSStackSize(0));
assertEquals("99999", StackFormatter.quantityToRSStackSize(99_999));
assertEquals("100K", StackFormatter.quantityToRSStackSize(100_000));
assertEquals("10M", StackFormatter.quantityToRSStackSize(10_000_000));
assertEquals("2147M", StackFormatter.quantityToRSStackSize(Integer.MAX_VALUE));
assertEquals("0", StackFormatter.quantityToRSStackSize(-0));
assertEquals("-400", StackFormatter.quantityToRSStackSize(-400));
assertEquals("-400K", StackFormatter.quantityToRSStackSize(-400_000));
assertEquals("-40M", StackFormatter.quantityToRSStackSize(-40_000_000));
assertEquals("-2147M", StackFormatter.quantityToRSStackSize(Integer.MIN_VALUE));
}
@Test
public void quantityToStackSize()
{