How nikita-ynov/projet-red_console-game works
Project type and purpose
• This is a monolithic, console‐based RPG game written in Go.
• There is no client/server split; it’s a single binary that runs in a terminal, handling user input, game state, and rendering text/ASCII art.
File-structure analysis
• src/main.go – entry point and core game loop (invokes menus, handles user input).
• src/structure/structure.go – domain models (Player, Goblin, Inventory, Equipment, Achievement, etc.).
• src/functions/ – “service” layer implementing game mechanics, grouped by feature:
• menu.go → main menu controller
• characterCreation.go, initCharacter.go → character setup
• initGoblin.go, traningFight.go, characterTurn.go → combat handling
• merchant.go → shop interactions
• blacksmith.go → crafting/forging
• equipment.go, DisplayEquipment.go → equipment management
• achievement.go, DisplayAchievement.go → success system
• displayInfo.go → HUD/stats rendering
• takePot.go, takeSkill.go → item/skill usage
• randomWeapon.go, additional helpers
• src/utils/ – cross-cutting helpers (inventory ops, adding/removing stats or coins, death & respawn, exit/pause, success checks).
• src/data/gameData.go – static data definitions (monsters, items, skill parameters).
• src/image/goblinImage.go – ASCII art renderer for goblins.
Key architectural patterns
• Layered modular design:
• Presentation/CLI layer (main.go + displayInfo, DisplayEquipment, DisplayAchievement).
• Controller/Service layer (functions/*).
• Domain/Model layer (structure/* + data/*).
• Utility layer (utils/*).
• In-memory state: all game state lives in Go structs passed around by reference.
Main components
• CLI Interface (User I/O)
• Main Orchestrator (main.go)
• Domain Models (structure package)
• Game Data (data package)
• Services / Feature Modules (functions package, subdivided into CombatService, MerchantService, BlacksmithService, AchievementService, CharacterService, MenuService)
• Utilities (utils package)
• ASCII Art Renderer (image package)
Interactions and data flow
• User → CLI Interface → Main Orchestrator
• Main calls MenuService → depending on choice, delegates to the appropriate service.
• Services read/write Domain Models (player struct, inventory, monsters) and reference static Game Data.
• Services invoke Utility functions for state mutations (add/remove HP, coins, inventory ops, death checks).
• Services (displayInfo, DisplayEquipment, DisplayAchievement) read model state and output to CLI.
• ASCII Art Renderer may be called during combat to show monster art.
Technologies
• Go modules and packages (src/functions, src/utils, src/structure, src/data, src/image)
• In-memory Go structs, no external DB
• Terminal I/O via fmt.Scan, fmt.Print
Essential elements
• Don’t omit the utils layer—it centralizes state mutations.
• That services depend on both domain models and static data.
• Monolithic, in-process architecture: everything lives in the Go binary.
• Keep components coarse enough for clarity but fine enough to show separation of concerns.