Giter VIP home page Giter VIP logo

dmg's Introduction

dmg

Damage Calculator library and CLI (dmg) for Pokémon cartridge battles spanning every generation. Based on the engine powering the Pokémon Showdown damage calculator.

Install

$ npm install @pkmn.cc/dmg

CLI

$ dmg +1 252 SpA Gengar @ Choice Specs [Focus Blast] vs. 0 HP / 172+ SpD Blissey --gen=4
+1 252 SpA Choice Specs Gengar Focus Blast vs. 0 HP / 172+ SpD Blissey: 362-428 (55.6 - 65.7%) -- guaranteed 2HKO after Leftovers recovery
$ dmg gengar [focus blast] vs. blissey gen:6
252 SpA Life Orb Gengar Focus Blast vs. 252 HP / 4 SpD Blissey: 263-309 (36.8 - 43.2%) -- 98.7% chance to 3HKO after Leftovers recovery
$ dmg gen=3 mence @ CB [EQ] vs. cune @ lefties
252+ Atk Choice Band Salamence Earthquake vs. 252 HP / 252+ Def Suicune: 121-143 (29.9 - 35.3%) -- guaranteed 4HKO after Leftovers recovery

Format

The command line dmg tool is able to parse basic descriptions / phrases as input in addition to flags. The specification for the phrases it understands is similar to the output description, with items and moves requiring a slight modification in their place in order to make parsing easier:

<ATTACKER_BOOST>? <ATTACKER_EVS>? <ATTACKER_POKEMON> (@ <ATTACKER_ITEM>)? ([<ATTACKER_MOVE>])? vs.
<DEFENDER_BOOST>? <DEFENDER_EVS>? <DEFENDER_POKEMON> (@ <DEFENDER_ITEM>)?

where:

  • ATTACKER_BOOST: optional, can range from -6 to +6 and boosts the stat used for attacking.
  • ATTACKER_EVS: optional, can range from 0-252 and can only be 'Atk' or 'SpA' EVs (not case-sensitive). A '+' or '-' may be included after the number of EVs to indicate nature.
  • ATTACKER_POKEMON: required, the name of the attacking Pokémon species/forme.
  • ATTACKER_ITEM: optional, must come after a '@', the held item of the attacker.
  • ATTACKER_MOVE: optional, must be enclosed in square brackets, the attacking move.
  • DEFENDER_BOOST: optional, can range from -6 to +6 and boosts the stat used to defend against the attack.
  • DEFENDER_EVS: optional, can range from 0-252 and can of the form '<N> HP', '<N> HP / <N> Def' or '<N> HP / <N> SpD' (not case-sensitive). A '+' or '-' may be included after the number of Def or SpD EVs to indicate nature.
  • DEFENDER_POKEMON: required, the name of the defending Pokémon species/forme.

Flags have a fairly flexible format: any instance of 'key:value' or 'key=value' (where the key can optionally be prefixed with '-' or '--', i.e. '-key=value' or '--key:value', etc) gets interpreted as a flag. Flags used to set properties of the attacker have keys beginning with 'attacker', those for the defender must begin with 'defender'. The field ('spikes', 'weather', etc) and other properties ('isCrit', 'useZ', etc) may be set without any prefix, but the 'is' on boolean properties is optional (i.e. '--isSR=true' and 'sr=true' both set Stealth Rock on the defender's side).

Flags may appear anywhere within the input to the CLI (even inside the phrase), the following is functionally equivalent to the first example above:

$ dmg +1 --attackerItem='Choice Specs' Gengar [Focus Blast] vs. 0 HP / 172+ SpD Blissey attackerSpAEVs=252 --gen=4

Unless explicitly specified, the attacker and defender's abilities, items and spreads (IVs/EVs//natures) will default to the most common sets for the Pokémon used in competitive play (i.e. this is why Blissey is assumed to have Leftovers in the output above).

Library

const dmg = require('@pkmn.cc/dmg');
let result = dmg.calc(gen, attacker, defender, move, field);
console.log(result.desc);

Credits

Based on honko-damagecalc by Honko, gamut-was-taken, Austin, Zarel et al.

dmg's People

Contributors

scheibo avatar

Watchers

 avatar

Forkers

austinxii

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.