@Override public void run(final String cmd, String parameters) { AdventureResult crop = CampgroundRequest.getCrop(); if (crop == null) { KoLmafia.updateDisplay("You don't have a garden."); return; } int count = crop.getCount(); if (parameters.equals("")) { String name = count != 1 ? ItemDatabase.getPluralName(crop.getItemId()) : crop.getName(); KoLmafia.updateDisplay("Your garden has " + count + " " + name + " in it."); return; } if (parameters.equals("pick")) { if (count == 0) { KoLmafia.updateDisplay("There is nothing ready to pick in your garden."); return; } if (!Limitmode.limitCampground() && !KoLCharacter.isEd() && !KoLCharacter.inNuclearAutumn()) { CampgroundRequest.harvestCrop(); } } }
public void valueChanged(final ListSelectionEvent e) { AdventureResult effect = (AdventureResult) SkillBuffFrame.this.effectList.getSelectedValue(); if (effect == null) { return; } SkillBuffFrame.this.skillSelect.setSelectedItem( UseSkillRequest.getInstance(UneffectRequest.effectToSkill(effect.getName()))); }
@Override public boolean isVisible(final Object element) { AdventureResult item = (AdventureResult) element; int itemId = item.getItemId(); if (RestoresDatabase.isRestore(itemId)) { String itemName = item.getName(); if (KoLCharacter.inBeecore() && KoLCharacter.hasBeeosity(itemName)) { return false; } if (RestoresDatabase.getUsesLeft(itemName) == 0) { return false; } if (RestoresDatabase.getHPRange(itemName).length() == 0 && RestoresDatabase.getMPRange(itemName).length() == 0) { return false; } return super.isVisible(element); } return false; }
public static void use(final String command, String parameters) { if (parameters.equals("")) { return; } boolean either = parameters.startsWith("either "); if (either) { parameters = parameters.substring(7).trim(); } if (command.equals("eat") || command.equals("eatsilent")) { if (KoLCharacter.inBadMoon() && KitchenCommand.visit(parameters)) { return; } if (KoLCharacter.canadiaAvailable() && RestaurantCommand.makeChezSnooteeRequest(parameters)) { return; } } if (command.equals("drink") || command.equals("overdrink")) { if (KoLCharacter.inBadMoon() && KitchenCommand.visit(parameters)) { return; } if (KoLCharacter.gnomadsAvailable() && RestaurantCommand.makeMicroBreweryRequest(parameters)) { return; } } // Now, handle the instance where the first item is actually // the quantity desired, and the next is the amount to use if (command.equals("eat") || command.equals("eatsilent") || command.equals("ghost")) { ItemFinder.setMatchType(ItemFinder.FOOD_MATCH); } else if (command.equals("drink") || command.equals("overdrink") || command.equals("hobo")) { ItemFinder.setMatchType(ItemFinder.BOOZE_MATCH); } else if (command.equals("slimeling")) { ItemFinder.setMatchType(ItemFinder.EQUIP_MATCH); } else { ItemFinder.setMatchType(ItemFinder.USE_MATCH); } Object[] itemList = ItemFinder.getMatchingItemList(KoLConstants.inventory, parameters); ItemFinder.setMatchType(ItemFinder.ANY_MATCH); for (int level = either ? 0 : 2; level <= 2; ++level) { // level=0: use only items in inventory, exit on first success // level=1: buy/make as needed, exit on first success // level=2: use all items in list, buy/make as needed for (int i = 0; i < itemList.length; ++i) { AdventureResult currentMatch = (AdventureResult) itemList[i]; int consumpt = ItemDatabase.getConsumptionType(currentMatch.getItemId()); if (command.equals("eat") && consumpt == KoLConstants.CONSUME_FOOD_HELPER) { // allowed } else if (command.equals("eat") || command.equals("ghost")) { if (consumpt != KoLConstants.CONSUME_EAT) { KoLmafia.updateDisplay( MafiaState.ERROR, currentMatch.getName() + " cannot be consumed."); return; } } if (command.equals("drink") && consumpt == KoLConstants.CONSUME_DRINK_HELPER) { // allowed } else if (command.equals("drink") || command.equals("hobo")) { if (consumpt != KoLConstants.CONSUME_DRINK) { KoLmafia.updateDisplay( MafiaState.ERROR, currentMatch.getName() + " is not an alcoholic beverage."); return; } } if (command.equals("use")) { switch (consumpt) { case KoLConstants.CONSUME_EAT: case KoLConstants.CONSUME_FOOD_HELPER: KoLmafia.updateDisplay(MafiaState.ERROR, currentMatch.getName() + " must be eaten."); return; case KoLConstants.CONSUME_DRINK: case KoLConstants.CONSUME_DRINK_HELPER: KoLmafia.updateDisplay( MafiaState.ERROR, currentMatch.getName() + " is an alcoholic beverage."); return; } } int have = currentMatch.getCount(KoLConstants.inventory); if (level > 0 || have > 0) { if (level == 0 && have < currentMatch.getCount()) { currentMatch = currentMatch.getInstance(have); } if (KoLmafiaCLI.isExecutingCheckOnlyCommand) { RequestLogger.printLine(currentMatch.toString()); } else { UseItemRequest request = command.equals("hobo") ? UseItemRequest.getInstance(KoLConstants.CONSUME_HOBO, currentMatch) : command.equals("ghost") ? UseItemRequest.getInstance(KoLConstants.CONSUME_GHOST, currentMatch) : command.equals("slimeling") ? UseItemRequest.getInstance(KoLConstants.CONSUME_SLIME, currentMatch) : UseItemRequest.getInstance(currentMatch); RequestThread.postRequest(request); } if (level < 2) { return; } } } } }
public VendingMachineRequest(final String action, final AdventureResult ar) { this(action, ar.getItemId(), ar.getCount()); }
public static void cleanup() { int itemCount; AdventureResult currentItem; Object[] items = KoLConstants.junkList.toArray(); // Before doing anything else, go through the list of items // which are traditionally used and use them. Also, if the item // can be untinkered, it's usually more beneficial to untinker // first. boolean madeUntinkerRequest = false; boolean canUntinker = UntinkerRequest.canUntinker(); ArrayList closetList = new ArrayList(); for (int i = 0; i < items.length; ++i) { if (!KoLConstants.singletonList.contains(items[i]) || KoLConstants.closet.contains(items[i])) { continue; } if (KoLConstants.inventory.contains(items[i])) { closetList.add(((AdventureResult) items[i]).getInstance(1)); } } if (closetList.size() > 0) { RequestThread.postRequest( new ClosetRequest(ClosetRequest.INVENTORY_TO_CLOSET, closetList.toArray())); } do { madeUntinkerRequest = false; for (int i = 0; i < items.length; ++i) { currentItem = (AdventureResult) items[i]; itemCount = currentItem.getCount(KoLConstants.inventory); if (itemCount == 0) { continue; } if (canUntinker && (ConcoctionDatabase.getMixingMethod(currentItem) & KoLConstants.CT_MASK) == KoLConstants.COMBINE) { RequestThread.postRequest(new UntinkerRequest(currentItem.getItemId())); madeUntinkerRequest = true; continue; } switch (currentItem.getItemId()) { case 184: // briefcase case 533: // Gnollish toolbox case 553: // 31337 scroll case 604: // Penultimate fantasy chest case 621: // Warm Subject gift certificate case 831: // small box case 832: // large box case 1768: // Gnomish toolbox case 1917: // old leather wallet case 1918: // old coin purse case 2057: // black pension check case 2058: // black picnic basket case 2511: // Frat Army FGF case 2512: // Hippy Army MPE case 2536: // canopic jar case 2612: // ancient vinyl coin purse RequestThread.postRequest( UseItemRequest.getInstance(currentItem.getInstance(itemCount))); break; } } } while (madeUntinkerRequest); // Now you've got all the items used up, go ahead and prepare to // pulverize strong equipment. int itemPower; if (KoLCharacter.hasSkill("Pulverize")) { boolean hasMalusAccess = KoLCharacter.isMuscleClass() && !KoLCharacter.isAvatarOfBoris(); for (int i = 0; i < items.length; ++i) { currentItem = (AdventureResult) items[i]; if (KoLConstants.mementoList.contains(currentItem)) { continue; } if (currentItem.getName().startsWith("antique")) { continue; } itemCount = currentItem.getCount(KoLConstants.inventory); itemPower = EquipmentDatabase.getPower(currentItem.getItemId()); if (itemCount > 0 && !NPCStoreDatabase.contains(currentItem.getName(), false)) { switch (ItemDatabase.getConsumptionType(currentItem.getItemId())) { case KoLConstants.EQUIP_HAT: case KoLConstants.EQUIP_PANTS: case KoLConstants.EQUIP_SHIRT: case KoLConstants.EQUIP_WEAPON: case KoLConstants.EQUIP_OFFHAND: if (InventoryManager.hasItem(ItemPool.TENDER_HAMMER) && itemPower >= 100 || hasMalusAccess && itemPower > 10) { RequestThread.postRequest(new PulverizeRequest(currentItem.getInstance(itemCount))); } break; case KoLConstants.EQUIP_FAMILIAR: case KoLConstants.EQUIP_ACCESSORY: if (InventoryManager.hasItem(ItemPool.TENDER_HAMMER)) { RequestThread.postRequest(new PulverizeRequest(currentItem.getInstance(itemCount))); } break; default: if (currentItem.getName().endsWith("powder") || currentItem.getName().endsWith("nuggets")) { RequestThread.postRequest(new PulverizeRequest(currentItem.getInstance(itemCount))); } break; } } } } // Now you've got all the items used up, go ahead and prepare to // sell anything that's left. ArrayList sellList = new ArrayList(); for (int i = 0; i < items.length; ++i) { currentItem = (AdventureResult) items[i]; if (KoLConstants.mementoList.contains(currentItem)) { continue; } if (currentItem.getItemId() == ItemPool.MEAT_PASTE) { continue; } itemCount = currentItem.getCount(KoLConstants.inventory); if (itemCount > 0) { sellList.add(currentItem.getInstance(itemCount)); } } if (!sellList.isEmpty()) { RequestThread.postRequest(new AutoSellRequest(sellList.toArray())); sellList.clear(); } if (!KoLCharacter.canInteract()) { for (int i = 0; i < items.length; ++i) { currentItem = (AdventureResult) items[i]; if (KoLConstants.mementoList.contains(currentItem)) { continue; } if (currentItem.getItemId() == ItemPool.MEAT_PASTE) { continue; } itemCount = currentItem.getCount(KoLConstants.inventory) - 1; if (itemCount > 0) { sellList.add(currentItem.getInstance(itemCount)); } } if (!sellList.isEmpty()) { RequestThread.postRequest(new AutoSellRequest(sellList.toArray())); } } }