Jeck - Consolidated card price functions from deckviewer/shop into PriceList. Also moved price discount hash variable. (As of around r1825, price discount has been based on (mtgid + static int randomKey) % 20. randomKey updates at the end of any won game, making prices for a given fixed between visits to the shop on the same "day")
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "../include/config.h"
|
||||
#include "../include/PriceList.h"
|
||||
|
||||
|
||||
int PriceList::randomKey = 0;
|
||||
|
||||
PriceList::PriceList(const char * _filename, MTGAllCards * _collection):collection(_collection){
|
||||
filename = _filename;
|
||||
@@ -15,6 +15,8 @@ PriceList::PriceList(const char * _filename, MTGAllCards * _collection):collecti
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
if(randomKey == 0)
|
||||
randomKey = rand();
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +62,6 @@ int PriceList::getPrice(int cardId){
|
||||
default:
|
||||
return Constants::PRICE_1C;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -69,3 +70,12 @@ int PriceList::setPrice(int cardId, int price){
|
||||
prices[cardId] = price;
|
||||
return price;
|
||||
}
|
||||
int PriceList::getSellPrice(int cardid){
|
||||
return getPurchasePrice(cardid) / 2;
|
||||
}
|
||||
int PriceList::getPurchasePrice(int cardid){
|
||||
float price = (float) getPrice(cardid);
|
||||
int rnd = abs(cardid + randomKey) % (1+Constants::PRICE_FLUX_RANGE);
|
||||
price += price * (float)(rnd - Constants::PRICE_FLUX_MINUS)/100.0f;
|
||||
return price;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user