Note: Language Context
Please note that this project was written in German as part of my
Ausbildung(German vocational training). Therefore, all variable names, comments, and console outputs (System.out.println) within the source code are in German.
This is a complete, runnable "Choose Your Own Adventure" (CYOA) / Text-Based RPG.
This project is not just a simple story; it is a data-driven game engine. The game's logic (the while loop) is completely separate from the game's content (the story, options, and locations).
All of the game's "rooms," "options," "text," and "connections" are stored in a single String[][] auswahl array. The main method simply acts as an engine that reads this array to run the game.
Each row in the array is a "node" (düğüm) with a specific structure:
{ "Parent_ID", "My_ID", "Option_Text", "Display_Text", "Auto_Transition_ID" (Optional) }
Parent_ID: Which room this option should appear in.My_ID: This room's unique ID.Option_Text: The text shown to the user as a choice (e.g., "Geh in die Wildnis").Display_Text: The story text shown when the user enters this room.
- State Machine: The engine uses an
aktuelleAuswahlvariable to track the player's current "state" (location). - Dynamic Options: The engine dynamically scans the
auswahlarray and only shows the user options whoseParent_IDmatches theaktuelleAuswahl. - Robust Input: It validates user input (
while (!list.contains(benutzerauswahl))) to ensure the user can only pick a valid, available option. - Forced Transitions: The engine supports an (optional) 5th element in the array (
nachsteID). This allows some choices (like "Lauf vor dem Monster davon") to automatically force the player to a new location (like the "Bar") without asking for more input.
To change or expand the entire game, one only needs to edit the auswahl array. The core Java logic does not need to be touched.