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

[WIP] Price limit implementation #755

Draft
wants to merge 4 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions src/classes/Pricelist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface EntryData {
intent: 0 | 1 | 2; // 'buy', 'sell', 'bank'
buy?: Currency | null;
sell?: Currency | null;
limit?: { buy: Currency | null; sell: Currency | null };
promoted?: 0 | 1;
group?: string | null;
note?: { buy: string | null; sell: string | null };
Expand All @@ -53,6 +54,8 @@ export class Entry implements EntryData {

sell: Currencies | null;

limit: { buy: Currencies | null; sell: Currencies | null };

promoted: 0 | 1;

group: string | null;
Expand Down
1 change: 1 addition & 0 deletions src/lib/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const v = new Validator();
import * as pl from '../schemas/pricelist-json/export';

v.addSchema(pl.currenciesSchema);
v.addSchema(pl.limitSchema);
v.addSchema(pl.pricelistSchema);
v.addSchema(pl.addSchema);
v.addSchema(pl.listingSchema);
Expand Down
3 changes: 2 additions & 1 deletion src/schemas/pricelist-json/export.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { currenciesSchema } from './tf2-currencies';
import { limitSchema } from './limit';
import { pricelistSchema } from './pricelist';
import { addSchema } from './pricelist-add';
import { listingSchema } from './listing-note';
import { pricesDataObject } from './pricesDataObject';

export { currenciesSchema, pricelistSchema, addSchema, listingSchema, pricesDataObject };
export { currenciesSchema, limitSchema, pricelistSchema, addSchema, listingSchema, pricesDataObject };
16 changes: 16 additions & 0 deletions src/schemas/pricelist-json/limit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import jsonschema from 'jsonschema';

export const limitSchema: jsonschema.Schema = {
id: 'pricelist-limit',
type: 'object',
properties: {
buy: {
anyOf: [{ $ref: 'tf2-currencies' }, { type: null }]
},
sell: {
anyOf: [{ $ref: 'tf2-currencies' }, { type: null }]
}
},
additionalProperties: false,
required: ['buy', 'sell']
};
3 changes: 3 additions & 0 deletions src/schemas/pricelist-json/pricelist-add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export const addSchema: jsonschema.Schema = {
// sell price
$ref: 'tf2-currencies'
},
limit: {
$ref: 'pricelist-limit'
},
promoted: {
// 0 = not promote, 1 = promote item (Sell only)
type: 'integer',
Expand Down
3 changes: 3 additions & 0 deletions src/schemas/pricelist-json/pricelist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export const pricelistSchema: jsonschema.Schema = {
sell: {
$ref: 'tf2-currencies'
},
limit: {
$ref: 'pricelist-limit'
},
promoted: {
type: 'integer',
enum: [0, 1]
Expand Down
3 changes: 3 additions & 0 deletions src/schemas/pricelist-json/pricesDataObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export const pricesDataObject: jsonschema.Schema = {
sell: {
$ref: 'tf2-currencies'
},
limit: {
$ref: 'pricelist-limit'
},
promoted: {
type: 'number',
enum: [0, 1]
Expand Down