Skip to content

Commit

Permalink
Code cleanup, improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidArthurCole committed Oct 18, 2024
1 parent f1cf754 commit d706503
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ object CakeTracker {
*/
private val auctionBrowserPattern by patternGroup.pattern(
"auction.search",
"^(Auctions Browser|Auctions: \".*)$",
"^(?:Auctions Browser|Auctions: \".*)$",
)

/**
Expand All @@ -101,10 +101,10 @@ object CakeTracker {
}

@Expose
var cakesOwned: MutableList<Int> = mutableListOf()
var cakesOwned: MutableSet<Int> = mutableSetOf()

@Expose
var cakesMissing: MutableList<Int> = mutableListOf()
var cakesMissing: MutableSet<Int> = mutableSetOf()
}

private fun addCake(cakeYear: Int) {
Expand Down Expand Up @@ -224,9 +224,9 @@ object CakeTracker {
private fun recalculateMissingCakes() {
val cakeTrackerData = getCakeTrackerData() ?: return
tracker.modify {
it.cakesMissing = (1..currentYear).filterNot {
year -> cakeTrackerData.cakesOwned.contains(year)
}.toMutableList()
it.cakesMissing = (1..currentYear).filterNot { year ->
cakeTrackerData.cakesOwned.contains(year)
}.toMutableSet()
}
}

Expand All @@ -238,7 +238,7 @@ object CakeTracker {
val stringRenderable =
Renderable.string(
if (end != 0) "§fYears $colorCode$start§f-$colorCode$end"
else "§fYear $colorCode$start"
else "§fYear $colorCode$start",
)
return if (displayType == CakeTrackerDisplayType.MISSING_CAKES) Renderable.link(
stringRenderable,
Expand Down Expand Up @@ -268,17 +268,17 @@ object CakeTracker {
ownedString,
{ setDisplayType(CakeTrackerDisplayType.OWNED_CAKES) },
condition = { config.displayType != CakeTrackerDisplayType.OWNED_CAKES },
)
),
)
add(Renderable.string(" §7§l- §r"))
add(
Renderable.optionalLink(
missingString,
{ setDisplayType(CakeTrackerDisplayType.MISSING_CAKES) },
condition = { config.displayType != CakeTrackerDisplayType.MISSING_CAKES },
)
),
)
}
},
)

private fun setDisplayOrderType(type: CakeTrackerDisplayOrderType) {
Expand All @@ -302,17 +302,17 @@ object CakeTracker {
newestString,
{ setDisplayOrderType(CakeTrackerDisplayOrderType.NEWEST_FIRST) },
condition = { config.displayOrderType != CakeTrackerDisplayOrderType.NEWEST_FIRST },
)
),
)
add(Renderable.string(" §7§l- §r"))
add(
Renderable.optionalLink(
oldestString,
{ setDisplayOrderType(CakeTrackerDisplayOrderType.OLDEST_FIRST) },
condition = { config.displayOrderType != CakeTrackerDisplayOrderType.OLDEST_FIRST },
)
),
)
}
},
)

private fun drawDisplay(data: Data): List<Searchable> = buildList {
Expand Down Expand Up @@ -340,7 +340,7 @@ object CakeTracker {
CakeTrackerDisplayOrderType.OLDEST_FIRST -> cakeList.sorted()
CakeTrackerDisplayOrderType.NEWEST_FIRST -> cakeList.sortedDescending()
null -> cakeList
}
}.toMutableList()

// Combine consecutive years into ranges
val cakeRanges = mutableListOf<CakeRange>()
Expand Down

0 comments on commit d706503

Please sign in to comment.