DEV Community

David
David

Posted on AI-assisted

Why I split tower-defense campaigns from their mini-challenges

While building a browser tower-defense game, I ran into a design mismatch: the campaign and special challenges look like parts of the same game, but they ask the player to do different things.

The campaign is about placing defenders, choosing upgrades, and surviving waves. One challenge asks you to route trains through two switches before scheduled arrivals. Treating that activity as another tower-defense level would add rail-specific state to systems that do not need to know about it.

Give the challenge its own small model

I keep the campaign engine and challenge rules separate. Each challenge has a type and a small configuration. Its model has three jobs:

  • init creates the starting state.
  • view turns the current state into data the shared interface can render: a forecast, status values, a board, and available actions.
  • act applies one player choice, including the scenario-specific rule and win/loss condition.

The model does not need the DOM, canvas, or browser storage. The challenge page owns input and rendering; the model owns the rules. This gives different challenge types one shared interface without pretending they all have the same board or objective.

One concrete example

In the Steam Junction timetable, switch A can handle every arrival, while switch B can only handle light cargo. Each successful interception puts that switch on cooldown. The arrival forecast is visible before you dispatch, so the puzzle is about planning ahead rather than reacting to hidden information.

This split makes it easier to inspect the important parts: a rule is a small transition over state, and the interface can display the forecast and action choices that transition expects. When I add another challenge, I can change its model and scenario data without threading special cases through tower placement, enemy movement, or combat.

The game has nine campaign modes and a separate set of 25 challenge rule types. Keeping those responsibilities apart matters more than it would in a single-screen prototype.

Disclosure: I built the linked game. AI helped draft and edit this article; the implementation details describe my project. The Steam Junction timetable is playable in the browser here: https://iooigame.net/games/steam-junction/?mode=mission&lang=en&utm_source=devto&utm_medium=social&utm_campaign=hundred_realms_launch

Top comments (0)