Skip to content

Commit

Permalink
Backend: Cleaner visitor rarity handling (#2220)
Browse files Browse the repository at this point in the history
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
  • Loading branch information
lunaynx and hannibal002 authored Jul 15, 2024
1 parent 73f2443 commit 9e0ffec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ data class GardenJson(
)

data class GardenVisitor(
@Expose val rarity: LorenzRarity,
@Expose @SerializedName("new_rarity") val newRarity: LorenzRarity?,
@Expose @SerializedName("rarity") private val _rarity: LorenzRarity,
@Expose @SerializedName("new_rarity") private val _newRarity: LorenzRarity?,
@Expose val position: LorenzVec?,
@Expose var skinOrType: String?,
@Expose val mode: String,
@Expose @SerializedName("need_items") val needItems: List<String>,
)
) {
val rarity: LorenzRarity
get() = _newRarity ?: _rarity
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ object GardenVisitorColorNames {
visitorColours.clear()
visitorItems.clear()
for ((visitor, visitorData) in data.visitors) {
val rarity = visitorData.newRarity ?: visitorData.rarity
visitorColours[visitor] = rarity.color.getChatColor()
visitorColours[visitor] = visitorData.rarity.color.getChatColor()
visitorItems[visitor] = visitorData.needItems
}
}
Expand Down

0 comments on commit 9e0ffec

Please sign in to comment.