{"_id":"@22mah22/calc","name":"@22mah22/calc","dist-tags":{"latest":"0.11.0-champions.0"},"versions":{"0.11.0-champions.0":{"name":"@22mah22/calc","version":"0.11.0-champions.0","publishConfig":{"access":"public"},"main":"dist/index.js","types":"dist/index.d.ts","unpkg":"dist/production.min.js","description":"Pokémon battle calculator","repository":{"type":"git","url":"git+https://github.com/smogon/damage-calc.git"},"contributors":[{"name":"Austin Couturier","email":"austincouturier@icloud.com"}],"license":"MIT","dependencies":{"@types/node":"^18.14.2"},"devDependencies":{"@pkmn/dex":"^0.10.5","@pkmn/eslint-config":"^2.15.0","@types/jest":"^29.5.14","@typescript-eslint/eslint-plugin":"^5.54.0","@typescript-eslint/parser":"^5.54.0","eslint":"^8.35.0","eslint-plugin-jest":"^27.2.1","jest":"^29.4.3","ts-jest":"^29.0.5","typescript":"^4.9.5"},"scripts":{"lint":"eslint --cache src --ext ts","fix":"eslint --fix src --ext ts","compile":"tsc -p .","bundle":"node bundle","build":"npm run compile && npm run bundle","test":"jest","coverage":"jest --coverage","prepare":"npm run build","pretest":"npm run build","posttest":"npm run lint"},"gitHead":"187514b0a89851c31c1ce754773a9a3a83f1344f","bugs":{"url":"https://github.com/smogon/damage-calc/issues"},"homepage":"https://github.com/smogon/damage-calc#readme","_id":"@22mah22/calc@0.11.0-champions.0","_nodeVersion":"12.22.9","_npmVersion":"8.5.1","dist":{"integrity":"sha512-2VflpDe8tirM1UGINXHnjUyuVmKMFcA9I5xhXec5Zr2Pqg2QfGD1a4T1MPzdlsoX4G10jMeROnw55/eP7vLQWg==","shasum":"71b36f3c49e89205d37f03c73a47e7a2fa556aaf","tarball":"https://registry.npmjs.org/@22mah22/calc/-/calc-0.11.0-champions.0.tgz","fileCount":149,"unpackedSize":4503198,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDauxLJYHyXk5lyJU67tyPChjgzvw/YWsYsg6/KnhynyQIhAOTr8zlIec/hB7xQzit3DqrhbvKTKHwvVTYCDRd2BsHG"}]},"_npmUser":{"name":"22mah22","email":"m.hovdar@gmail.com"},"directories":{},"maintainers":[{"name":"22mah22","email":"m.hovdar@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/calc_0.11.0-champions.0_1776426810400_0.6268175770883011"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-17T11:53:30.324Z","0.11.0-champions.0":"2026-04-17T11:53:30.603Z","modified":"2026-04-17T11:53:30.824Z"},"maintainers":[{"name":"22mah22","email":"m.hovdar@gmail.com"}],"description":"Pokémon battle calculator","homepage":"https://github.com/smogon/damage-calc#readme","repository":{"type":"git","url":"git+https://github.com/smogon/damage-calc.git"},"contributors":[{"name":"Austin Couturier","email":"austincouturier@icloud.com"}],"bugs":{"url":"https://github.com/smogon/damage-calc/issues"},"license":"MIT","readme":"# Pokémon Damage Calculator\n\n![Test Status](https://github.com/smogon/damage-calc/workflows/Tests/badge.svg)\n[![npm version](https://img.shields.io/npm/v/@smogon/calc.svg)](https://www.npmjs.com/package/@smogon/calc)&nbsp;\n\nDamage calculator for all generations of Pokémon battling.\n\nIf you are currently looking at [smogon/damage-calc][0] and not\na fork, this is the official repository for the Pokémon Showdown! damage calculator:\nhttps://calc.pokemonshowdown.com.\n\nThis repository houses both the package implementing the core damage formula mechanics in each\ngeneration ([`@smogon/calc`][1]) as well as [logic and markup for the official UI][2].\n\n## `@smogon/calc`\n\nThe `@smogon/calc` package powers the UI, providing a programmatic interface for computing damage\nranges. This subpackage contains code that will run on both the server or browser and can be used\nas a building block for alternative UIs or applications.\n\n### Installation\n\n```sh\n$ npm install @smogon/calc\n```\n\nAlternatively, as [detailed below](#browser), if you are using `@smogon/calc` in the browser and want\na convenient way to get started, simply depend on a transpiled and minified version via [unpkg][5]:\n\n```html\n<script src=\"https://unpkg.com/@smogon/calc/dist/data/production.min.js\"></script>\n<script src=\"https://unpkg.com/@smogon/calc\"></script>\n```\n\n*In this example, the `@smogon/calc/data` code is included as well to fulfill the calc's data\nlayer requirement. Alternatively, a more fully-featured data layer such as [`@pkmn/data`][9] may\nbe used instead, see below.*\n\n### Usage\n\n`@smogon/calc` exports all of the data types required to perform a calculation. The `calculate`\nmethods require:\n\n- a `Generation` that contains information about which damage formula mechanics to apply and where\n  all of the data about the generation can be found.\n- attacker and defender `Pokemon` (note: only relevant attributes are required, everything else\n  should have sensible defaults). The `Pokemon` constructor also requires a `Generation` to provide\n  the Pokémon's data for the generation.\n- the `Move` being used by the attacker (which also requires a `Generation` argument to scope the\n  move data to the particular generation).\n- (optionally) a `Field` object containing information about the state of each `Side`.\n\n`calculate` returns a `Result` object that contains methods for fetching damage rolls, ranges,\ndescriptions, recoil/drain information, etc.\n\n```ts\nimport {calculate, Generations, Pokemon, Move} from '@smogon/calc';\n\nconst gen = Generations.get(5); // alternatively: const gen = 5;\nconst result = calculate(\n  gen,\n  new Pokemon(gen, 'Gengar', {\n    item: 'Choice Specs',\n    nature: 'Timid',\n    evs: {spa: 252},\n    boosts: {spa: 1},\n  }),\n  new Pokemon(gen, 'Chansey', {\n    item: 'Eviolite',\n    nature: 'Calm',\n    evs: {hp: 252, spd: 252},\n  }),\n  new Move(gen, 'Focus Blast')\n);\n```\n\n`@smogon/calc` comes packaged with all of the data required for damage calculation - by default, it\nexposes this via its `Generations` object from `@smogon/calc/data`. As a shortcut, the `Generation`\nargument required by `calculate`, `Pokemon`, `Move` can instead simply be the generation *number*\n(eg. `5`), and it will handle getting that generations `Generation` object behind the scenes from\nthe data layer it ships with.\n\n**The data in `calc/data` must be kept in sync with Pokémon Showdown. If there is an issue with the\ncalc's data, please fix it in the simulator first.** In general, you should probably not be\nmaking manual edits to any of the data files, and in the future, they are likely to be generated\nprogrammatically.\n\nIn some advanced use cases, you may wish to use a different data layer with the calculator. The\n`@smogon/calc/adaptable` entry point can be used with any data layer that implements the calc's\n`Generations` interface. This interface is a subset of [`@pkmn/data`][9]'s `Generations` interface,\nso `@pkmn/data` (which contains all competitively relevant data from Pokémon Showdown) can be used\nwith the adaptable entry point for applications which want to avoid having two separate sets of the\nsame data shipped to users.\n\n```ts\nimport {Dex} from '@pkmn/dex';\nimport {Generations} from '@pkmn/data';\nimport {calculate, Pokemon, Move, Field} from '@smogon/calc/adaptable';\n\nconst gens = new Generations(Dex);\n\nconst gen = gens.get(1);\nconst result = calculate(\n  gen,\n  new Pokemon(gen, 'Gengar'),\n  new Pokemon(gen, 'Vulpix'),\n  new Move(gen, 'Surf'),\n  new Field({defenderSide: {isLightScreen: true}})\n);\n```\n\n### Browser\n\nThe recommended way of using `@smogon/calc` in a web browser is to **configure your bundler**\n([Webpack][6], [Rollup][7], [Parcel][8], etc) to minimize it and package it with the rest of your\napplication. If you do not use a bundler, a convenience `production.min.js` is included in the\npackage. You simply need to depend on `./node_modules/@smogon/calc/production.min.js` in a `script`\ntag (which is what the unpkg shortcut above is doing), after which **`calc` will be\naccessible as a global.** You must also have a `Generations` implementation provided, you can either\ndepend on the calculator's data layer by depending on\n`./node_modules/@smogon/calc/data/production.min.js` (or `@smogon/calc/data` via unpkg), or you can\nuse an alternative data layer such as [`@pkmn/data`][9]. You must load your data layer\n**before** loading the calc:\n\n```html\n<script src=\"./node_modules/@smogon/calc/data/production.min.js\"></script>\n<script src=\"./node_modules/@smogon/calc/production.min.js\"></script>\n```\n\n## UI\n\nThe [UI layer][2] is currently is written in vanilla JavaScript and HTML. To view the UI locally you\nfirst must install dependencies by running `npm install` at the top level and without `calc/`. This\nshould create a `node_modules/` folder under both the root directory and under `calc/`:\n\n```sh\n$ npm install\n$ cd calc && npm install\n```\n\nNext, run `node build` from the root directory of your clone of this repository. This should\nrun `npm run compile` in the `calc/` subdirectory to compile the `@smogon/calc` package from\nTypeScript to JavaScript that can be run in the browser, and then compile the 'templated' HTML\nand copy everything into the top-level `dist/` folder. To then view the UI, open `dist/index.html` -\nsimply double-clicking on the file from your operating system's file manager UI should open it in\nyour default browser.\n\n```sh\n$ node build\n$ open dist/index.html # open works on macOS, simply double-clicking the file on Windows/macOS works\n```\n\n**If you make changes to anything in `calc/`, you must run `node build` from the top level to\ncompile the files and copy them into `dist/` again. If you make changes to the HTML or JavaScript in\n`src/`you must run `node build view` before the changes will become visible in your browser**\n(`node build` also works, but it is slower, as it will compile `calc/` as well, which is\nunnecessary if you did not make any changes to that directory).\n\nBefore opening up a Pull Request, please ensure `npm test` passes:\n\n```sh\n$ npm test\n```\n\n### Import\n\nThis repository also houses an internal package under `import/` which is used for populating the\nPokémon sets data (as well as data about random battle options) used by the UI. Before making\nchanges here you must run `npm install` from under the `import/` directory to install its\ndependencies as they are not installed by default. [`TASKS.md`][4] contains more information on\nhow to programmatically update sets.\n\n## Credits\n\nThis project was created by Honko and is primarily maintained by Austin and jetou.\n\n- Gens 1-6 were originally implemented by Honko.\n- The Omega Ruby / Alpha Sapphire update was done by gamut-was-taken and Austin.\n- The Gen 7 update was done by Austin.\n- The Gen 8 update was done by Austin and Kris.\n- The Gen 9 update was done by Austin and Kris.\n- Some CSS styling was contributed by Zarel to match the Pokémon Showdown! theme.\n\nMany other contributors have added features or contributed bug fixes, please see the\n[full list of contributors](https://github.com/smogon/damage-calc/graphs/contributors).\n\n## License\n\nThis package is distributed under the terms of the [MIT License][3].\n\n  [0]: https://github.com/smogon/damage-calc\n  [1]: https://github.com/smogon/damage-calc/tree/master/calc\n  [2]: https://github.com/smogon/damage-calc/tree/master/src\n  [3]: https://github.com/smogon/damage-calc/blob/master/LICENSE\n  [4]: https://github.com/smogon/damage-calc/blob/master/TASKS.md\n  [5]: https://unpkg.com/\n  [6]: https://webpack.js.org/\n  [7]: https://rollupjs.org/\n  [8]: https://parceljs.org/\n  [9]: https://github.com/pkmn/ps/blob/master/data\n","readmeFilename":"README.md","_rev":"1-b9cd1617e2ef9dacdb6d67b22584fc5a"}