Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various cleanups, tests, and small features. #1225

Merged
merged 10 commits into from
Nov 4, 2022
1 change: 1 addition & 0 deletions src/data/defaults.txt
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ user hallowienerSmutOrcs false
user hallowienerSonofaBeach false
user hallowienerVolcoino false
user hardcorePVPWarning false
user hareMillisecondsSaved 0
user harvestBatteriesHardcore true
user harvestBatteriesSoftcore true
user harvestGardenHardcore none
Expand Down
2 changes: 2 additions & 0 deletions src/data/fullness.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ bucket of honey 1 4 good 3 0 0 0 50 Sugar Rush
bunch of square grapes 2 7 awesome 6-7 1-5 5-20 1-5
C.H.U.M. chum 3 1 crappy 1 0 0 0 20 Majorly Poisoned
cactus fruit 2 7 awesome 6-7 6-20 1-5 1-5 lose 8-10 HP
Calzone of Legend 2 5 EPIC 0 0 0 0 Unspaded, 100 In the 'zone zone! (+50 Spell Damage, +25 Mys, +300% Mys, +100% Max HP/MP)
campfire baked potato 1 1 awesome 4-5 15-30 0 0 60 Trial by Campfire (Damage Reduction: 10)
campfire beans 1 1 awesome 3-4 0 10-20 0 40 The More You Eat (Stench Damage +15, Stench Spell Damage +15)
campfire coffee 1 1 awesome 3-4 0 0 10-20 40 Coffee Achiever (+25 Init)
Expand Down Expand Up @@ -248,6 +249,7 @@ D roll 2 4 awesome 6-8 0 20-30 0 20 On a Roll (+25 Food Drop)
dead lights pie 2 2 awesome 7-9 5-10 20-40 5-10
dead meat bun 3 4 decent 5 10 0 0
decent brain 1 1 decent 2 3-5 3-5 3-5 Zombie Slayer
Deep Dish of Legend 2 1 EPIC 0 0 0 0 Unspaded, 100 In the Depths (+15 Familiar Weight, +25 Mus, +300% Mus, +100% Max HP/MP)
dehydrated caviar 1 2 decent 2 0 0 15
delicious noodles 3 3 good 6-9 0 0 9-25
delicious salad 3 1 decent 3-5 0 0 0 25% chance of tattoo, SALAD
Expand Down
6 changes: 4 additions & 2 deletions src/data/items.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11017,10 +11017,12 @@
10989 plain calzone 392094485 bbat_calzone1.gif food, cook d 200
10990 roasted vegetable focaccia 705913927 bbat_focaccia.gif food, cook d 200
10991
10992
10993
10992 Calzone of Legend 463633597 bbat_calzone2.gif food d 400
10993 Recipe of Before Yore: Calzone of Legend 897961264 bbat_recipe.gif usable t,d 300
10994
10995 Recipe of Before Yore: roasted vegetable focaccia 497528859 bbat_recipe.gif usable t,d 200
10996 Recipe of Before Yore: plain calzone 115946584 bbat_recipe.gif usable t,d 200
10997 Recipe of Before Yore: baked veggie ricotta 385781133 bbat_recipe.gif usable t,d 200
10998 cookbookbat book 230914563 book5.gif familiar t,d 75
10999 Recipe of Before Yore: Deep Dish of Legend 924225296 bbat_recipe.gif usable t,d 100
11000 Deep Dish of Legend 394854595 bbat_pizza.gif food d 400
4 changes: 4 additions & 0 deletions src/data/modifiers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6189,9 +6189,11 @@ Effect Impregnably Delicious Damage Reduction: 30
Effect Improprie Tea Sleaze Damage: +30
Effect Improved Candy Vision Candy Drop: +25
Effect In a Lather Hot Damage: +20, Cold Damage: +20, Stench Damage: +20, Spooky Damage: +20, Sleaze Damage: +20, Hot Spell Damage: +40, Cold Spell Damage: +40, Stench Spell Damage: +40, Spooky Spell Damage: +40, Sleaze Spell Damage: +40, Ranged Damage: +20, Weapon Damage: +20, Weapon Damage Percent: +50, Spell Damage: +40, Spell Damage Percent: +50
Effect In the Depths Familiar Weight: +15, Muscle: +25, Muscle Percent: +300, Maximum HP Percent: +100, Maximum MP Percent: +100
Effect In the Limelight Muscle Percent: +20, Mysticality Percent: +20, Moxie Percent: +20
Effect In the Saucestream Mysticality Percent: +15
Effect In the Slimelight Stench Damage: +50
Effect In the 'zone zone! Spell Damage: +50, Mysticality: +25, Mysticality Percent: +300, Maximum HP Percent: +100, Maximum MP Percent: +100
Effect In Tuna MP Regen Min: 3, MP Regen Max: 5
Effect In Vino Vires Muscle Percent: +50, Mysticality Percent: +50, Moxie Percent: +50
# In Your Cups: Whoah...
Expand Down Expand Up @@ -8556,6 +8558,7 @@ Item bucket of honey Effect: "Sugar Rush", Effect Duration: 50
# buñuelos Jaliscos: NOTE: This item will stop working when Crimbo 2019 is over.
# buñuelos Jaliscos Effect: "Fishy", Effect Duration: 30
Item C.H.U.M. chum Effect: "Majorly Poisoned", Effect Duration: 20
Item Calzone of Legend Effect: "In the 'zone zone!", Effect Duration: 100
Item campfire baked potato Effect: "Trial by Campfire", Effect Duration: 60
Item campfire beans Effect: "The More You Eat", Effect Duration: 40
Item campfire coffee Effect: "Coffee Achiever", Effect Duration: 40
Expand Down Expand Up @@ -8594,6 +8597,7 @@ Item cupcake-in-a-cup Effect: "Cake Caked", Effect Duration: 10
Item cursed black pearl onion Effect: "Curse of the Black Pearl Onion", Effect Duration: 1
Item cursed sea biscuit Effect: "Curse Magnet", Effect Duration: 10
Item D roll Effect: "On a Roll", Effect Duration: 20
Item Deep Dish of Legend Effect: "In the Depths", Effect Duration: 100
Item denastified haunch Effect: "Faerie Fortune", Effect Duration: 30
Item devil dog Effect: "Devil Inside", Effect Duration: 30
Item diabolic pizza Lasts Until Rollover
Expand Down
2 changes: 2 additions & 0 deletions src/data/statuseffects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2737,3 +2737,5 @@
2737 Feeling Fancy bbat_focaccia.gif 69862d498ff6068ea6b31787d1a494b8 neutral none eat 1 roasted vegetable focaccia
2738 Angering Pizza Purists bbat_calzone1.gif 08f4024c1d6cf8ddbe0c52f4d8b86c33 neutral none eat 1 plain calzone
2739 Pretty Delicious bbat_casserole.gif 9f03022717f7b13fef44b5dab8289bba neutral none eat 1 baked veggie ricotta casserole
2740 In the Depths bbat_pizza.gif 4e1b5fb5d2e16e3bcf3d9013abdb4d5c neutral none eat 1 Deep Dish of Legend
2741 In the 'zone zone! bbat_calzone2.gif 041f3562195a07294511006a50e1c9cb neutral none eat 1 Calzone of Legend
57 changes: 43 additions & 14 deletions src/net/sourceforge/kolmafia/KoLAdventure.java
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,20 @@ public boolean canAdventure() {
&& !Preferences.getBoolean("_loveTunnelUsed");
}

