Bug - Fixed Usage of Pumpkin Bomb not detected

Winterbay

Active member
There seems to be some kind of error in mafia's handlign of the pumpkin bomb as it is not deducted form inventory after usage as can be seen in this example:

Code:
[15] photocopied monster
Encounter: leethal's butt
Round 0:     winterbay wins initiative!

> inv pumpkin

pumpkin     bomb
Round 1: winterbay uses the pumpkin bomb!
You acquire an     effect: Everything Looks Yellow (duration: 149 Adventures)
Round 2:     winterbay wins the fight!
After Battle: Trofflesby smiles a     three-lipped smile from beneath the shade of his little sombrero.
You     gain 122 Beefiness
You gain some Muscle points!
You gain some Levels!
You     gain 74 Wizardliness
You gain some Mysticality points!
You gain 93     Roguishness
You gain some Moxie points!

> inv pumpkin

pumpkin     bomb

[16] Outskirts of The Knob
Encounter: Knob Goblin Assistant     Chef
Round 0: winterbay wins initiative!
Round 1: winterbay casts     TOSS!
Round 2: You pick up Trofflesby and toss him at your opponent,     dealing 14 damage. Go Trofflesby!
Round 2: knob goblin assistant chef     takes 14 damage.
Round 2: winterbay wins the fight!
You gain 11 Meat
After     Battle: Trofflesby smiles a three-lipped smile from beneath the shade of     his little sombrero.
You gain 3 Beefiness
You gain 2 Sarcasm

> inv     pumpkin

pumpkin bomb

> refresh inv

Refreshing closet...
Updating     consumable items...
Updating miscellaneous items...
Refreshing     stickers...
Requests complete.

> inv pumpkin

The second adventure was to make sure that it wouldn't be detected during the second fight, but it appears to not be detected until I make a refresh of the inventory.

I was playing in the relay browser and have the WOW-bar enabled, if that has any bearing on this.
 

slyz

Developer
Here is a patch. I should be able to test it as soon as I can log in KoL through this crappy wifi hotspot connection.

