# Development Notes & TODOs

## Immediate Tasks

### Core Gameplay (Priority 1)
- [ ] Implement HuntingEvent logic
  - Roll for success based on tribe member stats
  - Can result in: food found, injuries, deaths
  - Generate narrative description
  
- [ ] Implement ExplorationEvent logic
  - Discover items
  - Meet NPCs
  - Find new areas
  
- [ ] Implement FarmingEvent logic
  - Produce food
  - Can fail causing injuries
  - Seasonal variation

### Month Progression (Priority 2)
- [ ] Implement seasonal events
  - Spring: breeding season, new births
  - Summer: abundance, good hunting
  - Autumn: preparation, gathering
  - Winter: hardship, cold injuries
  
- [ ] Implement birth system
  - Parents pass stats to offspring
  - Genetic inheritance up to 3 levels
  - New age tiers for babies

### Story Generation (Priority 3)
- [ ] Narrative templates for events
- [ ] Dynamic story building based on outcomes
- [ ] Age progression narratives
- [ ] Death narratives

## Medium Priority

### Sprite System
- [ ] Implement transformSprite() method
- [ ] Create sprite modification pipeline
- [ ] Per-kobold sprite storage
- [ ] Damage/scar visualization

### NPC System
- [ ] Implement NPC interactions
- [ ] Trade system
- [ ] Diplomacy (rival vs friendly)
- [ ] NPC tribes can affect game

### Item System
- [ ] More item types
- [ ] Item durability
- [ ] Crafting system (use Crafting stat)
- [ ] Inheritance of items between generations

## Lower Priority (Nice-to-Have)

### UI Enhancements
- [ ] Sprite rendering in HTML5 Canvas/WebGL
- [ ] Better visual feedback
- [ ] Sound effects
- [ ] Drag-and-drop for items
- [ ] Detailed stat viewer

### Gameplay Balance
- [ ] Tune event success rates
- [ ] Balance injury frequency
- [ ] Adjust birth rates
- [ ] Fine-tune seasonal modifiers

### Administration
- [ ] Admin panel for content
- [ ] Event editor
- [ ] Item templates
- [ ] Balance tweaking tools

## Code Quality

### Testing
- [ ] Unit tests for stat system
- [ ] Integration tests for events
- [ ] Database transaction tests
- [ ] Frontend interaction tests

### Documentation
- [ ] API documentation (OpenAPI/Swagger)
- [ ] Event creation guide
- [ ] Extension guide
- [ ] Database schema documentation

### Performance
- [ ] Database query optimization
- [ ] Frontend state management
- [ ] Lazy loading for large tribes
- [ ] Caching strategy

## Known Limitations

1. **Sprite System Not Implemented**
   - Placeholder sprite handling in place
   - transformSprite() is empty
   - No pixel-level modifications yet

2. **Event Logic Incomplete**
   - Event framework ready
   - Individual event logic needs implementation
   - Story generation is basic

3. **Frontend State**
   - Currently loads from server each time
   - Could optimize with local caching
   - No auto-save yet

4. **NPC System**
   - Stored but not actively used
   - No NPC interactions yet

## Architecture Improvements Possible

1. **Event Outcomes**
   - Create outcome system for events
   - Define possible outcomes
   - Weight-based selection

2. **Stat Modifiers**
   - Item system uses flat modifiers
   - Could add percentages/multipliers
   - Equipment slots for optimization

3. **Genetic Algorithm**
   - Could improve inheritance system
   - Stat averaging from parents
   - Mutation rates

4. **Seasonal Modifiers**
   - Events have seasonal variants
   - Different injury types per season
   - Seasonal stat bonuses/penalties

## Future Expansion Ideas

1. **Achievements/Progression**
   - Unlock new events
   - Cosmetic rewards
   - Stats tracking

2. **Difficulty Settings**
   - Hardcore mode (permadeath)
   - Easy mode (reduced injuries)
   - Sandbox mode (no aging)

3. **Multiplayer**
   - Trading between players
   - Rival tribes (PvP events)
   - Shared events/server events

4. **Mod Support**
   - Custom event loading
   - Custom injury types
   - Custom items

5. **Mobile Version**
   - Responsive UI done
   - Simplified controls
   - Mobile-optimized

## Testing Commands

```php
// In PHP console to test database initialization
php -r "require 'vendor/autoload.php'; \TribeGen\Database\Database::getInstance()->initializeTables(); echo 'OK';"

// Generate test tribe
php -r "
require 'vendor/autoload.php';
use TribeGen\Classes\User;
use TribeGen\Classes\Tribe;
use TribeGen\Classes\Kobold;

// Create user
\$user = User::register('test@example.com', 'password123');

// Create tribe
\$tribe = Tribe::create(\$user->getId(), 'Test Tribe');

// Generate kobolds
for (\$i = 0; \$i < 20; \$i++) {
    \$k = Kobold::generate(\$tribe->getSaveId());
    \$k->save();
}

echo 'Test tribe created with ID: ' . \$tribe->getSaveId();
"
```

## File Size Reference

Approximate file sizes for optimization:
- `public/js/app.js`: ~12KB (minified: ~4KB)
- `public/css/style.css`: ~8KB (minified: ~5KB)
- Database per save: ~50KB average
- Sprites per morph: ~200KB (PNG files)

## Version History

- **v0.1.0** - Initial project setup
  - Project structure created
  - Database schema designed
  - Core classes implemented
  - Frontend scaffolding complete
  - Event system framework ready
