Skip to content

doshidak/showdex-calc

 
 

Repository files navigation

 Currently v1.2.5   Powering showdex · v1.2.5   Patches @smogon/calc · v0.10.060ee461 

Showdex's fork of the @smogon/calc package, sometimes referred to as the "underlying damage calculator." This is the modified source of the aforementioned package that's patched in & bundled with official releases of Showdex.

If you're looking for Showdex's source code, this isn't it (try here instead!). You're looking at a supporting package that supplies all the damage calculations that Showdex displays to you. But if you're looking for a sign, here's a pointer: int* ✧゚・: *ヽ(◕ヮ◕ヽ)



Developer Zone

Caution

You are about to get in the zone, the developer zone.
If you do not wish to get in the zone, the developer zone, please visit this zone instead.

Developer SparkNotes™

Sooo... what's different?

Mainly:

  • Disabled web client.
    • Web client build scripts have been bypassed in the postinstall script.
    • For our purposes, we're only interested in the MEAT inside the calc directory ( ͡° ͜ʖ ͡°)
  • yarn Classic in lieu of npm, similar to Showdex.

More specifically:

Many of these modifications were made to account for real-time battle conditions that don't apply to the original web-based version. Hence, I'm not intending on pushing any of them to the master smogon/damage-calc repo (also would seriously break the good 'ol Damage Calculator we know & love!).

Requirements

  • node LTS Hydrogen v18
  • yarn Classic v1.22.0+
  • bash (Windows WSL, macOS, or Linux)

①  Installation

Caution

Without any additional package configuration (that I'm too lazy to do rn), attempting to install this from a package manager (e.g., yarn add doshidak/showdex-calc) will fail! You must install this custom fork into your local copy of Showdex using the cumbersome method detailed below. Sorry :c

Important

I'm assuming you've already cloned doshidak/showdex.git (i.e., Showdex's source code), which exists under showdex in your favorite directory.

  1. cd into your favorite directory.
  2. git clone git@github.com:doshidak/showdex-calc.git
  3. cd showdex-calc
  4. yarn
  5. cd ../showdex
  6. rm -r node_modules/@smogon/calc/dist node_modules/@smogon/calc/src
  7. cp -r ../showdex-calc/calc/dist ../showdex-calc/calc/src node_modules/@smogon/calc
  8. yarn patch-package @smogon/calc
  9. yarn
  10. yarn dev:re
  11. ???
  12. Profit!

Tip

Creating the Patchfile in step 8 is completely optional if you just want to quickly test some changes.

Note

Technically, copying the showdex-calc/calc/dist/src directory into node_modules/@smogon/calc has no effect (uses the files in dist instead) & is completely optional, but I do it anyway so you can peep the source code. Fun fact: You can look through your local Showdex's node_modules/@smogon/calc/src right now to see the source code you see here!

Tip

Showdex's yarn dev[:chrome|:firefox]:re script is an alias of its yarn cache:purge && yarn dev[:chrome|:firefox] scripts (also yarn dev itself is an alias of yarn dev:chrome). Running yarn cache:purge is necessary if you've changed anything inside node_modules (including the @smogon/calc package!) after running yarn dev since the stale changes will still persist in (& be loaded from) node_modules/.cache/babel.

wait, you mean you do this every time for every Showdex release ???

  • yessir
  • all natty
    • no git
    • no ci
    • raw dawg
  • basically took a year to set this up cause I'm lazy
    • probably would've taken at least two had someone not asked me for this LOL

Credits

big thank to:

  • honk honk
  • austin, tx
  • kris kringle
  • smog squad
  • git clone

yee

\ (•◡•) /

Languages

  • TypeScript 56.0%
  • HTML 28.2%
  • JavaScript 14.8%
  • Other 1.0%