Skip to content

Commit

Permalink
Normalize Brilliance card data to exclude underscores to prevent look…
Browse files Browse the repository at this point in the history
…up disparity

Agronet stores some cards as "quickstep", but Brilliance has "quick_step".
This way, it doesn't matter if one or the other has underscores or dashes.
  • Loading branch information
4Ply committed Jan 5, 2025
1 parent 1d7671d commit 792c802
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/main/kotlin/org/trackedout/RunContext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ data object RunContext {
var runId = UUID.randomUUID().toString()
var initialized = false

// Note that all keys are stored without underscores or dashes, e.g. "quickstep" and "suitup"
// This is due to a disparity between what Agronet vs Brilliance calls the card
var brillianceCards = mapOf<String, BrillianceCard>()

private val playerContextMap: ConcurrentMap<String, PlayerContext> = Maps.newConcurrentMap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ class AddDeckToPlayerInventoryAction(
cardCount.forEach { (cardName, countInDeck) ->
player.debug("- ${countInDeck}x $cardName")
val card = Cards.findCard(cardName)!!
val maxCopies = RunContext.brillianceCards[card.key]?.maxCopies
val maxCopies = RunContext.brillianceCards[card.key.replace("_", "").replace("-", "")]?.maxCopies
var count = min(countInDeck, maxCopies ?: countInDeck)
logger.info("$playerName's shulker should contain ${count}x $cardName (deck has $countInDeck, max copies is $maxCopies, deck contains $totalCards cards)")

if (countInDeck > (maxCopies ?: 0)) {
// If the player has more copies of a card than they should, log the new count that we're giving them
modificationLog["new-card-count-${cardName.replace("_", "-")}"] = "$count"
logger.warn("$playerName has too many copies of $cardName in their deck, truncating to $count")
player.sendMessage("You have too many copies of $cardName in your deck, truncating to $count", Formatting.RED)
player.sendMessage("You have too many copies of $cardName in your deck (max is $maxCopies and you have ${countInDeck}), truncating to $count", Formatting.RED)
}

// If the new cards would take the total over 40, truncate the count to only fill up to 40
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/org/trackedout/data/BrillianceScoreboards.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ data class BrillianceScoreboardDescription(
val auto: Int,
val target: String,
val category: String,
val displayText: String? = null,
val description: String,
val canEditForRunTypes: List<String>? = null,
val values: Map<String, String>? = mapOf(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class AgroNetPlayerConnectionListener(
}

parseBrillianceData<Map<String, BrillianceCard>>(resourceManager, "cards.json") { map ->
RunContext.brillianceCards = map
RunContext.brillianceCards = map.mapKeys { it.key.replace("-", "").replace("_", "") }
println("Card data from Brilliance: ${RunContext.brillianceCards}")
}
}
Expand Down

0 comments on commit 792c802

Please sign in to comment.