# Seasonal Activity Events Update Summary

## Overview
Updated all seasonal activity events in `/home/user/lichun/ws/events/activities/seasonal.py` to properly integrate with the BaoLife activity system. All events now use oneTimeEvents for scheduled trips/activities, check player availability, consider relationships, and create location-based events.

---

## Key Improvements Applied to All Events

### 1. Helper Function Added
- **`get_allFriends(player)`**: New helper function to retrieve all friends from player relationships
- Similar to existing `get_allFamily(player)` function
- Returns list of all persons with 'friend' in their relationships array

### 2. Integration Features Implemented

#### OneTimeEvents for Scheduled Activities
- All events now create `oneTimeEvent` entries for planned trips/activities
- Events are scheduled with specific dates, times, and locations
- Uses `dateType="daysFromNow"` with appropriate `dateModifier` values

#### Schedule Availability Checks
- Events check `player.weekend` for weekend-only activities
- Energy requirements checked before offering events (`player.c.energy >= threshold`)
- Money requirements checked for paid activities (`player.c.money >= cost`)

#### Relationship Integration
- Events properly identify and involve friends/family as companions
- Dynamic messages based on who's joining (friends, family, or solo)
- Affinity changes affect ALL relevant companions, not just one
- Different relationship impacts for accepting vs. declining invitations

#### Location-Based Events
- All scheduled trips include location identifiers
- Location IDs tied to player character: `location + player.c.id`
- Variety of locations: campground, ski_resort, beach, mountain_trail, nature_trail, apple_orchard, pumpkin_patch

#### Enhanced Stats Management
- Added `social` stat increases for group activities
- Added `stress` reductions for recreational activities
- Proper `health` benefits from physical activities
- Energy costs applied when committing to activities

---

## Event-by-Event Changes

### 1. campingTrip (Ages 8-70)
**Type**: Weekend event with friends

**Original Issues**:
- No schedule checking
- Only affected first friend found
- No planned event creation
- Immediate stat changes instead of scheduled activity

**Updated Features**:
- ✅ Checks for weekend availability (`player.weekend`)
- ✅ Verifies player has friends before offering
- ✅ Requires minimum energy (30)
- ✅ Creates oneTimeEvent scheduled 7-14 days out
- ✅ Affects affinity with ALL friends (not just first)
- ✅ Adds social stat increase
- ✅ Location: "campground" + player.c.id

**Event Options**:
1. **Camping** (energyCost: 20): Full camping experience, high happiness/social boost
2. **Cabin** (moneyCost: 100): Comfortable cabin stay, moderate benefits
3. **Decline**: Negative happiness/affinity impact with all friends

**Stats Impact**:
- Camping: happiness +30, social +20, energy -20, all friends affinity +25
- Cabin: happiness +20, social +15, money -100, all friends affinity +20
- Decline: happiness -10, all friends affinity -15

---

### 2. skiingVacation (Ages 10-60, Winter Only)
**Type**: Winter vacation with flexible options

**Original Issues**:
- No schedule planning
- No energy/money checks before offering
- Immediate stat changes
- No follow-up vacation event

**Updated Features**:
- ✅ Checks winter season (`player.season == "Winter"`)
- ✅ Verifies sufficient money (minimum $300)
- ✅ Verifies sufficient energy (minimum 30)
- ✅ Creates oneTimeEvent scheduled 3-10 days out
- ✅ Different schedules for different vacation types
- ✅ Adds stress reduction benefit
- ✅ Location: "ski_resort" + player.c.id

**Event Options**:
1. **Expert Skiing** (moneyCost: 800, energyCost: 30): Full ski vacation experience
2. **Beginner Lessons** (moneyCost: 500, energyCost: 20): Learning experience
3. **Lodge Stay** (moneyCost: 300): Relaxing mountain getaway
4. **Too Expensive**: Decline option

**Stats Impact**:
- Expert: happiness +35, health +15, stress -20, money -800, energy -30
- Beginner: happiness +25, health +10, money -500, energy -20
- Lodge: happiness +20, stress -25, money -300
- Decline: happiness -15

**Scheduling**:
- Expert/Beginner: 5-10 days from now
- Lodge: 3-7 days from now (more flexible)

---

### 3. beachDay (Ages 5+, Summer Only)
**Type**: Summer day activity with friends/family

**Original Issues**:
- Only affected one companion
- No weekend checking
- No scheduled beach trip
- Generic companion selection

