Dev.to WebDev πŸ›  Dev πŸ‘ 0 πŸ“– 2 min read

Modeling 18 Single Types and 162 Dual-Type Combinations in the Browser: Engineering a Fast Pokemon Team Builder

Most competitive game planners fail on mobile for a boring reason: they treat a tiny, static lookup problem like a heavy database app. Every search keystroke hits an API, large sprite sheets choke the viewport, and savin

Most competitive game planners fail on mobile for a boring reason: they treat a tiny, static lookup problem like a heavy database app. Every search keystroke hits an API, large sprite sheets choke the viewport, and saving a six-slot roster somehow requires creating an account.

When building PokeTeam's browser-based Pokemon Team Builder, we took the opposite constraint: zero backend calls at runtime, zero accounts, zero official sprite assets, and instant recalculation of both defensive weaknesses and offensive coverage on every edit.

1. Compiling PokeAPI Down to a Compact Build-Time Snapshot

The entire competitive metadata needed for type analysisβ€”1,279 Pokemon and regional/battle forms plus 865 movesβ€”is small once you drop flavor text, sprites, and redundant fields. At build time, we pull only names, type pairs, and move damage categories from the open PokeAPI dataset and compile them into a static client bundle.

Because the 18Γ—18 type effectiveness chart is a constant lookup matrix of multipliers (0, 0.5, 1, 2), every defensive and offensive calculation runs synchronously in microseconds in the browser:

  • Per-member defense: Multiply the attacking type's effectiveness against slot type 1 and (if dual-typed) slot type 2, producing exact multipliers (0Γ—, ΒΌΓ—, Β½Γ—, 1Γ—, 2Γ—, 4Γ—).
  • Stacked weakness detection: Aggregate each attacking row across all six team slots. Whenever three or more members take super-effective damage (β‰₯ 2Γ—) from the same attacking type, highlight that row as a stacked weaknessβ€”a signal players can spot at a glance without reading 108 individual cells.

2. Why Single-Type Coverage Lies (and Why 162 Dual Types Matter)

A classic trap in naive coverage calculators is checking a four-move set only against the 18 single defending types. Consider Electric + Ice (the classic BoltBeam pair):

  • Against the 18 single types, Electric + Ice hits 5 types super-effectively and the remaining 13 neutrallyβ€”zero single-type gaps.
  • Against real Pokemon dual-type combinations, however, several combinations resist both Electric and Ice simultaneously (for example, Electric/Steel or Fire/Ice pairings depending on exact multipliers).

Out of the 171 theoretical unordered pairs of 18 types, 162 distinct type combinations actually exist on real Pokemon. By pre-indexing those 162 real defending combinations and computing max(effectiveness(attackType, combo)) across up to four selected attack types, the Type Coverage Calculator immediately surfaces every dual-type wall along with real example Pokemon that carry that typing.

3. Lossless Showdown Text Import/Export Without a Server

Players already live in Pokemon Showdown's plain-text export format. Parsing and serializing that format purely on the client keeps user rosters private and eliminates latency:

  1. Split incoming blocks on blank lines into up to six slot records.
  2. Parse the header line for species/form name (stripping optional nicknames, gender tags, and held items cleanly).
  3. Extract up to four - Move Name lines, normalizing against the bundled 865-move dictionary so coverage updates immediately on paste.
  4. Persist optional user saves directly to localStorage (poketeam:team:v1) so nothing is ever uploaded to a server.

Takeaway

For domain tools built on well-defined rule matricesβ€”whether battle calculators, calendar engines, or classroom drillsβ€”moving the compiled dataset and rule evaluation entirely into the browser turns a slow SaaS form into an instant, offline-friendly utility that works just as smoothly on a phone as on a desktop.

πŸ“° Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.