Rosencode Father & Son Repository
This is just a simple example, but it gives you an idea of how a basic game engine could work. The game loop is controlled by the play method of the Game class, which calls the display_status, get_input, and update_game_state methods in a loop. The display_status method prints out the current status of the player, enemies, and items, the get_input method gets input from the player and processes the command, and the update_game_state method updates the game state based on player actions.
Each class such as Player, Enemy, and Item has a set of properties and methods that define their behavior in the game. The player can attack enemies, pick up items, and run away, enemies can attack the player, and items have a name.
This is just a simple example, and you would need to add much more functionality to make a full game. However, it should give you a good starting point for building your own text-based RPG game engine.