How does mafia handle visit_url pages?

matt.chugg

Moderator
I use the following to smash items in a cleanup script

Code:
void smash(item itemtosmash, int numbertokeep)	{
	if (item_amount(itemtosmash) != 0){
		if (item_amount(itemtosmash) > numbertokeep)		{
			print("Smashing " + itemtosmash+ " (" + (item_amount(itemtosmash) - numbertokeep) + ") (Keeping " + numbertokeep + ")");
			int quant = item_amount(itemtosmash) - numbertokeep;
			string pret = visit_url("craft.php?action=pulverize&pwd=&qty=" + quant + "&smashitem=" + item_to_int(itemtosmash));
			if (contains_text(pret, "You smash"))			{
				print("Smashing OK");
			} else {
				print("Smashing Failed");
			}
		}
	}
}

(don't ask why I check if count > 0 AND whether count > numbertokeep, I really can't remember why I did that. There was a reason i'm sure of it, it just evades me for now!)

I've recently noticed if I run this in ronin (before pulling the hammer) that whilst my routine reports "Smashing Failed" mafia still believes that smashing was ok and deducts the relevant quantity of the relevant item from its local version of my inventory.

Please note: this isn't a bug report. I'm fully aware that I could fix this by checking for the hammer before calling my smash_stuff() routine, or possibly checking if the skill is available (although if the skill is permed but a hammer isn't present will the skill still be available?) but I seem to remember that mafia handled this differently in the past, before I changed the routine to use the new craft page. I could be wrong about that though, which having thunk about it would make this post somewhat redundant.
 

jasonharper

Developer
Why are you using visit_url() all? Mafia has a built-in pulverize command, that handles all the details such as acquiring a hammer, and that will be updated without any effort on your part if the crafting interface changes again.
 

jasonharper

Developer
The pulverize command has been around since revision 760, released on 2006-06-15, approximately two days after the ability to pulverize was added to the game.
 

Veracity

Developer
Staff member
It's a real bug: KoLmafia removes the item from inventory when you attempt to pulverize something, not when you succeed in pulverizing. If you do it via the CLI or GUI, it will put the item back in inventory upon failure, but if you do it via visit_url or in the Relay Browser, it will not.

How about if you file a bug report in the bug report section of this forum? Thanks.
 

matt.chugg

Moderator
Done.

http://kolmafia.us/project.php?issueid=247

First bug report, hope it is up to standard! :)

Although, if using the relay browser shouldn't it be impossible for pulverizing to fail as the link wouldn't exist unless pre-requisits (skill and hammer available) are met? it would probably require url crafting ?
 
Last edited:
Top