Help us measure site usage?

With your permission, we use self-hosted analytics to understand page usage. It is optional and does not affect the Service. Learn more.

C#beginnercliAI generated

Text Adventure Game Engine (JSON Rooms)

Build a text adventure game engine in C# where the whole adventure, its rooms, exits, items and puzzles, is written in JSON files, so anyone can create a new adventure without touching the code. The player types commands such as go north, look, take key, use key on door and inventory, explores the world and solves puzzles to reach the end. The engine checks the adventure file for mistakes before starting, and you'll write a small sample adventure to show everything it can do. It's a great first C# project: you'll learn classes and collections, reading JSON with System.Text.Json, splitting user input into commands, game state, and testing.

Estimate
~9h
Steps
6
Completed by
0
Proposed by
codeseed.app

System.Text.Json

Project roadmap

  1. 01

    Design the adventure format

    ~1h

    Write README.md with the JSON format: the title, start room, winning room, and rooms (id, name, description, exits as a direction-to-room map, and items), items (id, name, description and whether they can be picked up), and locked exits (which item unlocks them and the message shown). Include a tiny example adventure. Create a project with dotnet new console. Done when: README.md fully describes the format with an example.

  2. 02

    Load the adventure

    ~1.5h

    Create C# classes matching the JSON and load the file with JsonSerializer.Deserialize, with case-insensitive property names. Build a Dictionary of rooms by id. Check the adventure: the start and winning rooms exist, every exit leads to a real room, item ids are unique, and every key item exists. List all problems and stop if there are any. Done when: a correct file loads, and a file with a broken exit reports it.

  3. 03

    Parse commands

    ~1.5h

    Write a parser that lowercases the input, splits it into words, drops filler words (the and a), recognizes verbs and synonyms (go and walk, take and get, and n, s, e and w as directions), and returns a command with its objects. Unknown commands get a helpful message listing what's possible. Done when: go north, n and walk north all give the same command.

  4. 04

    Add items and puzzles

    ~2h

    Implement the game actions: moving (blocked by locked exits with their message), look, examine item, take and drop, inventory, and use item on exit, which unlocks it when it's the right key. Reaching the winning room ends the game with the number of moves. Done when: a player can pick up a key, unlock a door and win.

  5. 05

    Write a sample adventure

    ~1.5h

    Write a sample adventure with at least 8 rooms, 5 items and 2 puzzles that together use every feature of the engine, and play it from start to finish. Add a way to choose the adventure file from the command line. Done when: the sample adventure can be completed, and another file can be loaded with an argument.

  6. 06

    Test it

    ~1.5h

    Write xUnit tests: loading and validating (a good file and several broken ones), parsing commands, and playing a scripted sequence of commands through the game logic, checking the room, inventory and win condition along the way. Done when: dotnet test passes.

Ready to build this?

Get a GitHub repo and start building. Your AI reviewer checks each step as you go.

~9h · 6 steps

Tech stack

System.Text.Json