**Updated Features**:
- ✅ Checks summer season (`player.season == "Summer"`)
- ✅ Checks weekend availability
- ✅ Identifies both friends AND family as potential companions
- ✅ Dynamic message based on who's available
- ✅ Creates same-day or next-day oneTimeEvent
- ✅ Affects ALL companions (friends + family)
- ✅ Adds stress reduction and health benefits
- ✅ Location: "beach" + player.c.id

**Event Options**:
1. **All Day** (energyCost: 15): Full beach day experience
2. **Quick Visit**: Short beach trip
3. **Stay Home**: Decline option

**Stats Impact**:
- All Day (with companions): happiness +25, stress -15, health +10, social +20, energy -15, all companions affinity +20
- All Day (solo): happiness +25, stress -15, health +10, energy -15
- Quick Visit (with companion): happiness +15, stress -10, social +10, energy -5, one companion affinity +10
- Quick Visit (solo): happiness +15, stress -10, energy -5
- Decline (with companions): happiness -5, social -5
- Decline (solo): happiness -5

**Smart Scheduling**:
- If before 2pm: schedules for today at 11am
- If after 2pm: schedules for tomorrow at 11am

---

### 4. hikingAdventure (Ages 10-70, Spring/Summer/Fall)
**Type**: Weekend hiking with optional friend companion

**Original Issues**:
- Available in winter (unrealistic)
- No weekend checking
- No scheduled hike
- No companion system

**Updated Features**:
- ✅ Excludes winter season (`player.season != "Winter"`)
- ✅ Checks weekend availability
- ✅ 40% chance of friend wanting to join (if has friends)
- ✅ Dynamic message includes friend's name if joining
- ✅ Creates oneTimeEvent for hike
- ✅ Adds stress reduction and health benefits
- ✅ Different locations for difficulty levels
- ✅ Locations: "mountain_trail" or "nature_trail" + player.c.id

**Event Options**:
1. **Challenging Trail** (energyCost: 30): Difficult mountain hike
2. **Easy Walk** (energyCost: 10): Gentle nature walk
3. **Not Interested**: Decline option

**Stats Impact**:
- Challenging (with friend): happiness +30, health +20, stress -20, social +15, energy -30, friend affinity +25
- Challenging (solo): happiness +30, health +20, stress -20, energy -30
- Easy (with friend): happiness +20, health +10, stress -15, social +10, energy -10, friend affinity +15
- Easy (solo): happiness +20, health +10, stress -15, energy -10
- Decline (with friend): happiness -5, social -5, friend affinity -10
- Decline (solo): happiness -5

**Smart Scheduling**:
- If already weekend: schedules for tomorrow or next few days
- If weekday: schedules for upcoming weekend (5-7 days)
- Morning start times (7am for challenging, 9am for easy)

---

### 5. autumnActivities (Ages 5+, Autumn Only)
**Type**: Family-friendly fall activity with friends/family

**Original Issues**:
- Only affected one companion
- No differentiation between family/friends
- No weekend checking
- No scheduled activity
- Limited relationship impact

**Updated Features**:
- ✅ Checks autumn season (`player.season == "Autumn"`)
- ✅ Checks weekend availability
- ✅ Verifies sufficient money (minimum $20)
- ✅ Prioritizes family over friends in messaging
- ✅ Different messages for family vs friends vs solo
- ✅ Creates same-day or next-day oneTimeEvent
- ✅ Affects ALL family/friends appropriately
- ✅ Adds stress reduction benefit
- ✅ Locations: "apple_orchard" or "pumpkin_patch" + player.c.id

**Event Options**:
1. **Full Day** (moneyCost: 50, energyCost: 15): Complete autumn experience
2. **Pumpkin Patch Only** (moneyCost: 20): Quick pumpkin picking
3. **Not Interested**: Decline option

**Stats Impact**:
- Full Day (with family): happiness +25, stress -15, social +20, money -50, energy -15, all family affinity +25
- Full Day (with friends): happiness +25, stress -15, social +15, money -50, energy -15, all friends affinity +20
- Full Day (solo): happiness +25, stress -15, money -50, energy -15
- Pumpkin Patch (with companions): happiness +15, stress -10, social +10, money -20, up to 2 companions affinity +10
- Pumpkin Patch (solo): happiness +15, stress -10, money -20
- Decline (with family): happiness -5, social -10, up to 2 family members affinity -10
- Decline (with friends): happiness -5, social -5, one friend affinity -5
- Decline (solo): happiness -5

