From b342b35f6d78f665f5434e146e87f2249eaa54f3 Mon Sep 17 00:00:00 2001 From: gausie Date: Mon, 30 Sep 2024 21:33:01 +0000 Subject: [PATCH] Build: (2f58b1e) Black & White Apron project (#105) * Black & White Apron project. * tweak spading data. * include version check etc. * fix bug * address comments --- scripts/excavator/excavator.js | 732 +++++++++++++++++++-------------- 1 file changed, 428 insertions(+), 304 deletions(-) diff --git a/scripts/excavator/excavator.js b/scripts/excavator/excavator.js index 3a860f1..4abc01a 100644 --- a/scripts/excavator/excavator.js +++ b/scripts/excavator/excavator.js @@ -963,9 +963,9 @@ var require_copy_constructor_properties = __commonJS({ "../../node_modules/core-js/internals/copy-constructor-properties.js": function(exports2, module2) { "use strict"; init_kolmafia_polyfill(); - var hasOwn = require_has_own_property(), ownKeys7 = require_own_keys(), getOwnPropertyDescriptorModule = require_object_get_own_property_descriptor(), definePropertyModule = require_object_define_property(); + var hasOwn = require_has_own_property(), ownKeys8 = require_own_keys(), getOwnPropertyDescriptorModule = require_object_get_own_property_descriptor(), definePropertyModule = require_object_define_property(); module2.exports = function(target, source, exceptions) { - for (var keys = ownKeys7(source), defineProperty = definePropertyModule.f, getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f, i = 0; i < keys.length; i++) { + for (var keys = ownKeys8(source), defineProperty = definePropertyModule.f, getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f, i = 0; i < keys.length; i++) { var key = keys[i]; !hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key)) && defineProperty(target, key, getOwnPropertyDescriptor(source, key)); } @@ -6358,7 +6358,7 @@ function getBlessingModifiers() { }, {}); } -// ../excavator-projects/projects/coatOfPaint.ts +// ../excavator-projects/projects/blackAndWhiteApron.ts init_kolmafia_polyfill(); var import_kolmafia4 = require("kolmafia"); function _slicedToArray2(r, e) { @@ -6441,15 +6441,139 @@ function _toPrimitive2(t, r) { } return (r === "string" ? String : Number)(t); } +var BLACK_AND_WHITE_APRON = { + name: "Black & White Apron", + slug: "bwapron", + description: "Spade how the Black & White Apron meals are seeded", + author: "worthawholebean", + hooks: { + CHOICE_VISIT: function(choice, page) { + return choice !== "1518" ? null : spadeBw(page); + } + }, + since: 28071 +}; +function spadeBw(page) { + var _page$match, main0 = (_page$match = page.match(/name="meal"\s+value="0"\s+data-name="([^"]*)"/)) === null || _page$match === void 0 ? void 0 : _page$match[1]; + if (!main0) return null; + var main2 = { + "dinner salad": "lettuce", + "chicken wings": "chicken", + "baked potatoes": "potato", + "beef stew": "beef", + "fish sandwich": "fish", + "pork butt": "pork" + }[main0]; + if (!main2) return null; + var ingredientMatches = Array.from(page.matchAll(/name="ingredients([0-9])\[\]"\s+value="([0-9]+)"/g)); + if (ingredientMatches.length !== 15) return null; + var mealsEaten = parseInt((0, import_kolmafia4.getProperty)("bwApronMealsEaten")); + Number.isFinite(mealsEaten) || (mealsEaten = -1); + var result = _objectSpread2({ + path: (0, import_kolmafia4.myPath)().id, + class: (0, import_kolmafia4.myClass)().id, + day: (0, import_kolmafia4.myDaycount)(), + mealsEaten: mealsEaten, + main: main2 + }, Object.fromEntries(ingredientMatches.map(function(_ref, index) { + var _ref2 = _slicedToArray2(_ref, 3), meal = _ref2[1], ingredient = _ref2[2]; + return ["ingredient".concat(meal).concat(index % 5), ingredient]; + }))); + return result; +} + +// ../excavator-projects/projects/coatOfPaint.ts +init_kolmafia_polyfill(); +var import_kolmafia5 = require("kolmafia"); +function _slicedToArray3(r, e) { + return _arrayWithHoles3(r) || _iterableToArrayLimit3(r, e) || _unsupportedIterableToArray4(r, e) || _nonIterableRest3(); +} +function _nonIterableRest3() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} +function _unsupportedIterableToArray4(r, a) { + if (r) { + if (typeof r == "string") return _arrayLikeToArray4(r, a); + var t = {}.toString.call(r).slice(8, -1); + return t === "Object" && r.constructor && (t = r.constructor.name), t === "Map" || t === "Set" ? Array.from(r) : t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray4(r, a) : void 0; + } +} +function _arrayLikeToArray4(r, a) { + (a == null || a > r.length) && (a = r.length); + for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; + return n; +} +function _iterableToArrayLimit3(r, l) { + var t = r == null ? null : typeof Symbol < "u" && r[Symbol.iterator] || r["@@iterator"]; + if (t != null) { + var e, n, i, u, a = [], f = !0, o = !1; + try { + if (i = (t = t.call(r)).next, l === 0) { + if (Object(t) !== t) return; + f = !1; + } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) ; + } catch (r2) { + o = !0, n = r2; + } finally { + try { + if (!f && t.return != null && (u = t.return(), Object(u) !== u)) return; + } finally { + if (o) throw n; + } + } + return a; + } +} +function _arrayWithHoles3(r) { + if (Array.isArray(r)) return r; +} +function ownKeys3(e, r) { + var t = Object.keys(e); + if (Object.getOwnPropertySymbols) { + var o = Object.getOwnPropertySymbols(e); + r && (o = o.filter(function(r2) { + return Object.getOwnPropertyDescriptor(e, r2).enumerable; + })), t.push.apply(t, o); + } + return t; +} +function _objectSpread3(e) { + for (var r = 1; r < arguments.length; r++) { + var t = arguments[r] != null ? arguments[r] : {}; + r % 2 ? ownKeys3(Object(t), !0).forEach(function(r2) { + _defineProperty3(e, r2, t[r2]); + }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys3(Object(t)).forEach(function(r2) { + Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2)); + }); + } + return e; +} +function _defineProperty3(e, r, t) { + return (r = _toPropertyKey3(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; +} +function _toPropertyKey3(t) { + var i = _toPrimitive3(t, "string"); + return typeof i == "symbol" ? i : i + ""; +} +function _toPrimitive3(t, r) { + if (typeof t != "object" || !t) return t; + var e = t[Symbol.toPrimitive]; + if (e !== void 0) { + var i = e.call(t, r || "default"); + if (typeof i != "object") return i; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return (r === "string" ? String : Number)(t); +} var COAT_OF_PAINT = { name: "Fresh Coat of Paint", description: "Determine the relationship between Fresh Coat of Paint modifiers and the day seed.", author: "Phillammon", hooks: { DESC_ITEM: function(itemName, page) { - if (itemName !== import_kolmafia4.Item.get("fresh coat of paint").name) return null; - var mod = (0, import_kolmafia4.getProperty)("_coatOfPaintModifier"); - return mod === "" || import_kolmafia4.sessionStorage.getItem("reportedCoatOfPaintMod") === mod ? null : (import_kolmafia4.sessionStorage.setItem("reportedCoatOfPaintMod", mod), _objectSpread2(_objectSpread2(_objectSpread2({}, getPaintModifiers(page)), getDaySeed()), getDifficultySeed())); + if (itemName !== import_kolmafia5.Item.get("fresh coat of paint").name) return null; + var mod = (0, import_kolmafia5.getProperty)("_coatOfPaintModifier"); + return mod === "" || import_kolmafia5.sessionStorage.getItem("reportedCoatOfPaintMod") === mod ? null : (import_kolmafia5.sessionStorage.setItem("reportedCoatOfPaintMod", mod), _objectSpread3(_objectSpread3(_objectSpread3({}, getPaintModifiers(page)), getDaySeed()), getDifficultySeed())); } } }, COAT_OF_PAINT_MODIFIERS = { @@ -6459,23 +6583,23 @@ var COAT_OF_PAINT = { }, COAT_BONUS_REGEX = /Spells<\/font>
(.+?)<\/font>
Enchantments are different every day<\/font>/; function getPaintModifiers(page) { var paintMods = Object.entries(COAT_OF_PAINT_MODIFIERS).reduce(function(data, _ref) { - var _ref2 = _slicedToArray2(_ref, 2), type = _ref2[0], mods = _ref2[1], mod = mods.find(function(m) { - return (0, import_kolmafia4.numericModifier)(import_kolmafia4.Item.get("fresh coat of paint"), m) !== 0; + var _ref2 = _slicedToArray3(_ref, 2), type = _ref2[0], mods = _ref2[1], mod = mods.find(function(m) { + return (0, import_kolmafia5.numericModifier)(import_kolmafia5.Item.get("fresh coat of paint"), m) !== 0; }); - return _objectSpread2(_objectSpread2({}, data), {}, _defineProperty2(_defineProperty2({}, type, mod || ""), "".concat(type, "_value"), mod ? String((0, import_kolmafia4.numericModifier)(import_kolmafia4.Item.get("fresh coat of paint"), mod)) : "")); + return _objectSpread3(_objectSpread3({}, data), {}, _defineProperty3(_defineProperty3({}, type, mod || ""), "".concat(type, "_value"), mod ? String((0, import_kolmafia5.numericModifier)(import_kolmafia5.Item.get("fresh coat of paint"), mod)) : "")); }, {}), bonus = page.match(COAT_BONUS_REGEX); return bonus && (paintMods.bonus = bonus[1]), paintMods; } // ../excavator-projects/projects/designerSweatpants.ts init_kolmafia_polyfill(); -var import_kolmafia5 = require("kolmafia"); +var import_kolmafia6 = require("kolmafia"); function spadeSweatpants(encounter, page) { var _page$match; - if (!isEquippedAtEndOfCombat(import_kolmafia5.Item.get(["designer sweatpants", "replica designer sweatpants"]))) return null; + if (!isEquippedAtEndOfCombat(import_kolmafia6.Item.get(["designer sweatpants", "replica designer sweatpants"]))) return null; var sweat = Number((_page$match = page.match(/You get (\d)% Sweatier/)) === null || _page$match === void 0 ? void 0 : _page$match[1]); if (!sweat) return null; - var location = toNormalisedString((0, import_kolmafia5.myLocation)()); + var location = toNormalisedString((0, import_kolmafia6.myLocation)()); return shouldDiscardData("DesignerSweatpants", location) ? null : { location: location, sweat: sweat @@ -6492,14 +6616,14 @@ var DESIGNER_SWEATPANTS = { // ../excavator-projects/projects/dropBindlestocking.ts init_kolmafia_polyfill(); -var import_kolmafia6 = require("kolmafia"); +var import_kolmafia7 = require("kolmafia"); var DROP_BINDLESTOCKING = { name: "Bindlestocking", description: "Track critical drops from the bindlestocking.", author: "Rinn", hooks: { COMBAT_ROUND: function(_, page) { - if ((0, import_kolmafia6.equippedAmount)(import_kolmafia6.Item.get("bindlestocking")) < 1) return null; + if ((0, import_kolmafia7.equippedAmount)(import_kolmafia7.Item.get("bindlestocking")) < 1) return null; var result = page.match(/Something gets knocked loose from your bindlestocking!.*?You acquire an item: (.*?)<\/b>/); if (!result) return null; var item = toNormalisedItem(result[1]); @@ -6512,7 +6636,7 @@ var DROP_BINDLESTOCKING = { // ../excavator-projects/projects/dropConSnowglobe.ts init_kolmafia_polyfill(); -var import_es_string = __toESM(require_es_string_match_all()), import_kolmafia7 = require("kolmafia"); +var import_es_string = __toESM(require_es_string_match_all()), import_kolmafia8 = require("kolmafia"); var PATTERNS = [/and find a weird thing you don't remember packing in the first place.*?You acquire an item: (.*?)<\/b>/, /go into your kitchen and try to recreate it.*?You acquire an item: (.*?)<\/b>/, /that dinner is still in your refrigerator.*?You acquire an item: (.*?)<\/b>/], DROP_CON_SNOWGLOBE = { name: "KoL Con 13 Snowglobe", slug: "snowglobe", @@ -6520,7 +6644,7 @@ var PATTERNS = [/and find a weird thing you don't remember packing in the first author: "Rinn", hooks: { COMBAT_ROUND: function(_, page) { - if (!isEquippedAtEndOfCombat(import_kolmafia7.Item.get("KoL Con 13 snowglobe"))) return null; + if (!isEquippedAtEndOfCombat(import_kolmafia8.Item.get("KoL Con 13 snowglobe"))) return null; var result = PATTERNS.reduce(function(result2, pattern) { var _page$match; return result2 != null ? result2 : (_page$match = page.match(pattern)) === null || _page$match === void 0 ? void 0 : _page$match[1]; @@ -6534,14 +6658,14 @@ var PATTERNS = [/and find a weird thing you don't remember packing in the first // ../excavator-projects/projects/dropMixedEverything.ts init_kolmafia_polyfill(); -var import_kolmafia8 = require("kolmafia"); +var import_kolmafia9 = require("kolmafia"); var DROP_MIXED_EVERYTHING = { name: "Can Of Mixed Everything", description: "Track drops from the can of mixed everything.", author: "Rinn", hooks: { COMBAT_ROUND: function(encounter, page) { - if (!isEquippedAtEndOfCombat(import_kolmafia8.Item.get("can of mixed everything"))) return null; + if (!isEquippedAtEndOfCombat(import_kolmafia9.Item.get("can of mixed everything"))) return null; var result = page.match(/Something falls out of your can of mixed everything.*?You acquire an item: (.*?)<\/b>/); if (!result) return null; var item = toNormalisedItem(result[1]); @@ -6554,7 +6678,7 @@ var DROP_MIXED_EVERYTHING = { // ../excavator-projects/projects/dropMrCheengs.ts init_kolmafia_polyfill(); -var import_kolmafia9 = require("kolmafia"); +var import_kolmafia10 = require("kolmafia"); var DROP_MR_CHEENGS = { name: "Mr. Cheeng's Spectacles", slug: "cheengs", @@ -6562,7 +6686,7 @@ var DROP_MR_CHEENGS = { author: "Rinn", hooks: { COMBAT_ROUND: function(encounter, page) { - if (!isEquippedAtEndOfCombat(import_kolmafia9.Item.get("Mr. Cheeng's spectacles"))) return null; + if (!isEquippedAtEndOfCombat(import_kolmafia10.Item.get("Mr. Cheeng's spectacles"))) return null; var result = page.match(/You see a weird thing out of the corner of your eye, and you grab it.\s+Far out, man!.*?You acquire an item: (.*?)<\/b>/); if (!result) return null; var item = toNormalisedItem(result[1]); @@ -6575,7 +6699,7 @@ var DROP_MR_CHEENGS = { // ../excavator-projects/projects/dropMrScreeges.ts init_kolmafia_polyfill(); -var import_kolmafia10 = require("kolmafia"); +var import_kolmafia11 = require("kolmafia"); var DROP_MR_SCREEGES = { name: "Mr. Screege's Spectacles", slug: "screeges", @@ -6583,7 +6707,7 @@ var DROP_MR_SCREEGES = { author: "Rinn", hooks: { COMBAT_ROUND: function(encounter, page) { - if (!isEquippedAtEndOfCombat(import_kolmafia10.Item.get("Mr. Screege's spectacles"))) return null; + if (!isEquippedAtEndOfCombat(import_kolmafia11.Item.get("Mr. Screege's spectacles"))) return null; var result = page.match(/You notice something valuable hidden .*?You acquire an item: (.*?)<\/b>/); if (!result) return null; var item = toNormalisedItem(result[1]); @@ -6596,7 +6720,7 @@ var DROP_MR_SCREEGES = { // ../excavator-projects/projects/genie.ts init_kolmafia_polyfill(); -var import_kolmafia11 = require("kolmafia"), GENIE = { +var import_kolmafia12 = require("kolmafia"), GENIE = { name: "Genie", description: "Determine which monsters and effects can be fought/acquired with the Genie.", author: "gausie", @@ -6616,8 +6740,8 @@ function spadeGenie(page) { if (!wish) return null; var success = !page.includes("
You could try, "), fightWished = wish.match(/(?:(?:to fight|i (?:was|were) fighting) (?:a )?)(.*)/), effectWished = wish.match(/(?:to be|i (?:was|were)) (?!big|a baller|rich|a little bit taller)(.*)/); if (fightWished) { - var monster = (0, import_kolmafia11.toMonster)(fightWished[1]); - if (monster === import_kolmafia11.Monster.none) return null; + var monster = (0, import_kolmafia12.toMonster)(fightWished[1]); + if (monster === import_kolmafia12.Monster.none) return null; var wishable = monster.wishable; return wishable === success ? null : { success: success, @@ -6625,8 +6749,8 @@ function spadeGenie(page) { value: monster.name }; } else if (effectWished) { - var effect = (0, import_kolmafia11.toEffect)(effectWished[1]); - if (effect === import_kolmafia11.Effect.none) return null; + var effect = (0, import_kolmafia12.toEffect)(effectWished[1]); + if (effect === import_kolmafia12.Effect.none) return null; var _wishable = !effect.attributes.includes("nohookah"); return _wishable === success ? null : { success: success, @@ -6639,7 +6763,7 @@ function spadeGenie(page) { // ../excavator-projects/projects/hookah.ts init_kolmafia_polyfill(); -var import_kolmafia12 = require("kolmafia"), HOOKAH = { +var import_kolmafia13 = require("kolmafia"), HOOKAH = { name: "Hookah", description: "Record instances of an effect obtained through a hookah-like mechanic that KoLmafia thinks shouldn't be possible.", author: "gausie", @@ -6649,28 +6773,28 @@ var import_kolmafia12 = require("kolmafia"), HOOKAH = { }; function extractEffectFromEvent(page, eventTriggerText) { var _page$match; - if (!page.includes(eventTriggerText)) return import_kolmafia12.Effect.none; + if (!page.includes(eventTriggerText)) return import_kolmafia13.Effect.none; var descid = (_page$match = page.match(new RegExp("".concat(eventTriggerText, '.*?
(.*?) 0; + return (0, import_kolmafia15.haveEffect)(prerequisite) > 0; case "familiar": - return (0, import_kolmafia14.myFamiliar)() === prerequisite; + return (0, import_kolmafia15.myFamiliar)() === prerequisite; case "equip": - return (0, import_kolmafia14.haveEquipped)(prerequisite); + return (0, import_kolmafia15.haveEquipped)(prerequisite); case "plant": - return (_getFloristPlants$myL = (_getFloristPlants$myL2 = (0, import_kolmafia14.getFloristPlants)()[(0, import_kolmafia14.myLocation)().toString()]) === null || _getFloristPlants$myL2 === void 0 ? void 0 : _getFloristPlants$myL2.includes(prerequisite)) !== null && _getFloristPlants$myL !== void 0 ? _getFloristPlants$myL : !1; + return (_getFloristPlants$myL = (_getFloristPlants$myL2 = (0, import_kolmafia15.getFloristPlants)()[(0, import_kolmafia15.myLocation)().toString()]) === null || _getFloristPlants$myL2 === void 0 ? void 0 : _getFloristPlants$myL2.includes(prerequisite)) !== null && _getFloristPlants$myL !== void 0 ? _getFloristPlants$myL : !1; default: return !1; } @@ -7042,30 +7166,30 @@ function checkSimpleIndicators(data, page, monster, monsterParts) { } } function checkElVibratoRestraints(data, page, monster, monsterParts) { - if (!((0, import_kolmafia14.availableAmount)(import_kolmafia14.Item.get("El Vibrato restraints")) === 0 || !page.includes("lvcuff.gif"))) { + if (!((0, import_kolmafia15.availableAmount)(import_kolmafia15.Item.get("El Vibrato restraints")) === 0 || !page.includes("lvcuff.gif"))) { var base = { monster: monster, part: "arm", source: "El Vibrato restraints" }; - monsterParts.includes("arm") && page.includes("This foe doesn't have any arms that you can find") ? data.push(_objectSpread4(_objectSpread4({}, base), {}, { + monsterParts.includes("arm") && page.includes("This foe doesn't have any arms that you can find") ? data.push(_objectSpread5(_objectSpread5({}, base), {}, { confirmation: !1 - })) : !monsterParts.includes("arm") && page.includes("You push the button on top of the restraints") && data.push(_objectSpread4(_objectSpread4({}, base), {}, { + })) : !monsterParts.includes("arm") && page.includes("You push the button on top of the restraints") && data.push(_objectSpread5(_objectSpread5({}, base), {}, { confirmation: !0 })); } } var MUTANT_COUTURE_SKILLS = { - head: import_kolmafia14.Skill.get("Strangle"), - arm: import_kolmafia14.Skill.get("Disarm"), - leg: import_kolmafia14.Skill.get("Entangle") + head: import_kolmafia15.Skill.get("Strangle"), + arm: import_kolmafia15.Skill.get("Disarm"), + leg: import_kolmafia15.Skill.get("Entangle") }; function checkMutantCouture(data, page, monster, monsterParts) { - (0, import_kolmafia14.currentRound)() !== 1 || !(0, import_kolmafia14.isWearingOutfit)("Mutant Couture") || !page.includes("") || (data.push.apply(data, _toConsumableArray3(Object.entries(MUTANT_COUTURE_SKILLS).filter(function(_ref2) { + var _ref3 = _slicedToArray4(_ref2, 2), part = _ref3[0], skill = _ref3[1]; return !monsterParts.includes(part) && page.includes('