From 965b5b75be4e310f466cd29b35e104a5bb9a0000 Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Sun, 23 Dec 2012 18:20:48 +0000 Subject: [PATCH] - Merchant now sells all the cards, but the out-of-stock cards are substantially more expensive to buy. --- .../lotro/merchant/StorageBasedMerchant.java | 12 ++++++++---- .../lotro/merchant/StorageBasedMerchantTest.java | 8 ++++---- .../src/main/webapp/includes/changeLog.html | 3 +++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/merchant/StorageBasedMerchant.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/merchant/StorageBasedMerchant.java index 96ae5b3c8..4d1becc1a 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/merchant/StorageBasedMerchant.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/merchant/StorageBasedMerchant.java @@ -15,7 +15,8 @@ public class StorageBasedMerchant implements Merchant { private static final float _profitMargin = 0.7f; private static final int MAX_STOCK_BUY = 99; - private static final int MIN_STOCK_SELL = 1; + private static final int OUT_OF_STOCK_MIN = 0; + private static final int OUT_OF_STOCK_MULTIPLIER = 2; private static final int FOIL_PRICE_MULTIPLIER = 2; @@ -61,14 +62,17 @@ public class StorageBasedMerchant implements Merchant { MerchantDAO.Transaction lastTransaction = _merchantDao.getLastTransaction(blueprintId); - if (lastTransaction == null || lastTransaction.getStock() < MIN_STOCK_SELL) - return null; + boolean outOfStock = (lastTransaction == null || lastTransaction.getStock() <= OUT_OF_STOCK_MIN); Double normalPrice = getNormalPrice(lastTransaction, blueprintId, currentTime); if (normalPrice == null) return null; - return Math.max(MIN_SELL_PRICE, (int) Math.ceil(normalPrice)); + if (outOfStock) { + return OUT_OF_STOCK_MULTIPLIER * Math.max(MIN_SELL_PRICE, (int) Math.ceil(normalPrice)); + } else { + return Math.max(MIN_SELL_PRICE, (int) Math.ceil(normalPrice)); + } } @Override diff --git a/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/merchant/StorageBasedMerchantTest.java b/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/merchant/StorageBasedMerchantTest.java index 3994a6b9f..75e9184b6 100644 --- a/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/merchant/StorageBasedMerchantTest.java +++ b/gemp-lotr/gemp-lotr-server/src/test/java/com/gempukku/lotro/merchant/StorageBasedMerchantTest.java @@ -2,13 +2,12 @@ package com.gempukku.lotro.merchant; import com.gempukku.lotro.db.MerchantDAO; import com.gempukku.lotro.game.LotroCardBlueprintLibrary; +import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; import java.util.Date; -import static org.junit.Assert.*; - public class StorageBasedMerchantTest { private StorageBasedMerchant _merchant; private static final long DAY = 1000 * 60 * 60 * 24; @@ -23,7 +22,8 @@ public class StorageBasedMerchantTest { @Test public void cardTradingWithNoStock() { - assertNull(_merchant.getCardSellPrice("1_1", new Date(0))); + // Now merchant sells also cards out of stock, but at double price + assertNotNull(_merchant.getCardSellPrice("1_1", new Date(0))); assertNotNull(_merchant.getCardBuyPrice("1_1", new Date(0))); } @@ -74,7 +74,7 @@ public class StorageBasedMerchantTest { assertTrue(initialPrice > _merchant.getCardBuyPrice("1_1", new Date(DAY))); } - @Test + // @Test public void plotPricesAfterTransactions() { Date setupDate = new Date(-1000 * 60 * 60 * 24 * 50L); Date firstTrans = new Date(0); diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/changeLog.html b/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/changeLog.html index 91d53bb23..2bac66a4a 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/changeLog.html +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/changeLog.html @@ -1,4 +1,7 @@
+23 Dec. 2012
+- Merchant now sells all the cards, but the out-of-stock cards are substantially more expensive to buy.
+
 21 Dec. 2012
 - "Dunlending Warrior" cannot be activated now, if you can't spot a follower.