|
1 | | - |
2 | | - |
3 | 1 | # CLIsland |
4 | | -Command-line Love-Island game (written in Go) |
| 2 | + |
| 3 | +CLIsland is a command-line, single-player narrative game inspired by Love Island, written in Go. The game features branching dialogue, relationship management, and drama, all through a clean, modular, and testable architecture. |
| 4 | + |
| 5 | +## Features |
| 6 | +- **Clean, Functional Architecture**: Modular, testable, and extensible codebase using domain-driven design principles. |
| 7 | +- **Gameplay Loop**: Narrative-driven, state-machine-based gameplay with choices, relationships, and drama. |
| 8 | +- **Separation of Concerns**: Clear separation between game engine, I/O, state, and scripting. |
| 9 | +- **Testability**: Interfaces and dependency injection for easy unit testing. |
| 10 | +- **DevOps-Friendly**: Linting, formatting, test coverage, and CI setup. |
| 11 | +- **Configurable**: Characters, events, and dialogue trees defined via config files (JSON/YAML). |
| 12 | +- **Command-line UI**: Minimal, testable CLI (TUI support planned). |
| 13 | + |
| 14 | +## Current Status ✅ |
| 15 | +- **Core Architecture**: Complete with domain models, interfaces, and services |
| 16 | +- **Game Engine**: Fully functional with stub implementations |
| 17 | +- **CLI Interface**: Working game loop with character interactions and events |
| 18 | +- **Testing**: Unit tests for core functionality |
| 19 | +- **Build System**: Makefile and CI setup ready |
| 20 | + |
| 21 | +## Getting Started |
| 22 | + |
| 23 | +### Prerequisites |
| 24 | +- Go 1.20+ |
| 25 | +- (Optional) [golangci-lint](https://golangci-lint.run/) |
| 26 | + |
| 27 | +### Quick Start |
| 28 | +```bash |
| 29 | +# Build the game |
| 30 | +make build |
| 31 | + |
| 32 | +# Run the game |
| 33 | +./clisland |
| 34 | +``` |
| 35 | + |
| 36 | +### Running the Game |
| 37 | +```bash |
| 38 | +# Option 1: Build and run |
| 39 | +go build -o clisland ./cmd/main.go |
| 40 | +./clisland |
| 41 | + |
| 42 | +# Option 2: Run directly |
| 43 | +go run ./cmd/main.go |
| 44 | +``` |
| 45 | + |
| 46 | +### Building |
| 47 | +```bash |
| 48 | +# Using make |
| 49 | +make build |
| 50 | + |
| 51 | +# Using go directly |
| 52 | +go build -o clisland ./cmd/main.go |
| 53 | +``` |
| 54 | + |
| 55 | +### Testing |
| 56 | +```bash |
| 57 | +# Run all tests |
| 58 | +go test ./... |
| 59 | + |
| 60 | +# Run specific test package |
| 61 | +go test ./internal/services/ |
| 62 | + |
| 63 | +# Run with coverage |
| 64 | +make coverage |
| 65 | +``` |
| 66 | + |
| 67 | +### Linting & Formatting |
| 68 | +```bash |
| 69 | +# Lint the code |
| 70 | +make lint |
| 71 | + |
| 72 | +# Format the code |
| 73 | +make fmt |
| 74 | +``` |
| 75 | + |
| 76 | +## How to Play |
| 77 | + |
| 78 | +1. **Start the Game**: Run `./clisland` and enter your name |
| 79 | +2. **Main Menu Options**: |
| 80 | + - **Handle Current Event**: Make choices in story events |
| 81 | + - **Interact with Character**: Talk, date, or challenge other contestants |
| 82 | + - **Advance to Next Day**: Progress the story |
| 83 | + - **View Detailed Stats**: Check your relationships and progress |
| 84 | + - **Save Game**: Save your progress |
| 85 | + - **Quit**: Exit the game |
| 86 | + |
| 87 | +3. **Gameplay Elements**: |
| 88 | + - **Events**: Story-driven scenarios with multiple choices |
| 89 | + - **Characters**: 3 initial contestants (Emma, James, Sophie) with unique personalities |
| 90 | + - **Relationships**: Build affection and trust with characters |
| 91 | + - **Stats**: Manage energy, confidence, popularity, and money |
| 92 | + - **Days**: 30-day game cycle with different event types |
| 93 | + |
| 94 | +## Project Structure |
| 95 | +``` |
| 96 | +CLIsland/ |
| 97 | +├── cmd/ |
| 98 | +│ └── main.go # CLI entrypoint and game loop |
| 99 | +├── internal/ |
| 100 | +│ ├── domain/ |
| 101 | +│ │ ├── models.go # Core domain models (Player, Character, Event, etc.) |
| 102 | +│ │ └── interfaces.go # Service interfaces for dependency injection |
| 103 | +│ ├── services/ |
| 104 | +│ │ ├── game_engine.go # Core game logic implementation |
| 105 | +│ │ ├── stub_services.go # Stub implementations for testing |
| 106 | +│ │ └── game_engine_test.go # Unit tests |
| 107 | +│ └── repositories/ |
| 108 | +│ └── memory_repository.go # In-memory data storage |
| 109 | +├── data/ # Game data (names, config, etc.) |
| 110 | +├── utils/ # Utility functions |
| 111 | +├── scripts/ # DevOps and helper scripts |
| 112 | +├── Makefile # Build, test, and lint commands |
| 113 | +├── .golangci.yml # Linting configuration |
| 114 | +└── .github/workflows/ci.yml # CI/CD pipeline |
| 115 | +``` |
| 116 | + |
| 117 | +## Architecture |
| 118 | + |
| 119 | +### Domain Models |
| 120 | +- **Player**: Main character with stats, personality, and relationships |
| 121 | +- **Character**: Other contestants with unique traits and stats |
| 122 | +- **Event**: Story events with choices and effects |
| 123 | +- **Relationship**: Dynamic connections between characters |
| 124 | +- **Effect**: Changes to game state (stats, relationships, etc.) |
| 125 | + |
| 126 | +### Services |
| 127 | +- **GameEngine**: Core game logic and flow control |
| 128 | +- **EventManager**: Event creation and management |
| 129 | +- **CharacterManager**: Character operations |
| 130 | +- **RelationshipManager**: Relationship dynamics and interactions |
| 131 | +- **EffectProcessor**: Applying effects to game state |
| 132 | +- **RequirementChecker**: Validating event/choice requirements |
| 133 | +- **ConfigProvider**: Game configuration and data |
| 134 | + |
| 135 | +### Repositories |
| 136 | +- **MemoryStateRepository**: In-memory game state storage |
| 137 | +- **MemoryEventRepository**: In-memory event storage |
| 138 | +- **MemoryCharacterRepository**: In-memory character storage |
| 139 | + |
| 140 | +## DevOps & CI |
| 141 | +- **CI**: GitHub Actions workflow runs tests, linting, and coverage on every push/PR |
| 142 | +- **Makefile**: Common tasks for build, lint, test, and coverage |
| 143 | +- **Linting**: Uses `golangci-lint` for comprehensive static analysis |
| 144 | +- **Testing**: Unit tests with good coverage of core functionality |
| 145 | + |
| 146 | +## Extending the Game |
| 147 | + |
| 148 | +### Adding New Characters |
| 149 | +Edit `internal/services/stub_services.go` in the `GetCharacterConfigs` method: |
| 150 | +```go |
| 151 | +{ |
| 152 | + ID: "char_4", |
| 153 | + Name: "NewCharacter", |
| 154 | + Age: 25, |
| 155 | + Personality: domain.Personality{ |
| 156 | + Openness: 60.0, |
| 157 | + // ... other traits |
| 158 | + }, |
| 159 | + // ... other properties |
| 160 | +} |
| 161 | +``` |
| 162 | + |
| 163 | +### Adding New Events |
| 164 | +Edit `internal/services/stub_services.go` in the `GetEventConfigs` method: |
| 165 | +```go |
| 166 | +{ |
| 167 | + ID: "event_3", |
| 168 | + Title: "New Event", |
| 169 | + Description: "Description of the new event", |
| 170 | + Type: domain.EventTypeDrama, |
| 171 | + Choices: []domain.Choice{ |
| 172 | + // ... choices with effects |
| 173 | + }, |
| 174 | + IsActive: true, |
| 175 | +} |
| 176 | +``` |
| 177 | + |
| 178 | +### Adding New Effects |
| 179 | +Extend the `EffectProcessor` in `internal/services/stub_services.go`: |
| 180 | +```go |
| 181 | +case domain.EffectTypeNewEffect: |
| 182 | + // Handle new effect type |
| 183 | +``` |
| 184 | + |
| 185 | +## Testing Strategy |
| 186 | +- **Unit Tests**: Test individual services and components |
| 187 | +- **Integration Tests**: Test service interactions |
| 188 | +- **Mock Services**: Use stub implementations for isolated testing |
| 189 | +- **Coverage**: Aim for >80% test coverage |
| 190 | + |
| 191 | +## License |
| 192 | +MIT |
0 commit comments