Serin-Delaunay wrote
Personally I'd avoid duplicating the price formula in the room code, just in case it ever changes in the future. That way whoever changes it wouldn't get a nasty surprise when they find Mondedr is still using the old price formula.
That is a point.
Well, you could just add a GetMondedrPrice() function in item.cpp but then it'd be subject to the same problem if someone overlooks it.
truth shop::PickupItem(character* Customer, item* ForSale, int Amount)
{
//other code happens here
if(GetMaster()->GetConfig() == MONDEDR)
{
//calls GetMondedrPrice which is the same as GetTruePrice but ignores LifeExpectancy
long Price = ForSale->GetMondedrPrice;
}
else
{
//the shop is not in Mondedr, so it treats mirrored items as junk
long Price = ForSale->GetTruePrice();
}
Another option would be to add a "isMondedrItem" boolean to the item code and then just have GetTruePrice() ignore the LifeExpectancy if that boolean is true and the level is MONDEDR.
But then you'd need to set isMondedrItem for all generated shop items (mirrored or not) in Mondedr, which I feel is a little bit roundabout when you could cut out the middleman and just change the shop code.
EDIT: I had a better idea while I was in the shower (best place for thinking about programming IMO)
Change GetTruePrice() to take a single parameter, boolean AcceptMirrored:
long item::GetTruePrice(boolean AcceptMirrored) const
{
if(LifeExpectancy && !AcceptMirrored)
return 0;
Then in the shop code we have the check for Mondedr as before, but now it calls GetTruePrice(true):
truth shop::PickupItem(character* Customer, item* ForSale, int Amount)
{
//other code happens here
if(GetMaster()->GetConfig() == MONDEDR)
{
//this is the same as the GetTruePrice code but without the check for LifeExpectancy (or spoilage)
long Price = ForSale->GetTruePrice(true);
}
else
{
//the shop is not in Mondedr, so it treats mirrored items as junk
long Price = ForSale->GetTruePrice(false);
}
//rest of code here
}