Index: src/net/sourceforge/kolmafia/swingui/panel/UseItemEnqueuePanel.java
===================================================================
--- src/net/sourceforge/kolmafia/swingui/panel/UseItemEnqueuePanel.java (revision 9423)
+++ src/net/sourceforge/kolmafia/swingui/panel/UseItemEnqueuePanel.java (working copy)
@@ -55,6 +55,7 @@
import net.sourceforge.kolmafia.persistence.ItemDatabase;
import net.sourceforge.kolmafia.preferences.PreferenceListenerRegistry;
import net.sourceforge.kolmafia.preferences.Preferences;
+import net.sourceforge.kolmafia.request.CreateItemRequest;
import net.sourceforge.kolmafia.request.UseItemRequest;
import net.sourceforge.kolmafia.request.UseSkillRequest;
import net.sourceforge.kolmafia.session.InventoryManager;
@@ -88,13 +89,20 @@
listeners.add( new ExecuteListener() );
- if ( this.food || this.booze )
+ boolean hg = KoLCharacter.findFamiliar( FamiliarPool.GHOST ) != null;
+ boolean hh = KoLCharacter.findFamiliar( FamiliarPool.HOBO ) != null;
+
+ if ( food && hg || booze && hh )
{
listeners.add( new FamiliarFeedListener() );
+ }
+
+ if ( food || booze )
+ {
listeners.add( new BuffUpListener() );
}
- if ( this.booze || this.spleen )
+ if ( booze || spleen )
{
listeners.add( new FlushListener() );
}
@@ -150,17 +158,67 @@
{
super.setEnabled( isEnabled );
- // We gray out the dog hair button unless we have drunkenness,
- // have a pill, and haven't used one today.
- if ( isEnabled && this.booze )
+ if ( isEnabled )
{
- // The "flush" listener is the last button
- int flushIndex = this.buttons.length - 1;
- boolean havedrunk = KoLCharacter.getInebriety() > 0;
- boolean havepill = InventoryManager.getCount( ItemPool.SYNTHETIC_DOG_HAIR_PILL ) > 0;
- boolean usedpill = Preferences.getBoolean( "_syntheticDogHairPillUsed" );
- boolean canFlush = havedrunk && ( havepill && !usedpill );
- this.buttons[ flushIndex ].setEnabled( canFlush );
+ boolean ro = KoLCharacter.inRonin();
+ boolean haveMall = Preferences.getBoolean( "autoSatisfyWithMall" );
+
+ if ( this.food )
+ {
+ int milkIndex = this.buttons.length - 1;
+ boolean haveMilk = InventoryManager.getAccessibleCount( ItemPool.MILK_OF_MAGNESIUM ) > 0;
+
+ CreateItemRequest creator = CreateItemRequest.getInstance( ItemPool.MILK_OF_MAGNESIUM );
+
+ boolean canMake = false;
+ if (creator != null)
+ {
+ canMake = creator.getQuantityPossible() > 0;
+ }
+
+ //it's milktime if !haveMall and we have one/can make one
+ //OR if haveMall. Also check that we haven't hit maxUses.
+
+ boolean availMilk = ro || !haveMall ? haveMilk || canMake : true;
+ boolean canUse = UseItemRequest.maximumUses( ItemPool.MILK_OF_MAGNESIUM ) > 0;
+
+ boolean milkTime = canUse && availMilk;
+
+ this.buttons[ milkIndex ].setEnabled( milkTime );
+ }
+
+ else if ( this.booze )
+ {
+ // The "flush" listener is the last button
+ int flushIndex = this.buttons.length - 1;
+
+ boolean havePill = InventoryManager.getCount( ItemPool.SYNTHETIC_DOG_HAIR_PILL ) > 0;
+ boolean canUse = UseItemRequest.maximumUses( ItemPool.SYNTHETIC_DOG_HAIR_PILL ) > 0;
+
+ boolean canFlush = canUse && havePill;
+
+ //we gray out the dog hair button unless we have drunkenness,
+ //have a pill, and haven't used one today.
+ this.buttons[ flushIndex ].setEnabled( canFlush );
+
+ int odeIndex = this.buttons.length - 2;
+ boolean canOde = KoLCharacter.hasSkill( "The Ode to Booze" ) && KoLCharacter.getMaximumMP() > 49;
+
+ this.buttons[ odeIndex ].setEnabled( canOde );
+ }
+
+ else if (this.spleen )
+ {
+ int mojoIndex = this.buttons.length - 1;
+
+ boolean haveMojo = InventoryManager.getCount( ItemPool.MOJO_FILTER ) > 0;
+ boolean canUse = UseItemRequest.maximumUses( ItemPool.SYNTHETIC_DOG_HAIR_PILL ) > 0;
+
+ boolean isMojoTime = !canUse ? false : ro && !haveMojo ? false
+ : !ro && (!haveMojo && !haveMall) ? false : true;
+
+ this.buttons[ mojoIndex ].setEnabled( isMojoTime );
+ }
}
}