๐Ÿ’ก Inspiration

The core of Reddit is conversation, but gamification on the platform has always required leaving the app. I wanted to bring the high-stakes tension of a Battle Royale directly into the comment section, native to the Reddit experience. "Karma Combat" was born from the idea of asynchronous multiplayer gamingโ€”where users don't need to be online at the same time to compete, making it perfect for the "Daily" theme.

โš”๏ธ What it does

Karma Combat is a text-based survival game that lives in a dedicated subreddit.

  1. The Arena: Every 24 hours, the System (Bot) posts a new "Daily War Room" thread.
  2. The Moves: Players join by commenting commands like !attack @username, !defend, or !scout.
  3. The Simulation: At the end of the day, the engine processes all valid moves, calculates RNG (Random Number Generation) based on karma/stats, and posts a dramatic "Battle Log" summary.
  4. The Shrink: The "Zone" shrinks every day, eliminating inactive players or those with low health. Last survivor wins the "Karma King" flair.

โš™๏ธ How I built it

I utilized the Reddit Developer Platform (Devvit) to build a completely serverless architecture.

  • Language: Written in TypeScript for type safety and clean logic.
  • State Management: I used context.redis (Redis) to store player stats (Health, AP, Inventory) and game state (Day #, Living Players).
  • Concurrency: To handle multiple users commenting simultaneously, I implemented atomic transactions to ensure no "double attacks" or race conditions occur.
  • Scheduler: Used Devvit's scheduled triggers to automate the "Midnight Purge" (when the day ends and results are calculated) without me needing to run a script manually.

๐Ÿง  Challenges I faced

  • State Persistence: Storing complex player objects in a key-value store (Redis) required efficient serialization/deserialization logic to keep latency low.
  • Input Sanitization: Parsing Reddit comments is messy. I had to write a robust regex parser to distinguish between valid commands (e.g., !attack) and random chatter.
  • Rate Limiting: Preventing bot spam from ruining the game balance required implementing a "cooldown" system logic within the game loop.

๐Ÿš€ What's next for Karma Combat

  • Classes: Adding RPG elements like "Mage" or "Tank" classes that give bonuses to specific commands.
  • Economy: A shop system where users can spend "Karma Coins" (earned by surviving) to buy shields or buffs for the next round.

Built With

Share this project:

Updates