GithubHelp home page GithubHelp logo

danocmx / node-tf2-item-format Goto Github PK

View Code? Open in Web Editor NEW
22.0 22.0 4.0 3.55 MB

Fully typed battle-tested library that helps you format TF2 items to the community standards.

License: MIT License

JavaScript 79.72% TypeScript 20.28%
sku tf2 tf2-items

node-tf2-item-format's People

Contributors

danocmx avatar dependabot-preview[bot] avatar dependabot[bot] avatar piman51277 avatar prenaissance avatar semantic-release-bot avatar viggojonasson avatar zeusjunior avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-tf2-item-format's Issues

Items with 'The' in name get it removed when parsed.

Demonstration item: The Bitter Taste of Defeat and Lime
Expected response: { name: 'The Bitter Taste of Defeat and Lime', quality: 6 }
Current response: { name: 'Bitter Taste of Defeat and Lime', quality: 6 }

Procedure:

  • get alls item with The from schema
  • make exceptions for it
  • write tests

Parse output defindex and output quality in `parseString`

parseString does not parse output quality and output defindex for killstreak fabricators
name: Specialized Killstreak Atomizer Kit Fabricator
output:

{
  "name": "Specialized Killstreak Kit Fabricator",
  "craftable": true,
  "quality": 6,
  "killstreak": 2,
  "defindex": 20002,
  "target": "Atomizer",
  "targetDefindex": 450
}

Fix semantic release

  • Add tag to latest commit and use automatic semantic release.
  • Get rid of other versions

Add convertables

  • convertable classes that help your transform item to the format you wanted

Inproper defindexes in `parseString`

Non-Craftable Killstreak Eyelander Kit defindex returned: 5726 expected: 6527
Genuine Marxman defindex returned: 816 expected: 837
Any warpaint - you return 9536 - which is generic warpaint, instead of returning the specific warpaint defindex
Cool Candy Coated War Paint (Battle Scarred) defindex returned: 9536 expected: 17258

This is just a diference between your library and autobot library, I'm not 100% sure problem is in your library
Hot Blitzkrieg SMG (Battle Scarred) defindex returned: 203 expected: 15153

[Bug] Incorrect names of items with proper_name property

Bug description

Certain items in Tf2, such as "The Blutsauger", "The Anger", etc. have a "The" prefixed when in Unique form.
When stringifying the SKUs of such items, the "The" is omitted.
Example:

const { stringify, parseSKU } = require("tf2-item-format/static");
console.log(stringify(parseSKU("36;6"))); //returns "Blutsauger", should be "The Blutsauger"

Examples of affected items

This bug currently affects over 1,200 items

Why this matters

Sites such as Backpack.tf respect the "The" prefix, and this module is currently incompatible with their more correct schema system.

Origin of the Bug

This bug originates within a dependency, node-tf2-static-schema. Specifically, the item-names.json file. tf2-item-format blindly trusts this file to resolve SKUs to item names. However, this bug cannot be blamed on tf2-static-schema, as they are providing the correct base name of the item, which is correct in most contexts

Proposed solution

Luckily, the method to find which item names have this prefix is quite simple. Items with the proper_name property set to true within the raw tf2 schema should have the "The" prefix when unique.

However, the name property does not always include the "The" prefix when the prefix is still required. For example, the "The Sun-on-a-Stick" has the name property set to "Sun-on-a-Stick".

In order to keep backwards compatibilty with existing systems, I propose that this fix should be implemented as a separate function, or as an option to the stringify function.

Add overload to `stringify` to accept sku string

Proposal

Add an overload to stringify to directly get the item name from the SKU. In my opinion, this would make the api simpler and it's a common operation (at least for my use case).

Example:

const name = stringify("211;11;australium;kt-3;festive");
console.log(name); // "Strange Festivized Professional Killstreak Australium Medi Gun"

Current usage

const attributes = parseSKU("211;11;australium;kt-3;festive");
const name = stringify(attributes);

If you're happy with that, I can open a PR.

`The` and `proper_name` property on schema to get accurate names

  • Research what proper_name does -> (either it says if name is accurate or if The is supposed to be in name)
    - [ ] Possibly fix static schema item-names.json with this knowledge
    - [ ] Implement this into the current schema implementations
  • Write a quick utility to fix these issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.