Bug - Fixed Mafia doesn't notice equip failures in a fight

matt.chugg

Moderator
As it says, if you attempt to equip something while in the middle of combat using a cli command, mafia doesn't notice that it fails. (I believe it used ajax=1)

I'd started a fight, then my ccs failed because I couldn't shieldbut without a shield. I thought i'd run away but hadn't. Mafia allowed me to believe i'd equiped a shield using a cli command

Code:
> equip pilgrim

Holding pilgrim shield...
Equipment changed.

This obviously doesn't happen very often, in fact i'd hope almost never, but it did mean that mafia believed that i'd equiped it leading to the gear changer being out of sync when i finished the fight.

the ajax response when trying to equip an item whilst in a fight is

Code:
no|in a fight

I don't even know if this could be accounted for, and being such an unlikely occurence i understand it won't be high on anyone priority list!
 

slyz

Developer
Jason added this to RecoveryManager.java:
PHP:
public static boolean isRecoveryPossible()
{
	return !RecoveryManager.isRecoveryActive() && FightRequest.getCurrentRound() == 0 &&
		!FightRequest.inMultiFight() && GenericRequest.choiceHandled;
}
I guess the same thing should be done for equipment and familiars. Should the equivalent function go in FamiliarRequest directly? Or anywhere FamiliarRequest is called?
 
I've noticed this behavior a few times over a fairly long period of time, I think, so I wouldn't be surprised if there are several bug reports concerning it.
 

slyz

Developer
Maybe we should have an internal KoLCharacter.isAdventuring() function:
PHP:
public static final boolean isAdventuring()
{
	return FightRequest.getCurrentRound() == 0 && 
        !FightRequest.inMultiFight() && GenericRequest.choiceHandled;
}
which can be used in various places: familiar/equipment switching, using/drinking/eating items, non-combat skill casting, inventory/closet/storage management, visiting locations...

EDIT: KoLMafia.isAdventuring() already exists... but is only true during automated adventuring apparently. So change the current KoLMafia.isAdventuring() to:
PHP:
public static final boolean isAdventuring()
{
	return KoLmafia.isAdventuring ||
	       FightRequest.getCurrentRound() != 0 || 
	       FightRequest.inMultiFight() ||
	       !GenericRequest.choiceHandled;
}

EDIT2: changing KoLMafia.isAdventuring() would be problematic, better create a new KoLCharacter.isAdventuring() after all.
 
Last edited:
Top