Skip to content

Commit

Permalink
Allow users to force detection of forest florist
Browse files Browse the repository at this point in the history
  • Loading branch information
gausie committed Jul 12, 2023
1 parent 454d818 commit 62e23e3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
16 changes: 11 additions & 5 deletions packages/greenbox-script/src/greenbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,18 @@ import {
import { Kmail } from "libram";
import { getNumber, getBoolean } from "libram/dist/property";

import { getIotMStatus } from "./iotms";
import { getIotMStatus, IotMOptions } from "./iotms";
import { haveItem } from "./utils";

/**
* Generates an object with a list of IOTMs & ownership stats.
* @returns large string of IOTM ownership
*/

function checkIotMs() {
return (loadIotMs()?.data ?? []).map((iotm) => [iotm.id, getIotMStatus(iotm)] as RawIotM);
function checkIotMs(options: IotMOptions) {
return (loadIotMs()?.data ?? []).map(
(iotm) => [iotm.id, getIotMStatus(iotm, options)] as RawIotM,
);
}

/**
Expand Down Expand Up @@ -213,13 +215,14 @@ function main(args = ""): void {
printHtml(`
Usage:
<table border=0>
<tr><td>greenbox [--help|-h|--wipe|-w|--private|-p]</td></tr>
<tr><td>greenbox [...options]</td></tr>
</table>
Options:
<table border=0>
<tr><td>--help -h</td><td>See this message</td></tr>
<tr><td>--wipe -w</td><td>Wipe your public profile</td></tr>
<tr><td>--private -w</td><td>Generate a link without updating your public profile</td></tr>
<tr><td>--force-florist</td><td>Report that you have an Order of the Green Thumb Order Form bound, even if KoLmafia says otherwise</td></tr>
</table>
`);
return;
Expand Down Expand Up @@ -252,14 +255,17 @@ function main(args = ""): void {

const tattoos = visitUrl("account_tattoos.php");

const forceIotMs = [];
if (hasFlag(args, "--force-florist")) forceIotMs.push(6413);

const code = compress({
meta: checkMeta(),
skills: checkSkills(),
familiars: checkFamiliars(),
trophies: checkTrophies(),
...checkTattoos(tattoos),
paths: checkPaths(tattoos),
iotms: checkIotMs(),
iotms: checkIotMs({ force: forceIotMs }),
});

const link = `https://greenbox.loathers.net/?${keepPrivate ? `d=${code}` : `u=${myId()}`}`;
Expand Down
12 changes: 9 additions & 3 deletions packages/greenbox-script/src/iotms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ import { haveItem } from "./utils";

const arrayOf = <T>(items: T | T[]) => (Array.isArray(items) ? items : [items]);

function haveBound(iotm: IotMDef): boolean {
export type IotMOptions = Partial<{
force: number[];
}>;

function haveBound(iotm: IotMDef, options: IotMOptions): boolean {
if (options.force?.includes(iotm.id)) return true;

const boxed = Item.get(iotm.id);

switch (iotm.type) {
Expand Down Expand Up @@ -66,8 +72,8 @@ function haveBound(iotm: IotMDef): boolean {
}
}

export function getIotMStatus(iotm: IotMDef): IotMStatus {
if (haveBound(iotm)) return IotMStatus.BOUND;
export function getIotMStatus(iotm: IotMDef, options: IotMOptions = {}): IotMStatus {
if (haveBound(iotm, options)) return IotMStatus.BOUND;
const boxed = Item.get(iotm.id);
if (haveItem(boxed)) return IotMStatus.BOXED;
return IotMStatus.NONE;
Expand Down

0 comments on commit 62e23e3

Please sign in to comment.