Setup merchant, min buy/sell price.
This commit is contained in:
@@ -9,6 +9,8 @@ import com.gempukku.lotro.game.CardItem;
|
||||
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
|
||||
import com.gempukku.lotro.game.Player;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
@@ -32,7 +34,14 @@ public class MerchantService {
|
||||
public MerchantService(LotroCardBlueprintLibrary library, CollectionsManager collectionsManager, MerchantDAO merchantDAO) {
|
||||
_collectionsManager = collectionsManager;
|
||||
ParametrizedMerchant parametrizedMerchant = new ParametrizedMerchant(library);
|
||||
parametrizedMerchant.setMerchantSetupDate(new Date());
|
||||
try {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
format.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
Date setupDate = format.parse("2012-03-14 00:00:00");
|
||||
parametrizedMerchant.setMerchantSetupDate(setupDate);
|
||||
} catch (ParseException exp) {
|
||||
throw new RuntimeException("Unable to parse merchant setup date");
|
||||
}
|
||||
parametrizedMerchant.setMerchantDao(merchantDAO);
|
||||
_merchant = parametrizedMerchant;
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ParametrizedMerchant implements Merchant {
|
||||
if (normalPrice == null)
|
||||
return null;
|
||||
|
||||
int price = (int) Math.floor(_profitMargin * normalPrice / getSetupComponent(currentTime));
|
||||
int price = Math.max(1, (int) Math.floor(_profitMargin * normalPrice / getSetupComponent(currentTime)));
|
||||
|
||||
if (foil)
|
||||
return 2 * price;
|
||||
@@ -67,7 +67,7 @@ public class ParametrizedMerchant implements Merchant {
|
||||
if (normalPrice == null)
|
||||
return null;
|
||||
double setupComponent = getSetupComponent(currentTime);
|
||||
return (int) Math.ceil(normalPrice * setupComponent);
|
||||
return Math.max(2, (int) Math.ceil(normalPrice * setupComponent));
|
||||
}
|
||||
|
||||
private double getSetupComponent(Date currentTime) {
|
||||
|
||||
Reference in New Issue
Block a user