@tf2-automatic/tf2-format 9.3.0-dev.3 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +124 -7
- package/package.json +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/index.js.map +1 -1
- package/src/lib/common.d.ts +29 -0
- package/src/lib/common.js +33 -0
- package/src/lib/common.js.map +1 -0
- package/src/lib/naming/index.d.ts +2 -1
- package/src/lib/naming/index.js +21 -26
- package/src/lib/naming/index.js.map +1 -1
- package/src/lib/parsing/bptf/parser.d.ts +8 -0
- package/src/lib/parsing/bptf/parser.js +89 -0
- package/src/lib/parsing/bptf/parser.js.map +1 -0
- package/src/lib/parsing/bptf/types.d.ts +94 -0
- package/src/lib/parsing/bptf/types.js +3 -0
- package/src/lib/parsing/bptf/types.js.map +1 -0
- package/src/lib/parsing/econ/parser.d.ts +3 -9
- package/src/lib/parsing/econ/parser.js +74 -138
- package/src/lib/parsing/econ/parser.js.map +1 -1
- package/src/lib/parsing/econ/types.d.ts +1 -1
- package/src/lib/parsing/helpers.d.ts +7 -0
- package/src/lib/parsing/helpers.js +105 -0
- package/src/lib/parsing/helpers.js.map +1 -0
- package/src/lib/parsing/index.d.ts +3 -1
- package/src/lib/parsing/index.js +3 -1
- package/src/lib/parsing/index.js.map +1 -1
- package/src/lib/parsing/parser.d.ts +4 -4
- package/src/lib/parsing/parser.js.map +1 -1
- package/src/lib/parsing/tf2/parser.d.ts +9 -10
- package/src/lib/parsing/tf2/parser.js +123 -384
- package/src/lib/parsing/tf2/parser.js.map +1 -1
- package/src/lib/parsing/tf2/types.d.ts +12 -59
- package/src/lib/parsing/tf2-api/parser.d.ts +10 -0
- package/src/lib/parsing/tf2-api/parser.js +128 -0
- package/src/lib/parsing/tf2-api/parser.js.map +1 -0
- package/src/lib/parsing/tf2-api/types.d.ts +47 -0
- package/src/lib/parsing/tf2-api/types.js +3 -0
- package/src/lib/parsing/tf2-api/types.js.map +1 -0
- package/src/lib/parsing/tf2-gc/constants.js.map +1 -0
- package/src/lib/parsing/tf2-gc/parser.d.ts +12 -0
- package/src/lib/parsing/tf2-gc/parser.js +277 -0
- package/src/lib/parsing/tf2-gc/parser.js.map +1 -0
- package/src/lib/parsing/tf2-gc/types.d.ts +43 -0
- package/src/lib/parsing/tf2-gc/types.js +3 -0
- package/src/lib/parsing/tf2-gc/types.js.map +1 -0
- package/src/lib/schemas.d.ts +65 -0
- package/src/lib/schemas.js +3 -0
- package/src/lib/schemas.js.map +1 -0
- package/src/lib/types.d.ts +11 -323
- package/src/lib/parsing/tf2/constants.js.map +0 -1
- /package/src/lib/parsing/{tf2 → tf2-gc}/constants.d.ts +0 -0
- /package/src/lib/parsing/{tf2 → tf2-gc}/constants.js +0 -0
|
@@ -1,38 +1,10 @@
|
|
|
1
|
-
import { RecipeInput } from '../../types';
|
|
2
|
-
export interface
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
id: string;
|
|
6
|
-
account_id: number;
|
|
7
|
-
inventory: number;
|
|
8
|
-
def_index: number;
|
|
9
|
-
quantity: number;
|
|
1
|
+
import { RecipeInput, Spell } from '../../types';
|
|
2
|
+
export interface ExtractedTF2Item {
|
|
3
|
+
assetid: string;
|
|
4
|
+
originalId: string | null;
|
|
10
5
|
level: number;
|
|
6
|
+
defindex: number;
|
|
11
7
|
quality: number;
|
|
12
|
-
flags: number;
|
|
13
|
-
origin: number;
|
|
14
|
-
custom_name: string | null;
|
|
15
|
-
custom_desc: string | null;
|
|
16
|
-
interior_item: TF2Item | null;
|
|
17
|
-
in_use: boolean;
|
|
18
|
-
style: number;
|
|
19
|
-
original_id: string | null;
|
|
20
|
-
position: number;
|
|
21
|
-
}
|
|
22
|
-
export interface EquippedState {
|
|
23
|
-
new_class: number;
|
|
24
|
-
new_slot: number;
|
|
25
|
-
}
|
|
26
|
-
export interface Attribute {
|
|
27
|
-
def_index: number;
|
|
28
|
-
value: unknown;
|
|
29
|
-
value_bytes: ValueBytes | Buffer;
|
|
30
|
-
}
|
|
31
|
-
export interface ValueBytes {
|
|
32
|
-
type: 'Buffer';
|
|
33
|
-
data: number[];
|
|
34
|
-
}
|
|
35
|
-
export interface Attributes {
|
|
36
8
|
elevated: boolean;
|
|
37
9
|
australium: boolean;
|
|
38
10
|
festivized: boolean;
|
|
@@ -43,28 +15,17 @@ export interface Attributes {
|
|
|
43
15
|
killstreak: number;
|
|
44
16
|
sheen: number | null;
|
|
45
17
|
killstreaker: number | null;
|
|
46
|
-
|
|
47
|
-
* Either the defindex of the spell, or an array with the defindex and value
|
|
48
|
-
* of the attribute.
|
|
49
|
-
*/
|
|
50
|
-
spells: (number | [number, number])[];
|
|
18
|
+
spells: Spell[];
|
|
51
19
|
parts: number[];
|
|
52
20
|
paintkit: number | null;
|
|
21
|
+
quantity: number;
|
|
53
22
|
inputs: RecipeInput[] | null;
|
|
54
23
|
output: number | null;
|
|
55
24
|
outputQuality: number | null;
|
|
56
25
|
target: number | null;
|
|
26
|
+
crateSeries: number | null;
|
|
57
27
|
}
|
|
58
|
-
|
|
59
|
-
* The result of extracting information from an TF2Item
|
|
60
|
-
*/
|
|
61
|
-
export interface ExtractedTF2Item {
|
|
62
|
-
assetid: string;
|
|
63
|
-
originalId: string | null;
|
|
64
|
-
level: number;
|
|
65
|
-
defindex: number;
|
|
66
|
-
quality: number;
|
|
67
|
-
elevated: boolean;
|
|
28
|
+
export interface Attributes {
|
|
68
29
|
australium: boolean;
|
|
69
30
|
festivized: boolean;
|
|
70
31
|
effect: number | null;
|
|
@@ -74,22 +35,14 @@ export interface ExtractedTF2Item {
|
|
|
74
35
|
killstreak: number;
|
|
75
36
|
sheen: number | null;
|
|
76
37
|
killstreaker: number | null;
|
|
77
|
-
|
|
78
|
-
* Either the defindex of the spell, or an array with the defindex and value
|
|
79
|
-
* of the attribute.
|
|
80
|
-
*/
|
|
81
|
-
spells: (number | [number, number])[];
|
|
38
|
+
spells: Spell[];
|
|
82
39
|
parts: number[];
|
|
83
40
|
paintkit: number | null;
|
|
84
|
-
quantity: number;
|
|
85
41
|
inputs: RecipeInput[] | null;
|
|
86
42
|
output: number | null;
|
|
87
43
|
outputQuality: number | null;
|
|
88
44
|
target: number | null;
|
|
45
|
+
killEater: boolean;
|
|
89
46
|
crateSeries: number | null;
|
|
90
|
-
|
|
91
|
-
export interface Context {
|
|
92
|
-
origin: number;
|
|
93
|
-
flags: number;
|
|
94
|
-
attributes: Set<number>;
|
|
47
|
+
quantity: number | null;
|
|
95
48
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { InventoryItem } from '../../types';
|
|
2
|
+
import { Context, TF2APIItem } from './types';
|
|
3
|
+
import { ExtractedTF2Item } from '../tf2/types';
|
|
4
|
+
import { TF2Parser } from '../tf2/parser';
|
|
5
|
+
export declare class TF2APIParser extends TF2Parser<TF2APIItem> {
|
|
6
|
+
private extractAttributes;
|
|
7
|
+
extract(raw: TF2APIItem): [ExtractedTF2Item, Context];
|
|
8
|
+
parse(extracted: ExtractedTF2Item, context: Context): Promise<InventoryItem>;
|
|
9
|
+
}
|
|
10
|
+
export { TF2APIItem, ExtractedTF2APIItem } from './types';
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TF2APIParser = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const parser_1 = require("../tf2/parser");
|
|
6
|
+
class TF2APIParser extends parser_1.TF2Parser {
|
|
7
|
+
extractAttributes(attributes) {
|
|
8
|
+
var _a;
|
|
9
|
+
const result = {};
|
|
10
|
+
if (attributes) {
|
|
11
|
+
const inputs = [];
|
|
12
|
+
for (const attribute of attributes) {
|
|
13
|
+
switch (attribute.defindex) {
|
|
14
|
+
case 2000:
|
|
15
|
+
case 2001:
|
|
16
|
+
case 2002:
|
|
17
|
+
case 2003:
|
|
18
|
+
case 2004:
|
|
19
|
+
case 2005:
|
|
20
|
+
case 2006:
|
|
21
|
+
case 2007:
|
|
22
|
+
case 2008:
|
|
23
|
+
case 2009: {
|
|
24
|
+
const recipeAttributes = this.extractAttributes(attribute.attributes);
|
|
25
|
+
if (attribute.is_output === false) {
|
|
26
|
+
const quantity = (_a = attribute.quantity) !== null && _a !== void 0 ? _a : 1;
|
|
27
|
+
if (quantity < 1) {
|
|
28
|
+
// 0 if it is fulfilled
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const input = {
|
|
32
|
+
quality: 6,
|
|
33
|
+
quantity,
|
|
34
|
+
};
|
|
35
|
+
if (attribute.itemdef) {
|
|
36
|
+
input.defindex = attribute.itemdef;
|
|
37
|
+
}
|
|
38
|
+
if (attribute.quality) {
|
|
39
|
+
input.quality = attribute.quality;
|
|
40
|
+
}
|
|
41
|
+
if (recipeAttributes.killstreak) {
|
|
42
|
+
input.killstreak = recipeAttributes.killstreak;
|
|
43
|
+
}
|
|
44
|
+
inputs.push(input);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
for (const key in recipeAttributes) {
|
|
48
|
+
result[key] = recipeAttributes[key];
|
|
49
|
+
}
|
|
50
|
+
if (attribute.itemdef) {
|
|
51
|
+
result.output = attribute.itemdef;
|
|
52
|
+
}
|
|
53
|
+
if (attribute.quality) {
|
|
54
|
+
result.outputQuality = attribute.quality;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
default: {
|
|
60
|
+
const value = Buffer.allocUnsafe(4);
|
|
61
|
+
if (attribute.float_value !== undefined) {
|
|
62
|
+
value.writeFloatLE(attribute.float_value, 0);
|
|
63
|
+
}
|
|
64
|
+
else if (typeof attribute.value === 'number') {
|
|
65
|
+
value.writeUInt32LE(attribute.value, 0);
|
|
66
|
+
}
|
|
67
|
+
parser_1.TF2Parser.extractSimpleAttribute(attribute.defindex, value, result);
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (inputs.length > 0) {
|
|
73
|
+
result.inputs = inputs;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
extract(raw) {
|
|
79
|
+
const attributes = this.extractAttributes(raw.attributes);
|
|
80
|
+
return [
|
|
81
|
+
this.createExtractedItem(raw, attributes),
|
|
82
|
+
{
|
|
83
|
+
craftable: raw.flag_cannot_craft !== true,
|
|
84
|
+
tradable: raw.flag_cannot_trade !== true,
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
parse(extracted, context) {
|
|
89
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
let paint = null;
|
|
91
|
+
if (extracted.primaryPaint) {
|
|
92
|
+
const hex = extracted.primaryPaint.toString(16);
|
|
93
|
+
if (hex === '1') {
|
|
94
|
+
// Glitched legacy paint
|
|
95
|
+
paint = 5046;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
paint = this.schema.getPaintByColor(hex);
|
|
99
|
+
if (paint === undefined) {
|
|
100
|
+
paint = yield this.schema.fetchPaintByColor(hex);
|
|
101
|
+
}
|
|
102
|
+
else if (paint instanceof Error) {
|
|
103
|
+
throw paint;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const parts = [];
|
|
108
|
+
if (extracted.parts.length > 0) {
|
|
109
|
+
for (let i = 0; i < extracted.parts.length; i++) {
|
|
110
|
+
const part = extracted.parts[i];
|
|
111
|
+
let match = this.schema.getStrangePartById(part);
|
|
112
|
+
if (match instanceof Error) {
|
|
113
|
+
throw match;
|
|
114
|
+
}
|
|
115
|
+
else if (match === undefined) {
|
|
116
|
+
match = yield this.schema.fetchStrangePartById(part);
|
|
117
|
+
}
|
|
118
|
+
if (match !== null) {
|
|
119
|
+
parts.push(match);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return this.createParsedItem(extracted, parts, paint, extracted.crateSeries, extracted.quantity, context.tradable, context.craftable);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.TF2APIParser = TF2APIParser;
|
|
128
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../../../../../libs/tf2-format/src/lib/parsing/tf2-api/parser.ts"],"names":[],"mappings":";;;;AAGA,0CAA0C;AAE1C,MAAa,YAAa,SAAQ,kBAAqB;IAC7C,iBAAiB,CACvB,UAAoC;;QAEpC,MAAM,MAAM,GAAwB,EAAE,CAAC;QAEvC,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,MAAM,GAAkB,EAAE,CAAC;YAEjC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;gBACnC,QAAQ,SAAS,CAAC,QAAQ,EAAE,CAAC;oBAC3B,KAAK,IAAI,CAAC;oBACV,KAAK,IAAI,CAAC;oBACV,KAAK,IAAI,CAAC;oBACV,KAAK,IAAI,CAAC;oBACV,KAAK,IAAI,CAAC;oBACV,KAAK,IAAI,CAAC;oBACV,KAAK,IAAI,CAAC;oBACV,KAAK,IAAI,CAAC;oBACV,KAAK,IAAI,CAAC;oBACV,KAAK,IAAI,CAAC,CAAC,CAAC;wBACV,MAAM,gBAAgB,GAAG,IAAI,CAAC,iBAAiB,CAC7C,SAAS,CAAC,UAAU,CACrB,CAAC;wBAEF,IAAI,SAAS,CAAC,SAAS,KAAK,KAAK,EAAE,CAAC;4BAClC,MAAM,QAAQ,GAAG,MAAA,SAAS,CAAC,QAAQ,mCAAI,CAAC,CAAC;4BACzC,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;gCACjB,uBAAuB;gCACvB,SAAS;4BACX,CAAC;4BAED,MAAM,KAAK,GAAgB;gCACzB,OAAO,EAAE,CAAC;gCACV,QAAQ;6BACT,CAAC;4BAEF,IAAI,SAAS,CAA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AAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;oBAChD,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBAChC,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;oBACjD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;wBAC3B,MAAM,KAAK,CAAC;oBACd,CAAC;yBAAM,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;wBAC/B,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;oBACvD,CAAC;oBAED,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;wBACnB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBACpB,CAAC;gBACH,CAAC;YACH,CAAC;YAED,OAAO,IAAI,CAAC,gBAAgB,CAC1B,SAAS,EACT,KAAK,EACL,KAAK,EACL,SAAS,CAAC,WAAW,EACrB,SAAS,CAAC,QAAQ,EAClB,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,SAAS,CAClB,CAAC;QACJ,CAAC;KAAA;CACF;AAlJD,oCAkJC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ExtractedTF2Item } from '../tf2/types';
|
|
2
|
+
export interface TF2APIItem {
|
|
3
|
+
id: number;
|
|
4
|
+
original_id: number;
|
|
5
|
+
defindex: number;
|
|
6
|
+
level: number;
|
|
7
|
+
quality: number;
|
|
8
|
+
inventory: number;
|
|
9
|
+
quantity: number;
|
|
10
|
+
origin: number;
|
|
11
|
+
flag_cannot_trade?: boolean;
|
|
12
|
+
attributes?: Attribute[];
|
|
13
|
+
equipped?: Equipped[];
|
|
14
|
+
style?: number;
|
|
15
|
+
flag_cannot_craft?: boolean;
|
|
16
|
+
custom_name?: string;
|
|
17
|
+
custom_desc?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface Attribute {
|
|
20
|
+
defindex: number;
|
|
21
|
+
value?: string | number;
|
|
22
|
+
float_value?: number;
|
|
23
|
+
account_info?: AccountInfo;
|
|
24
|
+
is_output?: boolean;
|
|
25
|
+
quantity?: number;
|
|
26
|
+
quality?: number;
|
|
27
|
+
match_all_attribs?: boolean;
|
|
28
|
+
attributes?: Attribute[];
|
|
29
|
+
itemdef?: number;
|
|
30
|
+
}
|
|
31
|
+
export interface AccountInfo {
|
|
32
|
+
steamid: number;
|
|
33
|
+
personaname: string;
|
|
34
|
+
}
|
|
35
|
+
export interface Equipped {
|
|
36
|
+
class: number;
|
|
37
|
+
slot: number;
|
|
38
|
+
}
|
|
39
|
+
export interface ExtractedTF2APIItem extends ExtractedTF2Item {
|
|
40
|
+
originalId: string;
|
|
41
|
+
craftable: boolean;
|
|
42
|
+
tradable: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface Context {
|
|
45
|
+
craftable: boolean;
|
|
46
|
+
tradable: boolean;
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../libs/tf2-format/src/lib/parsing/tf2-api/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../libs/tf2-format/src/lib/parsing/tf2-gc/constants.ts"],"names":[],"mappings":";;;AAAA,IAAY,cAcX;AAdD,WAAY,cAAc;IACxB,6FAAkC,CAAA;IAClC,mHAA6C,CAAA;IAC7C,yHAAgD,CAAA;IAChD,2FAAiC,CAAA;IACjC,4JAAiE,CAAA;IACjE,8GAA0C,CAAA;IAC1C,sGAAsC,CAAA;IACtC,mGAAoC,CAAA;IACpC,oHAI0D,CAAA;AAC5D,CAAC,EAdW,c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C,CAAA;IAClC,yGAAiC,CAAA;IACjC,gFAAkB,CAAA;AACpB,CAAC,EA1BW,mBAAmB,mCAAnB,mBAAmB,QA0B9B;AAED,IAAY,kBAOX;AAPD,WAAY,kBAAkB;IAC5B,qEAAkB,CAAA;IAClB,6EAAsB,CAAA;IACtB,uFAA2B,CAAA;IAC3B,qFAA0B,CAAA;IAC1B,kGAAgC,CAAA;IAChC,kGAAgC,CAAA;AAClC,CAAC,EAPW,kBAAkB,kCAAlB,kBAAkB,QAO7B;AAWY,QAAA,sBAAsB,GAAG;IACpC,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { InventoryItem } from '../../types';
|
|
2
|
+
import { Context, ExtractedTF2GCItem, TF2GCItem } from './types';
|
|
3
|
+
import { TF2Parser } from '../tf2/parser';
|
|
4
|
+
export declare class TF2GCParser extends TF2Parser<TF2GCItem, Context> {
|
|
5
|
+
extract(item: TF2GCItem): [ExtractedTF2GCItem, Context];
|
|
6
|
+
private getAttributes;
|
|
7
|
+
private static isCraftable;
|
|
8
|
+
private static isTradable;
|
|
9
|
+
private static hasAttribute;
|
|
10
|
+
parse(extracted: ExtractedTF2GCItem, context: Context): Promise<InventoryItem>;
|
|
11
|
+
}
|
|
12
|
+
export { ExtractedTF2GCItem, TF2GCItem } from './types';
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TF2GCParser = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
const light_1 = tslib_1.__importDefault(require("protobufjs/light"));
|
|
7
|
+
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
8
|
+
const parser_1 = require("../tf2/parser");
|
|
9
|
+
var AttributeTokens;
|
|
10
|
+
(function (AttributeTokens) {
|
|
11
|
+
AttributeTokens[AttributeTokens["cannot trade"] = 153] = "cannot trade";
|
|
12
|
+
AttributeTokens[AttributeTokens["always tradable"] = 195] = "always tradable";
|
|
13
|
+
AttributeTokens[AttributeTokens["expiration date"] = 302] = "expiration date";
|
|
14
|
+
AttributeTokens[AttributeTokens["never craftable"] = 449] = "never craftable";
|
|
15
|
+
AttributeTokens[AttributeTokens["non economy"] = 777] = "non economy";
|
|
16
|
+
AttributeTokens[AttributeTokens["tool target item"] = 2012] = "tool target item";
|
|
17
|
+
AttributeTokens[AttributeTokens["killstreak effect"] = 2013] = "killstreak effect";
|
|
18
|
+
AttributeTokens[AttributeTokens["killstreak idleeffect"] = 2014] = "killstreak idleeffect";
|
|
19
|
+
AttributeTokens[AttributeTokens["killstreak tier"] = 2025] = "killstreak tier";
|
|
20
|
+
})(AttributeTokens || (AttributeTokens = {}));
|
|
21
|
+
const PROTO = {
|
|
22
|
+
nested: {
|
|
23
|
+
CAttribute_DynamicRecipeComponent: {
|
|
24
|
+
fields: {
|
|
25
|
+
defIndex: { type: 'uint32', id: 1 },
|
|
26
|
+
itemQuality: { type: 'uint32', id: 2 },
|
|
27
|
+
componentFlags: { type: 'uint32', id: 3 },
|
|
28
|
+
attributesString: { type: 'string', id: 4 },
|
|
29
|
+
numRequired: { type: 'uint32', id: 5 },
|
|
30
|
+
numFulfilled: { type: 'uint32', id: 6 },
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
const root = light_1.default.Root.fromJSON(PROTO);
|
|
36
|
+
const recipeComponentType = root.lookupType('CAttribute_DynamicRecipeComponent');
|
|
37
|
+
const ATTRIBUTE_SEPERATOR = '|\x01\x02\x01\x03|\x01\x02\x01\x03|';
|
|
38
|
+
class TF2GCParser extends parser_1.TF2Parser {
|
|
39
|
+
extract(item) {
|
|
40
|
+
const [attributes, defindexes] = this.getAttributes(item);
|
|
41
|
+
return [
|
|
42
|
+
this.createExtractedItem(item, attributes),
|
|
43
|
+
{
|
|
44
|
+
flags: item.flags,
|
|
45
|
+
origin: item.origin,
|
|
46
|
+
attributes: defindexes,
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
getAttributes(item) {
|
|
51
|
+
var _a, _b, _c;
|
|
52
|
+
const result = {};
|
|
53
|
+
const inputs = [];
|
|
54
|
+
const defindexes = new Set();
|
|
55
|
+
for (let i = 0; i < item.attribute.length; i++) {
|
|
56
|
+
const attribute = item.attribute[i];
|
|
57
|
+
defindexes.add(attribute.def_index);
|
|
58
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
59
|
+
const value = Buffer.from(attribute.value_bytes);
|
|
60
|
+
switch (attribute.def_index) {
|
|
61
|
+
case 2000:
|
|
62
|
+
case 2001:
|
|
63
|
+
case 2002:
|
|
64
|
+
case 2003:
|
|
65
|
+
case 2004:
|
|
66
|
+
case 2005:
|
|
67
|
+
case 2006:
|
|
68
|
+
case 2007:
|
|
69
|
+
case 2008:
|
|
70
|
+
case 2009: {
|
|
71
|
+
// Fabricator inputs
|
|
72
|
+
const component = recipeComponentType
|
|
73
|
+
.decode(value)
|
|
74
|
+
.toJSON();
|
|
75
|
+
component.componentFlags = (_a = component.componentFlags) !== null && _a !== void 0 ? _a : 0;
|
|
76
|
+
const attribs = component.attributesString
|
|
77
|
+
? component.attributesString.split(ATTRIBUTE_SEPERATOR)
|
|
78
|
+
: [];
|
|
79
|
+
const attribsMap = {};
|
|
80
|
+
for (let i = 0; i < attribs.length; i += 2) {
|
|
81
|
+
attribsMap[attribs[i]] = parseFloat(attribs[i + 1]);
|
|
82
|
+
}
|
|
83
|
+
const isOutput = component.componentFlags & constants_1.DynamicRecipeFlags.IS_OUTPUT;
|
|
84
|
+
if (!isOutput) {
|
|
85
|
+
const input = {
|
|
86
|
+
quality: 6,
|
|
87
|
+
quantity: ((_b = component.numRequired) !== null && _b !== void 0 ? _b : 0) - ((_c = component.numFulfilled) !== null && _c !== void 0 ? _c : 0),
|
|
88
|
+
};
|
|
89
|
+
if (component.componentFlags & constants_1.DynamicRecipeFlags.PARAM_ITEM_DEF_SET) {
|
|
90
|
+
(0, assert_1.default)(component.defIndex !== undefined, 'defIndex is undefined');
|
|
91
|
+
input.defindex = component.defIndex;
|
|
92
|
+
}
|
|
93
|
+
if (component.componentFlags & constants_1.DynamicRecipeFlags.PARAM_QUALITY_SET) {
|
|
94
|
+
(0, assert_1.default)(component.itemQuality !== undefined, 'itemQuality is undefined');
|
|
95
|
+
input.quality = component.itemQuality;
|
|
96
|
+
}
|
|
97
|
+
if (attribsMap[AttributeTokens['killstreak tier']]) {
|
|
98
|
+
input.killstreak = attribsMap[AttributeTokens['killstreak tier']];
|
|
99
|
+
}
|
|
100
|
+
inputs.push(input);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
if (attribsMap[AttributeTokens['tool target item']]) {
|
|
104
|
+
result.target = attribsMap[AttributeTokens['tool target item']];
|
|
105
|
+
}
|
|
106
|
+
if (attribsMap[AttributeTokens['killstreak idleeffect']]) {
|
|
107
|
+
result.sheen =
|
|
108
|
+
attribsMap[AttributeTokens['killstreak idleeffect']];
|
|
109
|
+
result.killstreak = 2;
|
|
110
|
+
}
|
|
111
|
+
if (attribsMap[AttributeTokens['killstreak effect']]) {
|
|
112
|
+
result.killstreaker =
|
|
113
|
+
attribsMap[AttributeTokens['killstreak effect']];
|
|
114
|
+
result.killstreak = 3;
|
|
115
|
+
}
|
|
116
|
+
(0, assert_1.default)(component.itemQuality !== undefined, 'itemQuality is undefined');
|
|
117
|
+
(0, assert_1.default)(component.defIndex !== undefined, 'defIndex is undefined');
|
|
118
|
+
result.outputQuality = component.itemQuality;
|
|
119
|
+
result.output = component.defIndex;
|
|
120
|
+
}
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
default:
|
|
124
|
+
parser_1.TF2Parser.extractSimpleAttribute(attribute.def_index, value, result);
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const killstreak = constants_1.KILLSTREAK_FABRICATORS[item.def_index];
|
|
129
|
+
if (killstreak) {
|
|
130
|
+
result.killstreak = killstreak;
|
|
131
|
+
}
|
|
132
|
+
if (inputs.length > 0) {
|
|
133
|
+
result.inputs = inputs;
|
|
134
|
+
}
|
|
135
|
+
return [result, defindexes];
|
|
136
|
+
}
|
|
137
|
+
static isCraftable(schemaItem, context) {
|
|
138
|
+
// Always craftable
|
|
139
|
+
if (context.attributes.has(AttributeTokens['always tradable']) ||
|
|
140
|
+
TF2GCParser.hasAttribute('always tradable', schemaItem)) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
// Never craftable
|
|
144
|
+
if (context.attributes.has(AttributeTokens['never craftable']) ||
|
|
145
|
+
TF2GCParser.hasAttribute('never craftable', schemaItem)) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
// Temporary item
|
|
149
|
+
if (context.attributes.has(AttributeTokens['expiration date']) ||
|
|
150
|
+
TF2GCParser.hasAttribute('expiration date', schemaItem)) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
switch (context.origin) {
|
|
154
|
+
case constants_1.eEconItemOrigin.kEconItemOrigin_Invalid:
|
|
155
|
+
case constants_1.eEconItemOrigin.kEconItemOrigin_Foreign:
|
|
156
|
+
case constants_1.eEconItemOrigin.kEconItemOrigin_StorePromotion:
|
|
157
|
+
case constants_1.eEconItemOrigin.kEconItemOrigin_SteamWorkshopContribution:
|
|
158
|
+
return false;
|
|
159
|
+
case constants_1.eEconItemOrigin.kEconItemOrigin_Purchased:
|
|
160
|
+
if ((context.flags &
|
|
161
|
+
constants_1.eEconItemFlags.kEconItemFlag_PurchasedAfterStoreCraftabilityChanges2012) ===
|
|
162
|
+
0) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
if (schemaItem.capabilities &&
|
|
166
|
+
schemaItem.capabilities['can_craft_if_purchased'] === '0') {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
static isTradable(schemaItem, extracted, context) {
|
|
174
|
+
if (context.attributes.has(AttributeTokens['non economy']) ||
|
|
175
|
+
this.hasAttribute('non economy', schemaItem)) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
if (context.attributes.has(AttributeTokens['always tradable']) ||
|
|
179
|
+
this.hasAttribute('always tradable', schemaItem)) {
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
if (context.attributes.has(AttributeTokens['cannot trade']) ||
|
|
183
|
+
this.hasAttribute('cannot trade', schemaItem)) {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
switch (context.origin) {
|
|
187
|
+
case constants_1.eEconItemOrigin.kEconItemOrigin_Invalid:
|
|
188
|
+
case constants_1.eEconItemOrigin.kEconItemOrigin_Achievement:
|
|
189
|
+
case constants_1.eEconItemOrigin.kEconItemOrigin_Foreign:
|
|
190
|
+
case constants_1.eEconItemOrigin.kEconItemOrigin_PreviewItem:
|
|
191
|
+
case constants_1.eEconItemOrigin.kEconItemOrigin_SteamWorkshopContribution:
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
if (context.origin === constants_1.eEconItemOrigin.kEconItemOrigin_PreviewItem) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
if (extracted.quality >= 7 && extracted.quality <= 9) {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
if ((context.flags & constants_1.eEconItemFlags.kEconItemFlag_CannotTrade) !== 0) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
static hasAttribute(attribute, schemaItem) {
|
|
206
|
+
var _a;
|
|
207
|
+
if (schemaItem.attributes &&
|
|
208
|
+
((_a = schemaItem.attributes[attribute]) === null || _a === void 0 ? void 0 : _a.value) === '1') {
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
if (schemaItem.static_attrs && schemaItem.static_attrs[attribute] === '1') {
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
parse(extracted, context) {
|
|
217
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
218
|
+
var _a;
|
|
219
|
+
let schemaItem = this.schema.getItemsGameItemByDefindex(extracted.defindex);
|
|
220
|
+
if (schemaItem === undefined) {
|
|
221
|
+
schemaItem = yield this.schema.fetchItemsGameItemByDefindex(extracted.defindex);
|
|
222
|
+
}
|
|
223
|
+
else if (schemaItem instanceof Error) {
|
|
224
|
+
throw schemaItem;
|
|
225
|
+
}
|
|
226
|
+
let quantity = extracted.quantity;
|
|
227
|
+
if (extracted.quantity !== undefined &&
|
|
228
|
+
schemaItem.attributes &&
|
|
229
|
+
((_a = schemaItem.attributes['unlimited quantity']) === null || _a === void 0 ? void 0 : _a.value) === '1') {
|
|
230
|
+
quantity = -1;
|
|
231
|
+
}
|
|
232
|
+
let crateSeries = extracted.crateSeries;
|
|
233
|
+
// TF2 GC may not provide crate series, so we have to manually retrieve it
|
|
234
|
+
if (crateSeries === null &&
|
|
235
|
+
schemaItem.static_attrs &&
|
|
236
|
+
schemaItem.static_attrs['set supply crate series'] !== undefined) {
|
|
237
|
+
crateSeries = Number(schemaItem.static_attrs['set supply crate series']);
|
|
238
|
+
}
|
|
239
|
+
let paint = null;
|
|
240
|
+
if (extracted.primaryPaint) {
|
|
241
|
+
const hex = extracted.primaryPaint.toString(16);
|
|
242
|
+
if (hex === '1') {
|
|
243
|
+
// Glitched legacy paint
|
|
244
|
+
paint = 5046;
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
paint = this.schema.getPaintByColor(hex);
|
|
248
|
+
if (paint === undefined) {
|
|
249
|
+
paint = yield this.schema.fetchPaintByColor(hex);
|
|
250
|
+
}
|
|
251
|
+
else if (paint instanceof Error) {
|
|
252
|
+
throw paint;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const parts = [];
|
|
257
|
+
if (extracted.parts.length > 0) {
|
|
258
|
+
for (let i = 0; i < extracted.parts.length; i++) {
|
|
259
|
+
const part = extracted.parts[i];
|
|
260
|
+
let match = this.schema.getStrangePartById(part);
|
|
261
|
+
if (match instanceof Error) {
|
|
262
|
+
throw match;
|
|
263
|
+
}
|
|
264
|
+
else if (match === undefined) {
|
|
265
|
+
match = yield this.schema.fetchStrangePartById(part);
|
|
266
|
+
}
|
|
267
|
+
if (match !== null) {
|
|
268
|
+
parts.push(match);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return this.createParsedItem(extracted, parts, paint, crateSeries, quantity, TF2GCParser.isTradable(schemaItem, extracted, context), TF2GCParser.isCraftable(schemaItem, context));
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
exports.TF2GCParser = TF2GCParser;
|
|
277
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../../../../../libs/tf2-format/src/lib/parsing/tf2-gc/parser.ts"],"names":[],"mappings":";;;;AAEA,2CAMqB;AACrB,qEAAwC;AACxC,4DAA4B;AAE5B,0CAA0C;AAE1C,IAAK,eAUJ;AAVD,WAAK,eAAe;IAClB,uEAAoB,CAAA;IACpB,6EAAuB,CAAA;IACvB,6EAAuB,CAAA;IACvB,6EAAuB,CAAA;IACvB,qEAAmB,CAAA;IACnB,gFAAyB,CAAA;IACzB,kFAA0B,CAAA;IAC1B,0FAA8B,CAAA;IAC9B,8EAAwB,CAAA;AAC1B,CAAC,EAVI,eAAe,KAAf,eAAe,QAUnB;AAED,MAAM,KAAK,GAAwB;IACjC,MAAM,EAAE;QACN,iCAAiC,EAAE;YACjC,MAAM,EAAE;gBACN,QAAQ,EAAE,EAA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EACT,KAAK,EACL,KAAK,EACL,WAAW,EACX,QAAQ,EACR,WAAW,CAAC,UAAU,CAAC,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC,EACtD,WAAW,CAAC,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,CAC7C,CAAC;QACJ,CAAC;KAAA;CACF;AA/UD,kCA+UC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ExtractedTF2Item } from '../tf2/types';
|
|
2
|
+
export interface TF2GCItem {
|
|
3
|
+
attribute: Attribute[];
|
|
4
|
+
equipped_state: EquippedState[];
|
|
5
|
+
id: string;
|
|
6
|
+
account_id: number;
|
|
7
|
+
inventory: number;
|
|
8
|
+
def_index: number;
|
|
9
|
+
quantity: number;
|
|
10
|
+
level: number;
|
|
11
|
+
quality: number;
|
|
12
|
+
flags: number;
|
|
13
|
+
origin: number;
|
|
14
|
+
custom_name: string | null;
|
|
15
|
+
custom_desc: string | null;
|
|
16
|
+
interior_item: TF2GCItem | null;
|
|
17
|
+
in_use: boolean;
|
|
18
|
+
style: number;
|
|
19
|
+
original_id: string | null;
|
|
20
|
+
position: number;
|
|
21
|
+
}
|
|
22
|
+
export interface EquippedState {
|
|
23
|
+
new_class: number;
|
|
24
|
+
new_slot: number;
|
|
25
|
+
}
|
|
26
|
+
export interface Attribute {
|
|
27
|
+
def_index: number;
|
|
28
|
+
value: unknown;
|
|
29
|
+
value_bytes: ValueBytes | Buffer;
|
|
30
|
+
}
|
|
31
|
+
export interface ValueBytes {
|
|
32
|
+
type: 'Buffer';
|
|
33
|
+
data: number[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The result of extracting information from an TF2Item
|
|
37
|
+
*/
|
|
38
|
+
export type ExtractedTF2GCItem = ExtractedTF2Item;
|
|
39
|
+
export interface Context {
|
|
40
|
+
origin: number;
|
|
41
|
+
flags: number;
|
|
42
|
+
attributes: Set<number>;
|
|
43
|
+
}
|