From 730a41522c3be8cf8d5ac3b72d1d4d64b74018a6 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 29 Oct 2024 10:28:45 +0500 Subject: feat: show the amount of purchased pets --- .../src/kz/ilotterytea/maxon/screens/game/shop/ShopUI.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'core/src/kz/ilotterytea/maxon/screens') diff --git a/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopUI.java b/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopUI.java index 76e5a04..b0b6d77 100644 --- a/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopUI.java +++ b/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopUI.java @@ -248,6 +248,9 @@ public class ShopUI { for (Pet pet : pets) { PetWidget widget = new PetWidget(this.skin, pet, this.atlas); + Integer amount = savegame.getPurchasedPets().get(pet.getId()); + if (amount == null) amount = 0; + widget.setAmount(amount); widget.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { @@ -258,12 +261,11 @@ public class ShopUI { return; } - if (mode == ShopMode.BUY) { - Integer amount = savegame.getPurchasedPets().get(pet.getId()); + Integer amount = savegame.getPurchasedPets().get(pet.getId()); + if (amount == null) amount = 0; - if (amount == null) { - amount = 0; - } + if (mode == ShopMode.BUY) { + widget.setAmount(amount + multiplier.getMultiplier()); savegame.decreaseMoney(widget.getPrice()); savegame.increaseMultiplier(pet.getMultiplier() * multiplier.getMultiplier()); @@ -273,6 +275,8 @@ public class ShopUI { ); purchaseSound.play(soundVolume); } else { + widget.setAmount(amount - multiplier.getMultiplier()); + savegame.increaseMoney(widget.getPrice()); savegame.decreaseMultiplier(pet.getMultiplier() * multiplier.getMultiplier()); savegame.getPurchasedPets().put( -- cgit v1.2.3