Can you imagine I just moved into an apartment with a grand total of 0 telephone sockets? How am I going to get my DSL =(

EDIT: I forgot I had already overdrank earlier, so I'll test this tomorrow (unless someone beats me to it).
 

Attachments

  • PumpkinBomb.patch
    1.3 KB · Views: 22
Last edited:

slyz

Developer
No luck with my patch:
Code:
[3050] Goatlet
Encounter: drunk goat
Round 0: slyz wins initiative!
Round 1: slyz uses the pumpkin bomb!
You acquire an effect: Everything Looks Yellow (duration: 149 Adventures)
Round 2: slyz wins the fight!
You gain 67 Meat
You acquire an item: bottle of whiskey
You acquire an item: goat beard
After Battle: Dusty smiles a three-lipped smile from beneath the shade of his little sombrero.
You gain 8 Strongness
You gain 10 Magicalness
You gain 7 Smarm

> inv pumpkin bomb

pumpkin bomb

> refresh inv

Refreshing closet...
Updating consumable items...
Updating miscellaneous items...
Refreshing stickers...

> inv pumpkin bomb

The "Round 1: slyz uses the pumpkin bomb!" line shows that FightRequest.registerRequest() did recognize that a pumpkin bomb was used, so isItemConsumed() should be called correctly at one point.

I copied the code used for other combat items that may or may not be consumed, like the Merkin Pinkslip. I'll try again in 150 turns with a debug log, replacing
PHP:
return responseText.indexOf( "toss the pumpkin" ) != -1
with
PHP:
if( responseText.indexOf( "toss the pumpkin" ) != -1 )
{
	return true;
}

return false;
although I doubt the problem lies there.
 
Last edited:

Grotfang

Developer
I'm in HC at the moment, so can't do anything quickly. However, I will have a look tomorrow and see if I can find anything.
 

slyz

Developer
Here is the HTML of the fight, as provided by the debug log:
 

Attachments

  • pumpkinbomb.txt
    20.4 KB · Views: 35

Veracity

Developer
Staff member
I experimented with this and found that KoLmafia was, in fact, calling payActionCost but that was not calling payItemCost - which could ponly have happened if it thought it was round zero. We reset the round to zero when you win the fight, but it is not clear to me why it was paying the action cost AFTER having done so.

I have a patch which pays the item cost regardless of which round we think it is. After all, we pay mp cost for skills regardless of which round it is. Lets try out revision 9025 and see if there are unexpected side effects in other fights...
 

Theraze

Active member
That [change] would make sense... if you use an item when you win the fight, the item is still used up.
 

slyz

Developer
r9025 fixes the problem:
Code:
> inv pumpkin bomb

pumpkin bomb

[3351] Goatlet
Encounter: sabre-toothed goat
Round 0: slyz wins initiative!
KoLmafia thinks it is round 2 but KoL thinks it is round 1
Round 2: slyz uses the pumpkin bomb!
KoLmafia thinks it is round 3 but KoL thinks it is round 2
You acquire an effect: Everything Looks Yellow (duration: 149 Adventures)
Round 3: slyz wins the fight!
You gain 334 Meat
You acquire an item: goat beard
You gain 3 Fortitude
You gain 13 Mysteriousness
You gain 4 Sarcasm

> inv pumpkin bomb

Thanks Veracity. Just out of curiosity, how do you debug things like this? I tried adding "RequestLogger.printLine( message )" in payItemCost(), but of course this is hacky (and didn't work since it wasn't being called at all). There must be a professional way of doing this.

EDIT: I finally figured out how to change the prefix to "Bug - Fixed".
 
Last edited:

fronobulax

Developer
Staff member
EDIT: I finally figured out how to change the prefix to "Bug - Fixed".

How? For extra credit, how are the Might Minions et. al. searching for titles with the various prefixes? I could probably figure it out myself but it's more fun to ask. Thanks.
 

Veracity

Developer
Staff member
Thanks Veracity. Just out of curiosity, how do you debug things like this? I tried adding "RequestLogger.printLine( message )" in payItemCost(), but of course this is hacky (and didn't work since it wasn't being called at all). There must be a professional way of doing this.
Ha ha ha.

I went and inserted System.out.println all over the place. I verified it was getting into payActionCost and was NOT getting into payItemCost, which led me to conclude that the round had to be 0. I would have gone farther and figured out just how THAT was happening, but this particular item is restricted to 1 use in 150 turns, so I only got 2 tries at it on the multi that I tested on.

I suppose the "professional" way would be to use Eclipse or Netbeans and set breakpoints and such, but I've been programming since before there were IDEs and go for the primitive approach. Much as you did, but I was able to deduce more than you, it seems, from the debugging I installed...
 

Winterbay

Active member
How? For extra credit, how are the Might Minions et. al. searching for titles with the various prefixes? I could probably figure it out myself but it's more fun to ask. Thanks.

You can click on the prefixes to filter out any other and from that go through them. That much I know. The rest I can't help you with :)
 

Veracity

Developer
Staff member
You know, I think that we have a general issue with "pay Item costs". We do it when we decide it's time to advance the round. We look at what item was used, decide whether it is expended - possibly by looking at page text - and deduct it or not from inventory. For some items, we may do other deductions - toy soldiers and toy mercenaries, for example.

The issue is Funkslinging. You Funksling two beer bombs, both record damage, both are lost - even if the first was sufficient to kill the monster. You Funksling tattered scraps of paper, and if the first one suffices to end the combat, the second is not deducted. I don't recall seeing an issue with inventory counts getting skewed, so we must deal with that, somehow, but I don't recall how.

I suppose the best approach would be to pay the item cost for each item individually as we are stepping through the combat text of the fight and recognize that we are looking at item usage. For normal combat, we see an item image (which we have no record of in our database, unlike effects or your current familiar, say) associated with item text. If we could somehow recognize that this is an item being used, we could "pay item cost" right then for either the 1st or 2nd item, as appropriate, using the combat text to decide what happened. I'm not sure about Haiku combat. That has some things like "you remember that thing you used? It did something." I don't know if it shows the item image. If not, that would be a reasonable feature request for KoL itself.
 

jasonharper

Developer
The item counts for final-round-used items normally get corrected at the start of the next combat, when we see the updated item <select> on the page. The problem occurs when you've used up the last of some combat item, and it's no longer in the popup - the count correction code only processes the items that are explicitly listed, it doesn't try to enumerate every item that should be in the popup but currently isn't. This seemed like a better approach in general, despite the problem, than trying to maintain a list of every possible success/failure message for every combat item.
 

fronobulax

Developer
Staff member
I suppose the "professional" way would be to use Eclipse or Netbeans and set breakpoints and such, but I've been programming since before there were IDEs and go for the primitive approach.

FWIW, a relatively recent column in Communications of the ACM (a software and computer related professional journal for those who don't know) discussed debugging techniques, and the conclusion, which I agree with, is that the professional picks the right tool for the job, which does not always have to be a source level debugger.

@Winterbay - Thanks.
 

heeheehee

Developer
Staff member
I'm not sure about Haiku combat. That has some things like "you remember that thing you used? It did something." I don't know if it shows the item image. If not, that would be a reasonable feature request for KoL itself.
Got a small sample of the HTML for item use in the haiku dungeon. Inventory images off, but that doesn't seem to affect anything -- image still displays, with alt-text showing the item name.
Code:
<table><tr><td valign=top><img src="http://images.kingdomofloathing.com/itemimages/beer.gif" width=30 height=30 alt="beer bomb" title="beer bomb"></td><td valign=center><Table><tr><td valign=center align=left><b>56</b> damage<br>that's a lot of mayhem dealt<br>go, combat items!</td></tr></table></td></tr></table>
 
Top