Skip to content

Commit b114f3b

Browse files
committed
MAIN-001: feat: init
1 parent adfd231 commit b114f3b

13 files changed

Lines changed: 2338 additions & 38 deletions

File tree

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ MAIN-001 ]
6+
pull_request:
7+
branches: [ MAIN-001 ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Set up Go
15+
uses: actions/setup-go@v4
16+
with:
17+
go-version: '1.20'
18+
- name: Install golangci-lint
19+
run: |
20+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2
21+
- name: Lint
22+
run: golangci-lint run
23+
- name: Build
24+
run: go build -v ./cmd/main.go
25+
- name: Test
26+
run: go test -v ./...
27+
- name: Coverage
28+
run: |
29+
go test -coverprofile=coverage.out ./...
30+
go tool cover -func=coverage.out

.golangci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
run:
2+
timeout: 3m
3+
tests: true
4+
5+
linters:
6+
enable:
7+
- govet
8+
- errcheck
9+
- staticcheck
10+
- gosimple
11+
- unused
12+
- structcheck
13+
- deadcode
14+
- ineffassign
15+
- typecheck
16+
- varcheck
17+
- gofmt
18+
- goimports
19+
- misspell
20+
- gocritic
21+
- revive
22+
- depguard
23+
- dupl
24+
- gocyclo
25+
- nakedret
26+
- unparam
27+
- whitespace
28+
29+
issues:
30+
exclude-use-default: false
31+
max-issues-per-linter: 0
32+
max-same-issues: 0
33+
34+
output:
35+
format: colored-line

Makefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Makefile for CLIsland
2+
3+
BINARY=clisland
4+
PKG=./...
5+
6+
.PHONY: all build run test lint fmt coverage
7+
8+
all: build
9+
10+
build:
11+
go build -o $(BINARY) ./cmd/main.go
12+
13+
run:
14+
go run ./cmd/main.go
15+
16+
test:
17+
go test -v $(PKG)
18+
19+
lint:
20+
golangci-lint run
21+
22+
fmt:
23+
gofmt -s -w .
24+
25+
coverage:
26+
go test -coverprofile=coverage.out $(PKG)
27+
go tool cover -func=coverage.out

README.md

Lines changed: 191 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,192 @@
1-
2-
![image](https://github.com/user-attachments/assets/a1c1c2af-3983-4bd5-9618-154d63c4e795)
31
# 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

clisland

2.33 MB
Binary file not shown.

0 commit comments

Comments
 (0)