// Unleash Your Inner Wolf
if (this.adventureId.equals(AdventurePool.INNER_WOLF_ID)) {
// Grimstone path must be "wolf"
if (!Preferences.getString("grimstoneMaskPath").equals("wolf")) {
return false;
}
// It takes three turns to Release Your Inner Wolf.
// On turns 0-24, you may do it.
// On turns 25-26, you are directed to train more in the Gym
// On turn 27, you must do it.
int turnsUsed = Preferences.getInteger("wolfTurnsUsed");
return turnsUsed < 25 || turnsUsed == 27;
}

/* Removed adventures.
if (this.adventureId.equals(AdventurePool.ELDRITCH_FISSURE_ID)) {
return Preferences.getBoolean("eldritchFissureAvailable");
Expand Down Expand Up @@ -1160,7 +1174,8 @@ public boolean canAdventure() {

// The Pandamonium zones are available if you have completed the Friars quest
if (this.zone.equals("Pandamonium")) {
return QuestDatabase.isQuestFinished(Quest.FRIAR)
return QuestDatabase.isQuestStarted(Quest.AZAZEL)
|| QuestDatabase.isQuestFinished(Quest.FRIAR)
|| (InventoryManager.hasItem(DODECAGRAM)
&& InventoryManager.hasItem(CANDLES)
&& InventoryManager.hasItem(BUTTERKNIFE));
Expand Down Expand Up @@ -1889,14 +1904,18 @@ public boolean canAdventure() {
// See if the tale is finished
switch (tale) {
case "hare" -> {
// 30 turns of the Hare-Brained effect. The zone closes when you
// lose the effect. You adventure at A Deserted Stretch of I-911
// 30 turns of the Hare-Brained effect.
// The zone closes when you lose the effect.
// You adventure at A Deserted Stretch of I-911
return KoLConstants.activeEffects.contains(HARE_BRAINED);
}
case "wolf" -> {
// 30 turns to adventure in Skid Row. The zone closes when you
// finish. We do not seem to track them?
return Preferences.getInteger("wolfTurnsUsed") < 30;
// 30 turns to adventure in Skid Row.
// At turn 27, you must Release Your Inner Wolf.
// (Handled above, as that is not adventure.php)
// The zone closes when you finish.

return Preferences.getInteger("wolfTurnsUsed") < 27;
}
case "stepmother" -> {
// 30 turns to adventure at The Prince's Ball. The zone closes when
Expand All @@ -1915,8 +1934,7 @@ public boolean canAdventure() {
}
case "witch" -> {
// 30 turns to adventure in The Candy Witch and the Relentless
// Child Thieves. The zone closes when you finish. We do not seem
// to track them?
// Child Thieves. The zone closes when you finish.
return Preferences.getInteger("candyWitchTurnsUsed") < 30;
}
}
Expand Down Expand Up @@ -2200,14 +2218,25 @@ public boolean prepareForAdventure() {

// Level 6 quest
if (this.zone.equals("Pandamonium")) {
if (QuestDatabase.isQuestFinished(Quest.FRIAR)) {
// If we have completed the ritual and visited Pandammonium, Azazel's
// quest is started and the areas in that zone are available.
if (QuestDatabase.isQuestStarted(Quest.AZAZEL)) {
return true;
}
// If we get here, we have the ritual items.
// Do the ritual
var request = new GenericRequest("friars.php?action=ritual&pwd");
request.run();
return QuestDatabase.isQuestFinished(Quest.FRIAR);

// If we get here but have not finished the ritual, we must perform it.
if (!QuestDatabase.isQuestFinished(Quest.FRIAR)) {
var request = new GenericRequest("friars.php?action=ritual&pwd");
request.run();
}

// If the quest is finished, visit Pandamonium to start Azazel's quest
if (QuestDatabase.isQuestFinished(Quest.FRIAR)) {
var request = new GenericRequest("pandamonium.php", false);
request.run();
}

return QuestDatabase.isQuestStarted(Quest.AZAZEL);
}

if (this.formSource.equals("dwarffactory.php")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class AdventurePool {
public static final String ELDRITCH_HORROR_ID = "town_eicfight2";
public static final String SHROUDED_PEAK_ID = "cloudypeak2";
public static final String TUNNEL_OF_LOVE_ID = "townwrong_tunnel";
public static final String INNER_WOLF_ID = "ioty2014_wolf";

public static final int SPOOKY_FOREST = 15;
public static final int DEGRASSI_KNOLL = 18;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,6 @@ public static String equipmentString(

private static final Pattern WEAPON_TYPE_PATTERN = Pattern.compile("\\(((\\d)-handed (.*?))\\)");

public static final void registerItem(
final int itemId, final String itemName, final String text) {
int power = DebugDatabase.parsePower(text);
EquipmentDatabase.registerItem(itemId, itemName, text, power);
}

public static final void registerItem(
final int itemId, final String itemName, final String text, final int power) {
// A new item has been detected. Examine the item description
Expand Down
34 changes: 27 additions & 7 deletions src/net/sourceforge/kolmafia/persistence/ItemDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -728,10 +728,8 @@ public static final String extractItemsPlural(final int count, final String item
public static final boolean parseNewItems(final String responseText) {
Matcher m = DESC_PATTERN.matcher(responseText);
while (m.find()) {
String descId = m.group(1);
if (ItemDatabase.getItemIdFromDescription(descId) == -1) {
ItemDatabase.registerItem(descId);
}
// This will register new items if they are unknown
ItemDatabase.lookupItemIdFromDescription(m.group(1));
}
return true;
}
Expand Down Expand Up @@ -777,12 +775,12 @@ public static final void registerItem(final int itemId) {
}
}

public static void registerItem(String descId) {
// Pull the itemName from the item description, which will be cached
public static int registerItem(String descId) {
// Pull the itemId and itemName from the item description, which will be cached
String text =
DebugDatabase.itemDescriptionText(DebugDatabase.rawItemDescriptionText(descId, true));
if (text == null) {
return;
return -1;
}

int itemId = DebugDatabase.parseItemId(text);
Expand All @@ -795,6 +793,8 @@ public static void registerItem(String descId) {
String itemName = DebugDatabase.parseName(text);

ItemDatabase.registerItem(itemId, itemName, descId, null, 0, false);

return itemId;
}

public static final void registerItem(final int itemId, String itemName, String descId) {
Expand Down Expand Up @@ -1808,6 +1808,26 @@ public static final int getItemIdFromDescription(final String descriptionId) {
return itemId == null ? -1 : itemId.intValue();
}

/**
* Returns the id for an item, given its description id. If the item is unknown, register a new
* item from the description text
*
* @param descId The description id of the item to lookup
* @return The item id of the corresponding item
*/
public static final int lookupItemIdFromDescription(final String descId) {
if (descId.equals("")) {
return -1;
}
// See if we know the id already
Integer itemId = ItemDatabase.itemIdByDescription.get(descId);
if (itemId == null) {
// No. register a new item.
return ItemDatabase.registerItem(descId);
}
return itemId;
}

