Bug - Fixed Acquire not working for coinmaster purchases

slyz

Developer
I think we now have the opposite problem.

with r10806:
Code:
> create 1 coffe pixie stick

[color=red]That item cannot be created.[/color]

with r10794:
Code:
> create 1 coffe pixie stick

Verifying ingredients for coffee pixie stick (1)...
Searching for "Game Grid ticket"...
Search complete.
Purchasing Game Grid ticket (10 @ 295)...
You acquire Game Grid ticket (10)
Purchases complete.
Purchasing coffee pixie stick (1 @ 10 tickets)...
Visiting the Arcade Ticket Counter...
You acquire an item: coffee pixie stick
Arcade Ticket Counter successfully looted!
Successfully created coffee pixie stick (1)

I'll have some time to look at this some more tonight (we just moved in a new place). I think simply changing
PHP:
if ( !conc.available() )
{
	return null;
}
to
PHP:
if ( !conc.purchaseRequest.data.isAccessible() )
{
	return null;
}
in CreateItemRequest.getInstance() should do the trick.

EDIT:
Or rather change
PHP:
return this.purchaseRequest != null && this.purchaseRequest.canPurchase();
to
PHP:
if ( this.purchaseRequest == null )
{
	return false;
}

CoinmasterData coinmaster = this.purchaseRequest.getData();
return coinmaster.isAccessible();
in Concoction.available()
 
Last edited:

slyz

Developer
It's ugly, but what I was thinking of worked. I just had to change
PHP:
return this.purchaseRequest != null && this.purchaseRequest.canPurchase();
to
PHP:
if ( this.purchaseRequest == null )
{
	return false;
}

CoinmasterData coinmaster = ((CoinMasterPurchaseRequest) this.purchaseRequest).getData();
return coinmaster.isAccessible();
instead.

Code:
> use 1 coff pix

Verifying ingredients for coffee pixie stick (1)...
Searching for "Game Grid ticket"...
Search complete.
Purchasing Game Grid ticket (10 @ 295)...
You acquire Game Grid ticket (10)
Purchases complete.
Purchasing coffee pixie stick (1 @ 10 tickets)...
Visiting the Arcade Ticket Counter...
You acquire an item: coffee pixie stick
Arcade Ticket Counter successfully looted!
Successfully created coffee pixie stick (1)
Using 1 coffee pixie stick...
You gain 7 Adventures
Finished using 1 coffee pixie stick.

> Acquire Bone meal

Searching for "bone meal"...
Search complete.
Stopped purchasing bone meal @ 34,750.
Using cached search results for bone meal...
Stopped purchasing bone meal @ 34,750.
You need 1 more bone meal to continue.

EDIT: since my hack is ugly, I'll wait for Veracity's green light to commit this.
 

Donavin69

Member
Thanks Slyz!, I was going to post about this issue

I haven't even looked at the source for Mafia, I should get around to that one of these days, maybe then I could contribute more than just a bug report...
 

Rinn

Developer
Purchasing coinmaster items only works if you already have the necessary items to trade in your inventory.

Code:
> use coffee pixie stick


You need 1 more coffee pixie stick to continue.


> acquire coffee pixie stick


You need 1 more coffee pixie stick to continue.


> buy coffee pixie stick


Searching for "coffee pixie stick"...
Search complete.


> buy 10 game grid ticket


Searching for "Game Grid ticket"...
Search complete.
Purchasing Game Grid ticket (10 @ 293)...
You acquire Game Grid ticket (10)
Purchases complete.


> use coffee pixie stick


Verifying ingredients for coffee pixie stick (1)...
Purchasing coffee pixie stick (1 @ 10 tickets)...
Visiting the Arcade Ticket Counter...
You acquire an item: coffee pixie stick
Arcade Ticket Counter successfully looted!
Successfully created coffee pixie stick (1)
Using 1 coffee pixie stick...
You gain 10 Adventures
Finished using 1 coffee pixie stick.
 

Veracity

Developer
Staff member
This is, technically, a duplicate of the issue reported here. However, since that issue was reported in a follow-up to another request, this is the first standalone bug report on this issue. We have been working on it, but I guess having this here for tracking doesn't hurt.

I'll split the bug report messages from the other thread and move them here.
 

Veracity

Developer
Staff member
Yea, I agree with hola, but I think a better way is to create a new PurchaseRequest.isAccessible() method which returns true, and override that method in CoinMasterPurchaseRequest to return data.isAccessible(). Then, change

Code:
return this.purchaseRequest != null && this.purchaseRequest.canPurchase();
to
Code:
return this.purchaseRequest != null && this.purchaseRequest.isAccessible();
 

slyz

Developer
Done in r10818.

There might be something to be done in PurchaseRequest about canpurchase(), canPurchaseIgnoringMeat() and isAccessible() to make things consistent:
PHP:
public void setCanPurchase( final boolean canPurchase )
{
	this.canPurchase = canPurchase;
}

public void setCanPurchase()
{
	this.setCanPurchase( KoLCharacter.getAvailableMeat() >= this.price );
}

public boolean canPurchase()
{
	return this.canPurchase && KoLCharacter.getAvailableMeat() >= this.price;
}

public boolean canPurchaseIgnoringMeat()
{
	return this.canPurchase;
}
Calling canPurchase() will set this.canPurchase to false if you can't afford the item. This then makes the return value of canPurchaseIgnoringMeat() look untrustworthy.

Maybe this.canPurchase and canPurchaseIgnoringMeat() should be replaced by this.isAccessible and isAccessible(), since I guess that's what they were intended for.

NPCPurchaseRequest would benefit from using isAccessible() and canPurchase() the way they are used in CoinMasterPurchaseRequest, for clarity.
 
Top