← back to the pad

MTG Proxy Price Optimizer

Chrome extension — buy it or proxy it, whichever is cheaper

TypeScriptReactWebpackJestChrome MV3

Built
July 2024
Status
Working — loads unpacked
Stack
TypeScript, React, Webpack, Jest, Chrome Manifest V3
Code
github.com/fudgemasterultra/mtg-proxy

Problem

Building a Magic deck you can actually afford means going card by card and deciding which ones to buy real and which to print as proxies. For a hundred-card list that is a hundred small decisions, and doing it by hand is exactly as fun as it sounds.

It is also harder than it looks, because proxy printing is priced in bulk tiers — order more, pay less per card. So whether a given card is worth proxying depends on how many other cards you’re proxying, which changes the per-card price, which changes whether those other cards were worth proxying. The decision loops back on itself.

Solution

The extension reads the decklist straight off the page and then settles the circular part by iterating until it stops changing.

Worth noting

Settling to a fixed point rather than computing a formula is what makes this correct. Removing cards from the proxy order can only ever raise the per-card price, never lower it, so each pass moves in one direction and the loop is guaranteed to stop — it can’t oscillate between two answers.

The pricing logic is a pure function taking a decklist and returning two arrays, which meant the interesting half could be unit tested without a browser anywhere near it.