Skip to content

Commit

Permalink
Remove clue step items; show deleted + added items
Browse files Browse the repository at this point in the history
  • Loading branch information
themrrobert committed Mar 2, 2024
1 parent bb7037a commit 6821bf5
Show file tree
Hide file tree
Showing 4 changed files with 2,693 additions and 10,079 deletions.
23 changes: 22 additions & 1 deletion scripts/prepare.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
import minifyDist from './minifyDist';
import prepareItems from './prepareItems';
// @ts-ignore asif
import _items from '../src/data/items/item_data.json';

minifyDist();
prepareItems();
const previousItems: string[] = [];
for (const key of Object.keys(_items)) {
previousItems.push(key);
}

const newItems: string[] = [];
const deletedItems: string[] = [];
prepareItems().then(newItemMap => {
for (const key of Object.keys(newItemMap))
{
if (!previousItems.includes(key)) {
newItems.push(key);
}
}
for (const key of previousItems) {
if (!newItemMap[key]) deletedItems.push(key);
}
console.log(`Deleted items: ${deletedItems}`);
console.log(`New items: ${newItems}`);
});
16 changes: 12 additions & 4 deletions scripts/prepareItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { readFileSync, writeFileSync } from 'fs';
import fetch from 'node-fetch';

import { EquipmentSlot, Item } from '../dist/meta/types';
import Items, { USELESS_ITEMS } from '../dist/structures/Items';
import Items, { DO_NOT_REMOVE, USELESS_ITEMS } from '../dist/structures/Items';
import { itemID } from '../dist/util';
import { itemChanges } from './manualItemChanges';

Expand All @@ -30,15 +30,21 @@ interface RawItemCollection {
};
}

// This regex matches the nearly 600 individual clue-step items:
const clueStepRegex = /^Clue scroll \((beginner|easy|medium|hard|elite|master)\) - .*$/;

function itemShouldntBeAdded(item: any) {
if (DO_NOT_REMOVE.includes(item.id)) return false;

return (
USELESS_ITEMS.includes(item.id) ||
item.duplicate === true ||
item.noted ||
item.linked_id_item ||
item.placeholder ||
item.name === 'Null' ||
item.wiki_name?.includes(' (Worn)')
item.wiki_name?.includes(' (Worn)') ||
(item.wiki_name && clueStepRegex.exec(item.wiki_name))
);
}

Expand Down Expand Up @@ -228,7 +234,7 @@ const itemsToIgnorePrices = [

const keysToWarnIfRemovedOrAdded: (keyof Item)[] = ['equipable', 'equipment', 'weapon'];

export default async function prepareItems(): Promise<void> {
export default async function prepareItems() {
const messages: string[] = [];
const allItemsRaw: RawItemCollection = await fetch(
'https://raw.githubusercontent.com/0xNeffarion/osrsreboxed-db/master/docs/items-complete.json'
Expand Down Expand Up @@ -426,7 +432,7 @@ export default async function prepareItems(): Promise<void> {

messages.push(`New Items: ${moidLink(newItems)}.`);
messages.push(`Deleted Items: ${moidLink(deletedItems)}.`);
const sql = `SELECT
const sql = `SELECT
${deletedItems
.map(
item => `COUNT(*) FILTER (WHERE bank->>'${item.id}' IS NOT NULL) AS people_with_item_${item.id},
Expand All @@ -448,4 +454,6 @@ FROM users;
writeFileSync('./updates.txt', messages.join('\n'));

messages.push('Prepared items.');

return itemNameMap;
}
Loading

0 comments on commit 6821bf5

Please sign in to comment.