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

Add option toggle autoAddInvalidUnusual = false #412

Merged
merged 3 commits into from
Mar 4, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/classes/MyHandler/offer/accepted/updateListings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export default function updateListings(
const isDisabledHV = highValue.isDisableSKU.includes(sku);
const isAdmin = bot.isAdmin(offer.partner);
const isNotSkinsOrWarPaint = SKU.fromString(sku).wear === null;
// if item is unusual and autoAddInvalidUnusual is set to true then we allow addInvalidUnusual.
// If the item is not an unusual sku, we "allow" still (no-op)
const addInvalidUnusual = SKU.fromString(sku).quality === 5 ? opt.pricelist.autoAddInvalidUnusual : true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mainly for the Generic Unusual feature right?
So I guess it's much better to do it like this (together with some small refactorization):

const item = SKU.fromString(sku);
const isNotSkinsOrWarPaint = item.wear === null;
const addInvalidUnusual = item.quality === 5 && item.effect === null ? opt.pricelist.autoAddInvalidUnusual : true;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, wait. I don't think item.effect === null is correct.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, scratch that. My bad.

Copy link
Collaborator Author

@joekiller joekiller Mar 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I was about to say. I think in this case the SKU detected would be the SKU of the actual item at this point, so it would have an effect

Copy link
Member

@idinium96 idinium96 Mar 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep correct. It's not like when receiving the painted item (with normalize.painted.their set to true) or sold painted item to the trade partner (with normalize.painted.our set to false)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is somewhat a strange statement but it really should be "true" if either:

the item is unsual and we autoAddInvalidUnusual or,
if the item isn't an unusual.


const isAutoaddPainted =
normalizePainted.our === false && // must meet this setting
Expand All @@ -62,6 +65,7 @@ export default function updateListings(
isNotPureOrWeapons &&
sku !== '5021;6' && // not Mann Co. Supply Crate Key
isNotSkinsOrWarPaint && // exclude War Paint (could be skins)
addInvalidUnusual &&
!isDisabledHV &&
!isAdmin &&
opt.pricelist.autoAddInvalidItems.enable;
Expand Down
4 changes: 4 additions & 0 deletions src/classes/Options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ export const DEFAULTS = {
autoAddInvalidItems: {
enable: true
},
addInvalidUnusual: {
joekiller marked this conversation as resolved.
Show resolved Hide resolved
enable: false
},
autoAddPaintedItems: {
enable: true
},
Expand Down Expand Up @@ -1052,6 +1055,7 @@ interface Pricelist {
filterCantAfford?: OnlyEnable;
autoRemoveIntentSell?: OnlyEnable;
autoAddInvalidItems?: OnlyEnable;
autoAddInvalidUnusual?: OnlyEnable;
autoAddPaintedItems?: OnlyEnable;
priceAge?: PriceAge;
}
Expand Down
4 changes: 4 additions & 0 deletions src/schemas/options-json/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,9 @@ export const optionsSchema: jsonschema.Schema = {
autoAddInvalidItems: {
$ref: '#/definitions/only-enable'
},
autoAddInvalidUnusual: {
$ref: '#/definitions/only-enable'
},
autoAddPaintedItems: {
$ref: '#/definitions/only-enable'
},
Expand All @@ -543,6 +546,7 @@ export const optionsSchema: jsonschema.Schema = {
'filterCantAfford',
'autoRemoveIntentSell',
'autoAddInvalidItems',
'autoAddInvalidUnusual',
'autoAddPaintedItems',
'priceAge'
],
Expand Down