MERCADO NEGRO ES

MERCADO NEGRO

A barter party game for phones. Local, free and open source.

“Your word is negotiated. Pacts are kept.”

8–30 playersNo installsNode.js + 1 dependencyMIT + CC BY 4.0

Trailers

The two worlds of the same game, with original music. Press play.

The Black Key Guild (D&D)
Neo Rosario 2087 (cyberpunk)

Trailer music made with Suno (paid plan).

What it is and how to play

A barter game for phones, made for a room full of people shouting offers. One PC runs a tiny server, the TV shows a QR code, and everyone joins from their phone browser over the WiFi. No apps, no accounts.

  1. Join and get your bag

    Scan the QR, type your name, and you get a bag of ingredients (4 + 3 + 2 of three types) and a secret order: forge an artifact that needs ingredients you do not have.

  2. Trade with everyone

    Type another player's 4-letter code. Each side builds an offer and both accept: TRATO HECHO (“deal done”). Any change breaks the acceptances. The swap is atomic on the server, so nobody can cheat the trade itself.

  3. Forge and level up

    With everything in your bag, forge: you earn points (level 1 = 1, level 2 = 2, level 3+ = 3), get reward ingredients and a harder order. Lying about what you hold is allowed.

Gold
Gold
Feathers
Feathers
Copper
Copper
Gems
Gems
Mushrooms
Mushrooms
Silk
Silk
Runes
Runes
Bones
Bones

8 ingredients · 24 artifacts

🔔 The judge opens and closes the market

While it is closed you can join and look at your bag, but not trade or forge. The judge panel opens the market, launches events and runs the game.

🌧️ Rain and 🚢 Ship

Rain gives 1 item to every active player. The ship shows a giant code on the TV for 90 seconds: the first 5 people to type it loot 3 items. Everyone runs to the TV.

🏆 14 Minecraft-style achievements

They pop up on every phone and on the TV. They give no points. Three are social: trade with 5, 10 and 15 different people.

🤝 First deal🍻 Sociable🗝️ Contact network🎉 Soul of the tavern🔨 Blacksmith apprentice🏴‍☠️ Pirate⚡ Fastest in the harbor🐉 Dragon hoard…

Built in a night

Mercado Negro was built in one night for a birthday party: about 30 teens who study game development, a home WiFi and a TV. It was built with Claude Code, and the art was generated with Codex (OpenAI image generation).

The plan was a calm, all-night mode: drops every so often, a running leaderboard, people chatting. In the end about 23 people played and what came out was 20 minutes of pure shouting.

The whole thing was streamed on Twitch.

“It felt like the closing bell on Wall Street.”

Every time a ship showed up on the TV, everyone ran to the screen. It was the best part of the night. Two things came out of it: a very interesting balance problem (below) and a plan for an online version.

Two skins

Same logic, same economy, with their own texts, look, sounds and art. Each skin lives in its own folder and is played on its own.

The Black Key Guild

“Your word is negotiated. Pacts are kept.”

  • Forest green, parchment, wax seals and brass
  • Cinzel + Libre Baskerville type
  • Pacts with two wax seals, “CONFIDENTIAL” orders
  • The ship is a ship; the rain is rain

Folder: dnd/

Espada vorpalHuevo de dragónCorona del rey exiliadoBotas aladasVarita de bolas de fuegoCota de mithril

Neo Rosario 2087

“Your word is your firewall. Deals are kept.”

  • Neon magenta and cyan, scanlines
  • Orbitron + Share Tech Mono type
  • Encrypted contracts, runners and the Black Chip Syndicate
  • The ship is a cargo drone you hack; the rain is a data leak

Folder: cyber/

Katana monofilamentoDron halcónIA rebeldeDeck de hackeoOjo cibernéticoExoesqueleto
Player phone
Player phone
TV screen
TV screen
Player phone
Player phone
TV screen
TV screen
Judge panel: open the market, drops, players
Judge panel: open the market, drops, players

Balance: the snowball

The live game was far more intense than planned, and something no simulation had shown appeared: two players ran away with it. Here is what we found.

70 vs 17forges by the two leaders vs. an average player
14 vs 16trades each side made to get there
29 %of all points went to the top two

The symptom. Two players forged again and again with their own rewards: about 5 forges per trade, against roughly 1 for most others (70 forges with 14 trades, vs 17 forges with 16 trades). They also traded mostly with each other.

The root cause, found by analyzing the saved game. Once a bag holds 6 or more ingredient types, the order generator stopped excluding what you already had, so new orders came out already covered. In simulation, 1 in 3 new orders could be forged instantly, almost all with a single trade.

Ships fed the leaders. Whoever was fastest and closest to the TV looted most of them, and the judge launching extra ships to help everyone else made it worse.

What it was NOT. Trading among the same pair was only 5–6% of trades; forcing partner diversity changed nothing.

How we investigated

A simulator replays a 20-minute game with 23 players and a ship every minute. 30 seeds per variant, about 12 variants tested. Metrics: forges per trade, the top-2 share of points, the Gini coefficient and who loots the ships.

The fix

  1. A new order always lacks at least 2 units (MIN_FALTA = 2). If not, the quantity of the least abundant ingredient goes up.
  2. Whoever looted the previous ship cannot loot the next one.