/**
* Returns a list of all items which contain the given substring. This is useful for people who
* are doing lookups on items.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static void parseResponse(final String location, final String responseTex
int itemId = StringUtilities.parseInt(matcher.group(1));
Integer iitemId = itemId;
String descId = matcher.group(2);
String itemName = matcher.group(3);
String itemName = matcher.group(3).trim();
String currency = matcher.group(4);
int price = StringUtilities.parseInt(matcher.group(5));
int row = StringUtilities.parseInt(matcher.group(6));
Expand Down
4 changes: 2 additions & 2 deletions src/net/sourceforge/kolmafia/request/ClanStashRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ private static void parseStash(final String responseText) {
lastFindIndex = matcher.end();
int itemId = StringUtilities.parseInt(matcher.group(1));
String descId = matcher.group(2);
String itemString = matcher.group(3);
String itemName = matcher.group(3).trim();

String quantityString = matcher.group(5);
int quantity = 1;
Expand All @@ -251,7 +251,7 @@ private static void parseStash(final String responseText) {

// If this is a previously unknown item, register it.
if (ItemDatabase.getItemName(itemId) == null) {
ItemDatabase.registerItem(itemId, itemString, descId);
ItemDatabase.registerItem(itemId, itemName, descId);
}

items.add(ItemPool.get(itemId, quantity));
Expand Down
22 changes: 8 additions & 14 deletions src/net/sourceforge/kolmafia/request/EquipmentRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1431,23 +1431,17 @@ private static void parseEquipment(

String descId = matcher.group(1) != null ? matcher.group(2) : "";
String name = matcher.group(3).trim();
int itemId = ItemDatabase.getItemIdFromDescription(descId);
AdventureResult item;
if (slot == EquipmentManager.FAMILIAR
|| slot == EquipmentManager.HOLSTER
|| EquipmentDatabase.contains(itemId)) {
item = ItemPool.get(itemId);
} else {
RequestLogger.printLine("Found unknown equipped item: \"" + name + "\" descid = " + descId);

// No itemId available for equipped items!
// ItemDatabase.registerItem( itemId, name, descId );
// This will register a new item from the descid, if needed
int itemId = ItemDatabase.lookupItemIdFromDescription(descId);

// Put in a dummy item. If it gets unequipped, we will
// find and identify it in inventory.
item = AdventureResult.tallyItem(name, 1, false);
if (slot != EquipmentManager.FAMILIAR
&& slot != EquipmentManager.HOLSTER
&& !EquipmentDatabase.contains(itemId)) {
RequestLogger.printLine("Found unknown equipped item: \"" + name + "\" descid = " + descId);
}

AdventureResult item = ItemPool.get(itemId);

equipment[slot] = item;

if (RequestLogger.isDebugging()) {
Expand Down
21 changes: 16 additions & 5 deletions src/net/sourceforge/kolmafia/request/FightRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6946,25 +6946,36 @@ else if (FightRequest.anapest && str.contains("You went up a level")) {

private static final Pattern CANDY_PATTERN = Pattern.compile("\\+(\\d+) Candy");
private static final Pattern PIGS_PATTERN = Pattern.compile("\\+(\\d+) Pigs Evicted!");
private static final Pattern SECONDS_PATTERN = Pattern.compile("(\\d+)\\.(\\d+) Seconds Saved!");

private static boolean handleGrimstone(
final TagNode node, final TagNode inode, final TagStatus status) {

if (!status.won) return false;
if (inode == null) return false;

String src = inode.getAttributeByName("src");
if (src == null) return false;
String image = src.substring(src.lastIndexOf("/") + 1);

String image = src.substring(src.lastIndexOf("/") + 1);
String text = node.getText().toString();

switch (image) {
case "trophy.gif" -> {
Matcher matcher = PIGS_PATTERN.matcher(text);
if (!matcher.find()) return false;
int pigs = StringUtilities.parseInt(matcher.group(1));
Preferences.increment("wolfPigsEvicted", pigs);
break;
if (matcher.find()) {
int pigs = StringUtilities.parseInt(matcher.group(1));
Preferences.increment("wolfPigsEvicted", pigs);
break;
}
matcher = SECONDS_PATTERN.matcher(text);
if (matcher.find()) {
int seconds = StringUtilities.parseInt(matcher.group(1));
int milliseconds = StringUtilities.parseInt(matcher.group(2));
Preferences.increment("hareMillisecondsSaved", (seconds * 1000) + milliseconds);
break;
}
return false;
}
case "candypile.gif" -> {
Matcher matcher = CANDY_PATTERN.matcher(text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static void parseResponse(final String urlString, final String responseTe
while (matcher.find()) {
int id = StringUtilities.parseInt(matcher.group(1));
String desc = matcher.group(2);
String name = matcher.group(3);
String name = matcher.group(3).trim();
String data = ItemDatabase.getItemDataName(id);
// String price = matcher.group(4);
if (data == null || !data.equals(name)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static void parseResponse(final String urlString, final String responseTe
if (matcher.find()) {
int itemId = StringUtilities.parseInt(matcher.group(1));
String descId = matcher.group(2);
String itemName = matcher.group(3);
String itemName = matcher.group(3).trim();
int price = StringUtilities.parseInt(matcher.group(4));
String match = ItemDatabase.getItemDataName(itemId);
boolean checkItemName = !KoLCharacter.isCrazyRandomTwo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ public static final void parseShopResponse(final String urlString, final String
while (matcher.find()) {
int id = StringUtilities.parseInt(matcher.group(1));
String desc = matcher.group(2);
String name = matcher.group(3);
String name = matcher.group(3).trim();
String data = ItemDatabase.getItemDataName(id);
String countString = matcher.group(4);
int count = countString == null ? 1 : StringUtilities.parseInt(matcher.group(5));
Expand Down
2 changes: 1 addition & 1 deletion src/net/sourceforge/kolmafia/request/PhineasRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static void parseResponse(final String urlString, final String responseTe
while (matcher.find()) {
int id = StringUtilities.parseInt(matcher.group(1));
String desc = matcher.group(2);
String name = matcher.group(3);
String name = matcher.group(3).trim();
String data = ItemDatabase.getItemDataName(id);
if (data == null || !data.equals(name)) {
ItemDatabase.registerItem(id, name, desc);
Expand Down