Skip to content

Commit

Permalink
Allow g.e trading hat/mask
Browse files Browse the repository at this point in the history
  • Loading branch information
gc committed Oct 13, 2023
1 parent e396277 commit 00812a6
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/lib/customItems/customItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9358,7 +9358,8 @@ setCustomItem(
{
customItemData: {
cantDropFromMysteryBoxes: true,
isSuperUntradeable: true
isSuperUntradeable: true,
superTradeableButTradeableOnGE: true
}
},
100_000
Expand Down Expand Up @@ -9410,7 +9411,8 @@ setCustomItem(
{
customItemData: {
cantDropFromMysteryBoxes: true,
isSuperUntradeable: true
isSuperUntradeable: true,
superTradeableButTradeableOnGE: true
}
},
100_000
Expand Down
8 changes: 8 additions & 0 deletions src/lib/customItems/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ export function setCustomItem(id: number, name: string, baseItem: string, newIte
if (hasSet.some(i => i.name === name) && name !== 'Smokey') {
throw new Error(`Tried to add 2 custom items with same name, called ${name}`);
}
if (
newItemData &&
newItemData.customItemData &&
newItemData.customItemData.superTradeableButTradeableOnGE &&
!newItemData.customItemData.isSuperUntradeable
) {
throw new Error('Tried to add a custom item with superTradeableButTradeableOnGE, but not isSuperUntradeable');
}
const data = deepMerge({ ...getOSItem(baseItem) }, { ...newItemData, name, id });
data.price = price || 1;

Expand Down
4 changes: 2 additions & 2 deletions src/lib/grandExchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
assert,
generateGrandExchangeID,
getInterval,
isSuperUntradeable,
isGEUntradeable,
itemNameFromID,
makeComponents,
toKMB
Expand Down Expand Up @@ -295,7 +295,7 @@ class GrandExchangeSingleton {
return { error: 'Invalid item.' };
}

if (isSuperUntradeable(item.id)) {
if (isGEUntradeable(item.id)) {
return { error: 'Invalid item.' };
}

Expand Down
1 change: 1 addition & 0 deletions src/lib/itemMods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface CustomItemData {
cantDropFromMysteryBoxes?: boolean;
cantBeDropped?: true;
isDiscontinued?: true;
superTradeableButTradeableOnGE?: true;
}

declare module 'oldschooljs/dist/meta/types' {
Expand Down
11 changes: 11 additions & 0 deletions src/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,17 @@ export function isSuperUntradeable(item: number | Item) {
return id >= 40_000 && id <= 45_000;
}

export function isGEUntradeable(item: number | Item) {
const fullItem = typeof item === 'number' ? Items.get(item) : item;
if (!fullItem || !fullItem.customItemData || !fullItem.customItemData.superTradeableButTradeableOnGE) {
return isSuperUntradeable(item);
}
if (fullItem.customItemData.isSuperUntradeable && fullItem.customItemData.superTradeableButTradeableOnGE) {
return false;
}
return isSuperUntradeable(item);
}

export function birdhouseLimit(user: MUser) {
let base = 4;
if (user.bitfield.includes(BitField.HasScrollOfTheHunt)) base += 4;
Expand Down

0 comments on commit 00812a6

Please sign in to comment.