Bug - Fixed Buying items from the AWOL coinmaster

slyz

Developer
Using the CoinMaster frame, I bought 3 leather aviators' caps but for some reason they weren't added to my inventory:
Code:
Visiting the A. W. O. L. Quartermaster...
Unrecognized item found: 3 leather aviators' caps
You acquire leather aviators' caps (3)
A. W. O. L. Quartermaster successfully looted!
Despite the "You acquire leather aviators' caps (3)" message, there were no leather cap in in item manager, and Mafia thought I didn't have any commendations left, but I should have had 31.

I tried buying 2 Field Guides to Skeletal Anatomy, and I didn't get the error again:
Code:
Visiting the A. W. O. L. Quartermaster...
You acquire Field Guide to Skeletal Anatomy (2)
A. W. O. L. Quartermaster successfully looted!
although I noticed in the debug log for that request that the "Processing result: A. W. O. L. commendation (-10)" line appeared twice, and the Item Manager indeed thought I had 11 commendations left instead of 21.

I guess the "Unrecognized item found: 3 leather aviators' caps" message is not reproducible, but it looks like the fact that Mafia processes the commendations used twice when buying from the CoinMaster frame is reproducible:
Code:
> ash sell_price( $coinmaster[ awol ], $item[ultraserum ] )

Returned: 1

> inv commendation

A. W. O. L. commendation (21)
Visiting the A. W. O. L. Quartermaster...
You acquire an item: Ultrasoldier Serum
A. W. O. L. Quartermaster successfully looted!

> inv commendation

A. W. O. L. commendation (19)

This is pretty low priority, but I thought I'd start a thread to have somewhere to put that info.
 

Attachments

  • DEBUG_20111207.txt
    16.8 KB · Views: 93

slyz

Developer
It looks like there are more fishy things going on with the AWOL quartermaster:
Code:
> ash $coinmaster[ A. W. O. L. Quartermaster ]

Returned: A. W. O. L. Quartermaster
token => commendation
item => A. W. O. L. commendation
property =>
available_tokens => 20
buys => false
sells => false

> ash sells_item( $coinmaster[ A. W. O. L. Quartermaster ], $item[Ultrasoldier Serum ] )

Returned: true

> ash sell_price( $coinmaster[ A. W. O. L. Quartermaster ], $item[Ultrasoldier Serum ] )

Returned: 1

> ash item_amount( $coinmaster[ A. W. O. L. Quartermaster ].item )

Returned: 20

> ash buy( $coinmaster[ A. W. O. L. Quartermaster ], 1, $item[ Ultrasoldier Serum ] )

[color=red]You can't buy Ultrasoldier Serum from A. W. O. L. Quartermaster[/color]
Returned: false
 

slyz

Developer
That's what I first thought, then I looked at the name wrong and missed the obvious: leather aviators' caps != leather aviator's cap.
I'll add the plural right away.

EDIT: wouldn't "leather aviators' caps" mean "the caps of leather aviators"?
 
Last edited:

Theraze

Active member
It could be taken that way, but the plural of the aviator's cap (the cap belonging to the aviator) would be the aviators' caps (the caps belonging to the aviators). The leather just makes it a bit more amusing.
 

slyz

Developer
r10094 fixes the "Unrecognized item found: 3 leather aviators' caps" error, but the main bug of the report was Mafia removing the tokens twice when buying from the AWOL coinmaster.
 

slyz

Developer
It looks like the "You can't buy Ultrasoldier Serum from A. W. O. L. Quartermaster" error comes from this part in CoinMasterRequest.buy()
PHP:
String action = data.getBuyAction();
String itemName = it.getName();
if ( action == null || !data.canBuyItem( itemName ) )
{
	KoLmafia.updateDisplay( KoLConstants.ERROR_STATE, "You can't buy " + itemName + " from " + data.getMaster() );
	return;
}
It turns out that a few coinmasters (including the AWOL Quartermaster and the Fudge Wand I'm working on) do not have a buyAction.

Is there a reason for the "action == null" check, or can I simply scrap it?

EDIT: a better fix would be to set buyAction to "" instead of null for those coinmasters.
 
Last edited:

Veracity

Developer
Staff member
It turns out that a few coinmasters (including the AWOL Quartermaster and the Fudge Wand I'm working on) do not have a buyAction.

Is there a reason for the "action == null" check, or can I simply scrap it?
There is a reason, but it's obviously based on an incorrect assumption. :)

The assumption was that any Coinmaster from which you could buy would have a buyaction and that we could efficiently reject sell-only coinmasters (if there were ever to be such) with a null check, rather than looking through the list items you can buy. Turns out, if you can't buy anything, the list will, itself, be null, and canBuyItem will check that and quickly return false.

Remove that null check and move the "String action = data.getBuyAction();" down in the function, just in front of the first place it is really used - the call to CoinMasterRequest.getRequest( data, action, it ).
 

slyz

Developer
That worked like a charm.

By the way, the problem with "acquire" was simply user error (I already had more than one fudge cube in my inventory).

I'll try to reproduce and track down the problem with the double processing of commendations.
 
Top