From 353377e482d0f887019797a01229b9032ea36dd2 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sun, 28 Apr 2024 22:49:08 +0500 Subject: upd: item price depend on amount of purchased items --- core/src/com/ilotterytea/maxoning/screens/GameScreen.java | 2 +- core/src/com/ilotterytea/maxoning/screens/game/shop/ShopUI.java | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java index 555e87e..f514ae3 100644 --- a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java @@ -539,7 +539,7 @@ public class GameScreen implements Screen, InputProcessor { shopUI.createSavegameUI(this.player); shopUI.createShopTitleUI(); shopUI.createShopControlUI(); - shopUI.createShopListUI(); + shopUI.createShopListUI(this.player); } @Override diff --git a/core/src/com/ilotterytea/maxoning/screens/game/shop/ShopUI.java b/core/src/com/ilotterytea/maxoning/screens/game/shop/ShopUI.java index 2203ad9..a691045 100644 --- a/core/src/com/ilotterytea/maxoning/screens/game/shop/ShopUI.java +++ b/core/src/com/ilotterytea/maxoning/screens/game/shop/ShopUI.java @@ -146,7 +146,7 @@ public class ShopUI { this.stage.addActor(table); } - public void createShopListUI() { + public void createShopListUI(final MaxonSavegame player) { Table table = new Table(); table.setWidth(Math.percentFromValue(25f, Gdx.graphics.getWidth())); @@ -155,7 +155,11 @@ public class ShopUI { table.align(Align.center); table.pad(10f); - for (MaxonItem item : this.items) { + for (final MaxonItem item : this.items) { + int amount = (int) player.inv.stream().filter(c -> c == item.id).count(); + + double price = item.price * java.lang.Math.pow(1.15f, amount + this.multiplier.getMultiplier()); + item.price = (float) price; PurchaseItem purchaseItem = new PurchaseItem(this.skin, item); table.add(purchaseItem).width(table.getWidth()).padBottom(5f).row(); -- cgit v1.2.3