Skip to content

Commit

Permalink
1.0.30 (Are we ready?)
Browse files Browse the repository at this point in the history
Added caught tracker on item hover
  • Loading branch information
Rafacasari committed Jun 29, 2024
1 parent 504979f commit 0e3d816
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,31 @@ class CobbledexItem(settings: Settings) : Item(settings) {
get() {
return CobbledexConstants.Client.discoveredList.size
}



val totalPokemonCaught: Int
get() {
return CobbledexConstants.Client.discoveredList.filter {
it.value.any { form -> form.value.status == DiscoveryRegister.RegisterType.CAUGHT}
}.size
}

// val totalFormsDiscovered: Int
// get() {
// return CobbledexConstants.Client.discoveredList.flatMap {
// it.value.values
// }.size
// }
//
// val totalFormsCaught: Int
// get() {
// return CobbledexConstants.Client.discoveredList.flatMap {
// it.value.values
// }.filter {
// it.status == DiscoveryRegister.RegisterType.CAUGHT
// }.size
// }
}

private val totalPokemonCount: Int
Expand All @@ -36,11 +61,19 @@ class CobbledexItem(settings: Settings) : Item(settings) {

override fun appendTooltip(stack: ItemStack, world: World?, tooltip: MutableList<Text>, context: TooltipContext)
{
val percentageDiscovered = "%.2f%%".format((totalPokemonDiscovered.toDouble() / totalPokemonCount) * 100)
val percentageCaught = "%.2f%%".format((totalPokemonCaught.toDouble() / totalPokemonCount) * 100)
val translationDiscovered = cobbledexTextTranslation("tooltip_description.discovered", totalPokemonDiscovered.toString().text().formatted(Formatting.GREEN), totalPokemonCount.toString(), percentageDiscovered)
val translationCaught = cobbledexTextTranslation("tooltip_description.caught", totalPokemonCaught.toString().text().formatted(Formatting.GREEN), totalPokemonCount.toString(), percentageCaught)


val percentage = "%.2f%%".format((totalPokemonDiscovered.toDouble() / totalPokemonCount) * 100)
val translation = cobbledexTextTranslation("tooltip_description.discovered", totalPokemonDiscovered.toString().text().formatted(Formatting.GREEN), totalPokemonCount.toString(), percentage)
tooltip.add(translation)
tooltip.add(translationDiscovered)
tooltip.add(translationCaught)

// val formsDiscoveredTranslation = cobbledexTextTranslation("tooltip_description.total_forms_discovered", totalFormsDiscovered.toString().text().formatted(Formatting.GREEN))
// val formsCaughtTranslation = cobbledexTextTranslation("tooltip_description.total_forms_caught", totalFormsCaught.toString().text().formatted(Formatting.GREEN))
// tooltip.add(formsDiscoveredTranslation)
// tooltip.add(formsCaughtTranslation)

tooltip.add(MutableText.of(TextContent.EMPTY))
if (Screen.hasShiftDown()) {
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/resources/assets/cobbledex/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
"cobbledex.texts.new_pokemon_discovered": "You've discovered a new Pokémon: %s",
"cobbledex.texts.click_to_open_cobbledex": "Click to open in Cobbledex",
"cobbledex.texts.tooltip_description.discovered": "Discovered: %s/%s (%s)",
"cobbledex.texts.tooltip_description.total_forms_discovered": "Forms discovered: %s",
"cobbledex.texts.tooltip_description.caught": "Caught: %s/%s (%s)",
"cobbledex.texts.tooltip_description.total_forms_caught": "Forms caught: %s",
"cobbledex.texts.tooltip_description.press_shift": "Hold <Shift> for instructions",
"cobbledex.texts.tooltip_description.instructions1": "§a§lRight-Click§r a Pokémon to mark as seen",
"cobbledex.texts.tooltip_description.instructions2": "§a§lRight-Click§r a Pokémon to open §lInformation GUI§r",
Expand Down

0 comments on commit 0e3d816

Please sign in to comment.