diff options
| author | ilotterytea <iltsu@alright.party> | 2024-06-09 16:45:30 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-06-09 19:27:41 +0500 |
| commit | 39e8c7f9328056d755cf6f5c1a52816e1f86b345 (patch) | |
| tree | e1ff52564918155d272560f3dd983bcc2ffd66d8 /core/src/kz/ilotterytea/maxon/screens | |
| parent | 480fca4f020457fc0421c482e4069b0ba973c8d4 (diff) | |
upd: use HashMap for purchased pets + fix
Diffstat (limited to 'core/src/kz/ilotterytea/maxon/screens')
| -rw-r--r-- | core/src/kz/ilotterytea/maxon/screens/game/shop/ShopUI.java | 26 |
1 files changed, 13 insertions, 13 deletions
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 3bf2d79..cc60eb5 100644 --- a/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopUI.java +++ b/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopUI.java @@ -15,7 +15,6 @@ import kz.ilotterytea.maxon.utils.formatters.NumberFormatter; import kz.ilotterytea.maxon.utils.math.Math; import java.util.ArrayList; -import java.util.HashSet; public class ShopUI { private final Table table, mainTable; @@ -185,17 +184,19 @@ public class ShopUI { } if (mode == ShopMode.BUY) { - savegame.decreaseMoney(pet.getPrice()); - for (int i = 0; i < multiplier.getMultiplier(); i++) { - // TODO: fix this - savegame.getPurchasedPets().add(0); - } + savegame.decreaseMoney(widget.getPrice()); + savegame.getPurchasedPets().put( + pet.getId(), + savegame.getPurchasedPets().getOrDefault(pet.getId(), 0) + + multiplier.getMultiplier() + ); } else { - savegame.increaseMoney(pet.getPrice()); - for (int i = 0; i < multiplier.getMultiplier(); i++) { - // TODO: fix thisss - savegame.getPurchasedPets().remove(Integer.valueOf(0)); - } + savegame.increaseMoney(widget.getPrice()); + savegame.getPurchasedPets().put( + pet.getId(), + savegame.getPurchasedPets().get(pet.getId()) + - multiplier.getMultiplier() + ); } } }); @@ -217,8 +218,7 @@ public class ShopUI { private void updatePurchaseItems() { for (final PetWidget widget : this.petWidgets) { - // TODO: asdkjoiwe (fix this) - int amount = (int) savegame.getPurchasedPets().stream().filter(c -> c == 0).count(); + int amount = savegame.getPurchasedPets().getOrDefault(widget.getPet().getId(), 0); double price = widget.getPet().getPrice() * java.lang.Math.pow(1.15f, amount + multiplier.getMultiplier()); if (mode == ShopMode.SELL) { |