VariantForgesTradesForges/tradeTop 2 %GiniShip loots top 2 vs median
No fix (as played)2531691.5028.90.4415.7 vs 1.4
Only: orders lack ≥ 21691701.0017.30.2714.5 vs 1.5
Only: no ship twice in a row2401711.4020.30.339.0 vs 3.9
Both fixes (applied)1701681.0115.80.248.9 vs 3.9
Hidden: harder orders for leaders2651681.5832.90.4815.7 vs 1.1
Mild hidden: ship loot 4→2 items by rank2191701.2924.70.3915.9 vs 1.1
Ship loot never fits your own order2151681.2826.00.3915.3 vs 1.7

Simulation of 20 min, 23 players, one ship per minute, average of 30 seeds. Lower “Forges/trade”, “Top 2 %” and “Gini” = more even. “Ship loots” = how many ships the top 2 loot vs. a median player (out of 100).

What we learned

  • With both fixes, the top two go from 29% to 16% of the points and the Gini drops from 0.44 to 0.24. Nobody ends with 0 forges, and the middle of the pack keeps forging about the same (around 7), but with a much smaller gap to the top.
  • The hidden “rubber band” that makes leaders' orders harder backfired (top 2 rises to 33%): harder orders ask for exactly what the market hands out anyway.
  • Mild tweaks to the ship loot help a little, but not as much as fixing the order generator.
  • There is a cost: the market gets slower (253 → 170 forges in 20 min). For long all-night games, MIN_FALTA = 1 is the knob.
  • Moral: the most visible symptom (the ships, the leader pair) was not the cause. Simulate before you tweak.

The simulator ships in the repo: dnd/tools/sim-balance/. Run node run-all.js i5 30.

Download and play

You need Node.js 18 or newer on the PC that will host. Phones only need a browser and the same WiFi.

⬇ Download ZIP

or with git:

git clone https://github.com/m4cgregor/mercado-negro.git
cd mercado-negro/dnd
npm install
npm start
cd mercado-negro/cyber
npm install
npm start
  1. Download the ZIP (or clone the repo) and enter the skin folder you want: dnd or cyber.
  2. Install the dependency and start the server (commands below). The console prints 3 links: players (/), TV (/tv) and judge (/juez?key=…). The judge key is generated on first run into clave-juez.txt, or set it with ADMIN_KEY.
  3. Open /tv on the TV or projector and press “Activar sonido” (browsers require a click before playing audio).
  4. Open the judge link on your phone or another computer.
  5. Players scan the TV's QR code and type their name.
  6. When everyone is in: open the market from the judge panel. Start trading!

Tips

  • Suggested: 8 to 30 players, 20 to 40 minutes. For an intense game, a ship every 1–3 minutes. For an all-night game, automatic drops every 10 minutes.
  • Windows: allow Node through the firewall on private networks and mark the WiFi network as Private.
  • Do not click the Windows terminal: QuickEdit pauses the process and phones freeze. If it happens, press Esc or Enter. Better to minimize it.
  • Change the port with the PORT variable. Do not run both skins on the same port at once.
  • The game autosaves to partida.json; “Nueva partida” in the judge panel resets it.
  • It also works on a guest WiFi, as long as it does not isolate devices from each other. Test with one phone first.

Future: online version

ROADMAP · NOT IMPLEMENTED

Today you need a PC hosting on the same network. The idea is a Jackbox-style party game: rooms with a code, the TV in any browser and nobody hosting. It does not exist yet; this is the plan.

Architecture

Cloudflare Durable Objects or PartyKit: one object per room, WebSockets instead of polling, timers via alarms. The server.js logic (in-memory state, atomic actions) ports almost 1:1. Static assets on Pages/CDN.

Selectable skins

One codebase; the skin (D&D, Cyber, whatever comes next) is chosen when creating the room: texts in JSON, a CSS theme and a batch of art.

Twitch mode

Viewers play: trade by Twitch username, chat votes the next event (🚢 Ship, 🌧️ Rain, 📈 Gold rush, 🚫 Embargo, ⚡ Happy hour, 🎲 Wandering merchant) and the overlay is the TV view. Watch out for stream delay and code sniping.

CTF layer (Cyber)

Designed fake breaches with small rewards, while the real backend stays hardened. People who open DevTools find a game, not a vulnerability.

Estimated phases

  • 0. Validate remotely with the local server behind a tunnel
  • 1. Online MVP: room, code, TV by URL, WebSocket (2–4 days)
  • 2. Unified skins (2–3 days)
  • 3. CTF layer in Cyber (1–2 days)
  • 4. Party-game polish and a short mode
  • 5. Balance for groups of 4–12

Rough cost: on the order of USD 5/month on Cloudflare Workers Paid (the free plan is enough for the MVP).

Read the full plan (ONLINE.md)

Contributions welcome. If you want to build it, port the logic, make a new skin (pirates, western, space…) or test the balance, open an issue or a pull request.

License and credits

Code: MIT

The source code is published under the MIT license. Use it, modify it, share it.

Art: CC BY 4.0

The images and the trailer music (made with Suno) are published under Creative Commons Attribution 4.0. You may reuse them with credit to m4cgregor.

AI-generated art

The illustrations (artifacts, icons, backgrounds) were generated with AI image generation tools (Codex, by OpenAI) from prompts written by the author. Game sounds are synthesized in the browser with WebAudio.

Made with Claude Code

The logic, the interfaces, the simulator and this website were developed with Claude Code, by Anthropic.