Feature - Implemented Track Beancannon usages

The Beancannon skill is limited to 5 uses per day but is currently not tracked by mafia (in terms of uses, the banish itself is tracked).

I believe this patch is sufficient, and if not, would love to know what I did wrong:

Code:
Index: src/data/defaults.txt
===================================================================
--- src/data/defaults.txt   (revision 18148)
+++ src/data/defaults.txt   (working copy)
@@ -1255,6 +1263,7 @@
 user   _ballpit    false
 user   _banderRunaways 0
 user   _barrelPrayer   false
+user   _beanCannonUses 0
 user   _bearHugs   0
 user   _beerLensDrops  0
 user   _bendHellUsed   false
Index: src/net/sourceforge/kolmafia/request/FightRequest.java
===================================================================
--- src/net/sourceforge/kolmafia/request/FightRequest.java  (revision 18148)
+++ src/net/sourceforge/kolmafia/request/FightRequest.java  (working copy)
@@ -1519,6 +1531,25 @@
                return;
            }
        }
+       else if ( skillName.equals( "Beancannon" ) )
+       {
+           // You can only use 5 Beancannon banishes per day
+
+           if ( Preferences.getInteger( "_beanCannonUses" ) >= 5 ||
+               ( !KoLCharacter.hasEquipped( ItemPool.get( ItemPool.FRIGID_BEANS, 1 ) ) &&
+                   !KoLCharacter.hasEquipped( ItemPool.get( ItemPool.HEIMZ_BEANS, 1 ) ) &&
+                   !KoLCharacter.hasEquipped( ItemPool.get( ItemPool.HELLFIRE_BEANS, 1 ) ) &&
+                   !KoLCharacter.hasEquipped( ItemPool.get( ItemPool.MIXED_BEANS, 1 ) ) &&
+                   !KoLCharacter.hasEquipped( ItemPool.get( ItemPool.PORK_N_BEANS, 1 ) ) &&
+                   !KoLCharacter.hasEquipped( ItemPool.get( ItemPool.PREMIUM_BEANS, 1 ) ) &&
+                   !KoLCharacter.hasEquipped( ItemPool.get( ItemPool.TESLA_BEANS, 1 ) ) &&
+                   !KoLCharacter.hasEquipped( ItemPool.get( ItemPool.STINKBEANS, 1 ) ) &&
+                   !KoLCharacter.hasEquipped( ItemPool.get( ItemPool.BLACKEST_EYED_PEAS, 1 ) ) ) )
+           {
+               this.skipRound();
+               return;
+           }
+       }
        else if ( skillName.equals( "Release the Boots" ) )
        {
            // You can only release the boots 7 times per day
@@ -8037,6 +8098,7 @@
        case SkillPool.BEANCANNON:
            if ( responseText.contains( "tide of beans" ) || skillSuccess )
            {
+               Preferences.increment( "_beanCannonUses" );
                BanishManager.banishMonster( monsterName, "beancannon" );
                EquipmentManager.discardEquipment( EquipmentManager.getEquipment( EquipmentManager.OFFHAND ) );
            }
 

lostcalpolydude

Developer
Staff member
18149 adds this. Some of your code already existed in a different form (and I almost missed it), which I expect will be clear when you see what I went with.

Other than that, I would have used the two-parameter version of hasEquipped with EquipmentManager.OFFHAND specified, for what I suppose amounts to a negligible performance improvement.
 
EquipmentManager.usingCanOfBeans(), I would have never found that on my own. That is even better than using the two-parameter version. Thanks!
 
Top