Skip to content

Commit

Permalink
Fix up display of red text when partner offers less
Browse files Browse the repository at this point in the history
  • Loading branch information
tristonplummer committed Apr 1, 2019
1 parent a97e322 commit 257aab2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/.idea/
/.gradle/
build/
out/
g=out/
gen/

gradlew
gradlew.bat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ fun Int.toLiteral() : String? {
*/
fun Int.formatRS2() : String {
return when {
this == Integer.MIN_VALUE -> "-${format()}"
this < 0 -> "-${(-this).format()}"
this == Integer.MIN_VALUE -> "-${formatRS2()}"
this < 0 -> "-${(-this).formatRS2()}"
this < 100_000 -> "$this"
this < 10_000_000 -> "${this / 1_000}K"
else -> "${this / 1_000_000}M"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,16 @@ class TradeSession(private val player: Player, private val partner: Player) {
val partnerValue = partner.getTradeSession()?.container?.getValue() ?: 0

// The prefix of each line
val prefix = if (partnerValue > containerValue) "<col=FF0000>" else ""

val playerPrefix = if (partnerValue > containerValue) "<col=FF0000>" else ""
val partnerPrefix = if (containerValue > partnerValue) "<col=FF0000>" else ""

// The value text displayed on the partner's side
val valueText = "%s%s offers:<br>%s(Value: <col=FFFFFF>%s</col>%s coins)"

// Set the value text
player.setComponentText(TRADE_INTERFACE, 24, "Your offer:<br>(Value: <col=FFFFFF>${containerValue.decimalFormat()}</col> coins)")
partner.setComponentText(TRADE_INTERFACE, 27, "$prefix${player.username} offers:<br>$prefix(Value: <col=FFFFFF>${containerValue.decimalFormat()}</col>$prefix coins)")
player.setComponentText(TRADE_INTERFACE, 27, valueText.format(partnerPrefix, partner.username, partnerPrefix, partnerValue.decimalFormat(), partnerPrefix))
partner.setComponentText(TRADE_INTERFACE, 27, valueText.format(playerPrefix, player.username, playerPrefix, containerValue.decimalFormat(), playerPrefix))
}

/**
Expand Down

0 comments on commit 257aab2

Please sign in to comment.