@mann-conomy/tf-war-paints
Version:
A static Node.js wrapper for Team Fortress 2's many War Paints.
90 lines (64 loc) • 3.02 kB
Markdown
# tf-war-paints
A static Node.js wrapper for Team Fortress 2's many War Paints.
[](https://npmjs.com/package/@mann-conomy/tf-war-paints)
[](https://npmjs.com/package/@mann-conomy/tf-war-paints)
[](https://nodejs.org/en/about/releases/)
[](https://github.com/Mann-Conomy/tf-war-paints/blob/main/.github/workflows/test.yml)
[](https://github.com/Mann-Conomy/tf-war-paints/blob/main/LICENSE)
## Installation
Using [npm](https://www.npmjs.com/package/@mann-conomy/tf-war-paints):
```bash
$ npm install @mann-conomy/tf-war-paints
```
Using [yarn](https://yarnpkg.com/package/@mann-conomy/tf-war-paints):
```bash
$ yarn add @mann-conomy/tf-war-paints
```
## Testing
Using [npm](https://docs.npmjs.com/cli/v8/commands/npm-run-script):
```bash
$ npm test
```
Using [yarn](https://classic.yarnpkg.com/lang/en/docs/cli/run/):
```bash
$ yarn test
```
## Examples
Creating and evaluating War Paints from the Team Fortress 2 game files.
```js
import { WarPaint } from "@mann-conomy/tf-war-paints";
try {
// Create a new War Paint to represent Health and Hell
const paint = new WarPaint({ name: "Health and Hell" });
// Evaluate the War Paint based on the provided name
if (paint.eval()) {
// Retrieve the War Paint's id and name
const { id, name } = paint.find();
console.log(id, name); // 406, Health and Hell
}
} catch (error) {
console.error("Error processing War Paint", error.message);
}
```
Want to keep things simple without class instantiation? Opt for the static functions instead!
```js
import { WarPaint } from "@mann-conomy/tf-war-paints";
try {
// Create a new War Paint to represent Health and Hell Green
const paint = { id: 407 };
// Evaluate the War Paint based on the provided id
if (WarPaint.eval(paint)) {
// Retrieve the War Paint's id and name
const { id, name } = WarPaint.find(paint);
console.log(id, name); // 407, Health and Hell Green
}
} catch (error) {
console.error("Error processing War Paint", error.message);
}
```
Some more examples are available in the [examples](https://github.com/Mann-Conomy/tf-war-paints/tree/main/examples) and [test](https://github.com/Mann-Conomy/tf-war-paints/tree/main/test) directories.
## Documentation
See the [Wiki pages](https://github.com/Mann-Conomy/tf-war-paints/wiki) for further documentation.
## License
[MIT](LICENSE)
Copyright 2025, The Mann-Conomy Project