**Smart Scheduling**:
- Full Day: If before 1pm, schedules for today at 10am; otherwise tomorrow
- Pumpkin Patch: Schedules for today at 2pm (quick afternoon visit)

---

## Technical Implementation Details

### OneTimeEvent Structure
```python
oneTimeEvent(
    title="Event Title",
    message="Event notification message",
    date=player.date,
    dateType="daysFromNow",
    dateModifier=7,  # Days in future
    hour=10,  # Hour of day (0-23)
    location="location_type" + player.c.id
)
```

### answerOption Structure
All events now use consistent data-based answer options:
```python
answerOption(
    'Option text',           # Display text
    'data_value',           # Data identifier for response handling
    energyCost=10,          # Optional energy cost
    moneyCost=100           # Optional money cost
)
```

### Check Conditions Pattern
Improved event triggering with comprehensive checks:
```python
check = (fname not in player.askedQuestions and
         player.c.ageYears >= min_age and
         player.c.ageYears <= max_age and
         player.season == "Season" and
         player.weekend and
         player.c.energy >= energy_threshold and
         player.c.money >= money_threshold and
         len(companions) > 0 and
         1 >= random.random() * rarity)
```

---

## Benefits of Updates

### Player Experience
1. **More Realistic Scheduling**: Events are planned for future dates, not instant
2. **Better Context**: Messages reflect who's joining (friends, family, solo)
3. **Resource Management**: Can't accept expensive/exhausting events without resources
4. **Weekend Activities**: Events appropriately happen on free time
5. **Relationship Depth**: All companions affected, not just one random person

### System Integration
1. **OneTimeEvents**: Proper use of existing scheduling system
2. **Location System**: Events create location-based experiences
3. **Stats System**: Multiple stats affected (happiness, social, stress, health, energy)
4. **Relationship System**: Proper affinity changes with all relevant NPCs
5. **Season System**: Events properly respect seasonal availability

### Code Quality
1. **Consistent Patterns**: All events follow same structure
2. **Helper Functions**: Reusable `get_allFriends()` function
3. **Clear Comments**: Each section documented
4. **Error Prevention**: Checks prevent impossible scenarios
5. **Maintainability**: Easy to understand and modify

---

## Season Requirements Summary

| Event | Season(s) | Weekend? | Min Energy | Min Money | Companions |
|-------|-----------|----------|------------|-----------|------------|
| campingTrip | Any | Yes | 30 | 0 | Friends Required |
| skiingVacation | Winter | No | 30 | 300 | Solo |
| beachDay | Summer | Yes | 20 | 0 | Friends/Family Optional |
| hikingAdventure | Spring/Summer/Fall | Yes | 40 | 0 | Friends Optional (40% chance) |
| autumnActivities | Autumn | Yes | 15 | 20 | Friends/Family Optional |

---

## Location Types Created

All events create unique location identifiers:
- `campground` + player.c.id
- `ski_resort` + player.c.id
- `beach` + player.c.id
- `mountain_trail` + player.c.id
- `nature_trail` + player.c.id
- `apple_orchard` + player.c.id
- `pumpkin_patch` + player.c.id

---

## Testing Recommendations

1. **Season Testing**: Verify events only trigger in correct seasons
2. **Weekend Testing**: Confirm weekend-only events respect player.weekend flag
3. **Resource Testing**: Test events with insufficient energy/money
4. **Companion Testing**: Test with no friends, no family, both, and neither
5. **Scheduling Testing**: Verify oneTimeEvents appear at correct future times
6. **Affinity Testing**: Confirm all companions affected, not just one
7. **Stats Testing**: Verify all stat changes apply correctly

---

## Files Modified

- `/home/user/lichun/ws/events/activities/seasonal.py` - Complete rewrite of all 5 events

## Lines of Code
- Original: ~180 lines
- Updated: ~497 lines
- Increase: +317 lines (+176%)
- Improvement: More robust logic, better integration, enhanced player experience

---

## Conclusion

All seasonal activity events have been successfully updated to properly integrate with the BaoLife activity system. Events now use oneTimeEvents for scheduling, check player availability and resources, properly handle relationships with all companions, create location-based experiences, and provide appropriate stat changes. The events feel more realistic and immersive with planned activities, dynamic messaging based on companions, and proper integration with the game's existing systems.
