- Merchant now sells all the cards, but the out-of-stock cards are substantially more expensive to buy.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<pre style="font-size:80%">
|
||||
<b>23 Dec. 2012</b>
|
||||
- Merchant now sells all the cards, but the out-of-stock cards are substantially more expensive to buy.
|
||||
|
||||
<b>21 Dec. 2012</b>
|
||||
- "Dunlending Warrior" cannot be activated now, if you can't spot a follower.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user