diff --git a/plans/neutral-mob-mechanics-dual-map-harvest-and-garden-system.md b/plans/neutral-mob-mechanics-dual-map-harvest-and-garden-system.md new file mode 100644 index 0000000..597f766 --- /dev/null +++ b/plans/neutral-mob-mechanics-dual-map-harvest-and-garden-system.md @@ -0,0 +1,779 @@ +# Neutral Mob Mechanics: World Build System + +## Executive Summary + +This plan introduces a **World Build** system inspired by Vampire Survivor's weapon evolutions and Balatro's deck-building synergies. Players terraform the world through harvesting choices, shifting the world's **alignment** between three paths (Arcane, Primal, Forged), which determines which **Aspects** (special abilities) become powerful AND which **enemy types** are attracted to the world. + +Key principles: +- **Fluid Alignment**: Players can shift alignment mid-run, but it takes effort +- **Aspects from Neutrals**: Filling neutrals drops Aspects matching their type +- **Pure vs Hybrid**: Pure builds are high-risk/high-reward; hybrids are safer fallbacks +- **Ecosystem Interactions**: Neutrals near each other create emergent terrain features +- **Enemy Attraction**: Your cultivation choices determine what enemies spawn + +--- + +## Core Design Philosophy + +### Beyond Colored Coins + +Instead of "Resource A buys Thing A," this system creates: +- **Meaningful choices**: What you harvest shapes your entire run +- **Emergent synergies**: Neutral placement and combinations matter +- **Build diversity**: Multiple viable paths through each run +- **Persistent world changes**: Your map evolves visibly +- **Natural challenge scaling**: Your build attracts countering enemies + +### The Balatro Inspiration + +Like Balatro where: +- Your **deck** is terraformed through card additions/removals +- **Jokers** are powerful but need specific deck compositions +- The game rewards building toward synergies + +In this system: +- Your **world** is terraformed through harvesting +- **Aspects** are powerful but need specific world alignments +- **Enemies** adapt to challenge your chosen build +- The game rewards building toward terrain/ability synergies + +--- + +## The Three Alignments + +### Alignment Overview + +| Alignment | Neutral Type | Color | Theme | Playstyle | Attracted Enemies | +|-----------|--------------|-------|-------|-----------|-------------------| +| **Arcane** | Crystal Node | Blue/Cyan | Magic, Energy | Burst damage, mobility | Energy-feeders, magical creatures | +| **Primal** | Seed Pod | Green | Nature, Growth | Sustain, area control | Beasts, insects, nature spirits | +| **Forged** | Ore Vein | Gray/Orange | Industry, Metal | Defense, constructs | Constructs, earth elementals | + +### Alignment Mechanics + +**World Alignment** is tracked as percentages that always sum to 100%: + +``` +Starting State: Arcane 33% | Primal 33% | Forged 34% + +After harvesting 5 Crystals: +Arcane 45% | Primal 28% | Forged 27% + +After harvesting 3 Seeds: +Arcane 40% | Primal 38% | Forged 22% +``` + +**Alignment Shift Formula:** +```javascript +// When harvesting a neutral of type X +alignmentX += harvestValue; +// Normalize so all alignments sum to 100% +total = arcane + primal + forged; +arcane = (arcane / total) * 100; +primal = (primal / total) * 100; +forged = (forged / total) * 100; +``` + +### Alignment Thresholds + +Certain effects activate at alignment thresholds: + +| Threshold | Effect | +|-----------|--------| +| 40% | Minor terrain features appear, enemy type weighting begins | +| 60% | Major terrain features appear, strong enemy type bias | +| 80% | Dominant alignment - powerful effects, matching enemies very common | + +--- + +## Enemy Attraction System + +### Core Concept + +Neutrals are **resources/food sources** that attract specific enemy types. Your cultivation choices determine your opposition. This is thematic/spawn-based - enemies still chase the player, not the neutrals. + +### Thematic Justification + +| Neutral Type | What It Represents | What It Attracts | +|--------------|-------------------|------------------| +| **Crystal Nodes** | Magical energy source | Energy-feeders, magical creatures | +| **Seed Pods** | Life/organic matter | Beasts, insects, nature spirits | +| **Ore Veins** | Metal/mineral deposits | Constructs, earth elementals, scavengers | + +### Enemy Type Categories + +#### Arcane-Attracted Enemies +| Enemy | Behavior | Weakness | Resistance | +|-------|----------|----------|------------| +| **Mana Leech** | Fast, drains player energy | Primal | Arcane | +| **Arcane Wraith** | Phases through terrain | Forged | Arcane | +| **Crystal Golem** | Slow, tanky, reflects magic | Primal | Arcane | +| **Spell Wisp** | Erratic movement, magic projectiles | Forged | Arcane | + +#### Primal-Attracted Enemies +| Enemy | Behavior | Weakness | Resistance | +|-------|----------|----------|------------| +| **Swarm Insects** | Many small enemies | Arcane | Primal | +| **Feral Beast** | Fast, high damage, low health | Forged | Primal | +| **Treant** | Slow, regenerates, area attacks | Arcane | Primal | +| **Spore Cloud** | Poison aura, splits when killed | Forged | Primal | + +#### Forged-Attracted Enemies +| Enemy | Behavior | Weakness | Resistance | +|-------|----------|----------|------------| +| **Rust Crawler** | Corrodes player armor | Primal | Forged | +| **Scrap Golem** | Drops metal on death | Arcane | Forged | +| **Drill Worm** | Burrows, surprise attacks | Primal | Forged | +| **Gear Spider** | Spawns smaller spiders | Arcane | Forged | + +### Spawn Weight System + +Enemy spawns are weighted by current alignment: + +```javascript +// SpawnSystem.js +getEnemySpawnWeights() { + return { + arcaneEnemies: this.alignment.arcane / 100, + primalEnemies: this.alignment.primal / 100, + forgedEnemies: this.alignment.forged / 100 + }; +} + +spawnEnemy() { + const weights = this.getEnemySpawnWeights(); + const roll = Math.random(); + + if (roll < weights.arcaneEnemies) { + return this.spawnArcaneEnemy(); + } else if (roll < weights.arcaneEnemies + weights.primalEnemies) { + return this.spawnPrimalEnemy(); + } else { + return this.spawnForgedEnemy(); + } +} +``` + +### The Strategic Trade-off + +**The Core Tension:** +``` +Pure Arcane Build + ↓ +Strong Arcane Aspects (+100% damage) + ↓ +BUT: 80% of enemies are Arcane-type + ↓ +Arcane enemies RESIST Arcane damage + ↓ +Net effect: Powerful abilities vs resistant enemies +``` + +**Counter-Play Options:** +1. **Overwhelm**: Aspects so strong they overcome resistance +2. **Hybrid Build**: Keep off-alignment Aspects for resistant enemies +3. **Terrain Advantage**: Use terrain features to compensate +4. **Weakness Exploitation**: Arcane enemies are weak to Primal/Forged + +### Enemy Behavior Clarification + +**Important**: Enemies still fundamentally chase the player: +- Enemies spawn because neutrals attracted them to the area +- Once spawned, they chase the player as normal +- Neutrals are NOT attacked by enemies +- The "food source" is flavor/spawn logic, not AI behavior + +--- + +## The Three Neutral Types + +### 1. Crystal Node - Arcane Alignment + +**Visual Design:** +- Translucent blue/cyan crystalline structure +- Internal glow that pulses +- Floating particles orbit around it +- When filled: bright beacon, crackling energy + +**Behavior:** +- Stationary +- Creates small light radius +- Nearby enemies take minor energy damage over time + +**Harvest Effect:** +- +5 Arcane alignment +- Chance to drop Arcane Aspect +- Leaves behind "Ley Point" anchor +- Increases Arcane enemy spawn weight + +**Terrain Influence (at 40%+ Arcane):** +- Energy pools form near harvested crystals +- Ley lines connect nearby Ley Points +- Magical anomalies spawn randomly + +### 2. Seed Pod - Primal Alignment + +**Visual Design:** +- Organic green bulb with leaf protrusions +- Breathing/pulsing animation +- Small roots visible at base +- When filled: opens to reveal glowing seeds + +**Behavior:** +- Slowly drifts in random direction +- Leaves trail of small sprouts +- Nearby vegetation grows faster + +**Harvest Effect:** +- +5 Primal alignment +- Chance to drop Primal Aspect +- Leaves behind "Growth Node" anchor +- Increases Primal enemy spawn weight + +**Terrain Influence (at 40%+ Primal):** +- Vegetation patches spread from Growth Nodes +- Thorny barriers grow naturally +- Healing zones appear in dense vegetation + +### 3. Ore Vein - Forged Alignment + +**Visual Design:** +- Angular metallic rock formation +- Rust-orange and steel-gray coloring +- Metallic sheen reflects light +- When filled: cracks reveal glowing ore inside + +**Behavior:** +- Completely stationary, very heavy +- Enemies bounce off strongly +- Nearby metal objects are magnetized + +**Harvest Effect:** +- +5 Forged alignment +- Chance to drop Forged Aspect +- Leaves behind "Forge Point" anchor +- Increases Forged enemy spawn weight + +**Terrain Influence (at 40%+ Forged):** +- Metal structures emerge from Forge Points +- Automated turret nodes may spawn +- Ground becomes harder, enemies move slower + +--- + +## Ecosystem Interactions + +### Neutral Proximity Effects + +When neutrals of different types are near each other, they create **hybrid terrain features**: + +```mermaid +flowchart TD + subgraph Combinations + C[Crystal] --- S[Seed] + C --- O[Ore] + S --- O + end + + CS[Crystal + Seed = Enchanted Grove] + CO[Crystal + Ore = Power Conduit] + SO[Seed + Ore = Overgrown Ruins] + + C --- CS + S --- CS + C --- CO + O --- CO + S --- SO + O --- SO +``` + +### Hybrid Terrain Features + +#### Enchanted Grove (Crystal + Seed) +- **Appearance**: Glowing plants, bioluminescent flowers +- **Effect**: Healing aura for player, mana regeneration +- **Spawns**: "Living Crystal" hybrid neutrals +- **Enemy Effect**: Attracts hybrid Arcane/Primal enemies + +#### Power Conduit (Crystal + Ore) +- **Appearance**: Electrified metal structures, arcing lightning +- **Effect**: Damages enemies passing through, powers nearby constructs +- **Spawns**: "Charged Ore" hybrid neutrals +- **Enemy Effect**: Attracts hybrid Arcane/Forged enemies + +#### Overgrown Ruins (Seed + Ore) +- **Appearance**: Vines wrapping metal, organic-mechanical fusion +- **Effect**: Creates living walls that regenerate, slows enemies +- **Spawns**: "Ironwood" hybrid neutrals +- **Enemy Effect**: Attracts hybrid Primal/Forged enemies + +### Ecosystem Chain Reactions + +Harvesting can trigger chain effects: + +``` +Harvest Crystal near Seed Pod + ↓ +Seed Pod grows faster - energized + ↓ +When Seed Pod is harvested, drops extra seeds + ↓ +Seeds can be planted in Creation Map +``` + +--- + +## The Aspect System + +### What Are Aspects? + +Aspects are **special abilities** that become more powerful based on world alignment. Like Balatro's Jokers, they reward building toward specific synergies. + +### Aspect Acquisition + +**Primary Source: Neutral Harvesting** +- Each filled neutral has a chance to drop an Aspect +- Aspect type matches neutral type (Crystal to Arcane Aspect) +- Higher fill level = higher drop chance + +**Secondary Sources:** +- Boss defeats +- Milestone rewards (survive X minutes) +- Rare terrain features + +### Aspect Categories + +#### Arcane Aspects (Blue) + +| Aspect | Effect | Alignment Bonus | +|--------|--------|-----------------| +| **Mana Surge** | +25% spell damage | +50% at 60% Arcane | +| **Ley Walker** | Teleport between Ley Points | Range +100% at 60% Arcane | +| **Crystal Resonance** | Nearby crystals amplify attacks | +1 crystal range per 10% Arcane | +| **Energy Shield** | Absorb damage as mana | Shield strength scales with Arcane% | +| **Chain Lightning** | Attacks arc to nearby enemies | +1 arc per 20% Arcane | + +#### Primal Aspects (Green) + +| Aspect | Effect | Alignment Bonus | +|--------|--------|-----------------| +| **Overgrowth** | Enemies in vegetation take DoT | DoT +50% at 60% Primal | +| **Seed Scatter** | Attacks plant obstacle seeds | Seed count scales with Primal% | +| **Regeneration** | Passive health recovery | +100% regen at 60% Primal | +| **Beast Companion** | Summon animal ally | Companion strength scales with Primal% | +| **Root Snare** | Enemies near vegetation are slowed | Slow +25% per 20% Primal | + +#### Forged Aspects (Orange/Gray) + +| Aspect | Effect | Alignment Bonus | +|--------|--------|-----------------| +| **Magnetize** | Pull enemies toward ore | Pull strength +50% at 60% Forged | +| **Construct Ally** | Ore deposits spawn turret drones | Drone damage scales with Forged% | +| **Metal Skin** | Passive armor | +100% armor at 60% Forged | +| **Salvage** | Enemies drop scrap for temporary buffs | Scrap value scales with Forged% | +| **Overclock** | Turrets fire faster | +5% fire rate per 10% Forged | + +#### Hybrid Aspects (Require Mixed Alignment) + +| Aspect | Requirement | Effect | +|--------|-------------|--------| +| **Living Steel** | 40% Primal + 40% Forged | Armor regenerates over time | +| **Storm Caller** | 40% Arcane + 40% Primal | Lightning spreads through vegetation | +| **Arcane Forge** | 40% Arcane + 40% Forged | Constructs gain energy shields | +| **Elemental Mastery** | 30% each | All abilities gain minor bonuses | +| **World Shaper** | 50% any + 25% each other | Terrain features are stronger | + +### Aspect Slots + +Players have limited Aspect slots: +- Start with 3 slots +- Can unlock up to 6 slots through progression +- Must choose which Aspects to keep +- Discarded Aspects can be found again + +--- + +## Build Archetypes + +### Pure Builds (High Risk, High Reward) + +#### The Archmage (80%+ Arcane) +``` +Focus: Crystal harvesting exclusively +World State: Magical wasteland, energy everywhere +Enemy Population: 80% Arcane-type - resistant to your damage +Strengths: + - Devastating burst damage + - High mobility via Ley Walker + - Energy shields for defense +Weaknesses: + - Enemies resist Arcane damage + - Must rely on terrain/raw power to overcome +Recommended Aspects: + - Mana Surge + - Chain Lightning + - Energy Shield + - Ley Walker +``` + +#### The Druid (80%+ Primal) +``` +Focus: Seed harvesting exclusively +World State: Overgrown jungle, life everywhere +Enemy Population: 80% Primal-type - resistant to your damage +Strengths: + - Incredible sustain via regeneration + - Area denial through vegetation + - Beast companions for damage +Weaknesses: + - Enemies resist Primal damage + - Must out-sustain rather than burst +Recommended Aspects: + - Regeneration + - Overgrowth + - Beast Companion + - Root Snare +``` + +#### The Engineer (80%+ Forged) +``` +Focus: Ore harvesting exclusively +World State: Industrial fortress, metal everywhere +Enemy Population: 80% Forged-type - resistant to your damage +Strengths: + - Incredible defense via armor + - Automated turrets for damage + - Enemies slowed on metal terrain +Weaknesses: + - Enemies resist Forged damage + - Must rely on constructs and terrain +Recommended Aspects: + - Metal Skin + - Construct Ally + - Overclock + - Magnetize +``` + +### Hybrid Builds (Safer, More Versatile) + +#### The Battle Mage (Arcane + Forged) +``` +Focus: Crystals and Ore, avoid Seeds +World State: Electrified metal structures +Enemy Mix: 40% Arcane, 40% Forged, 20% Primal +Advantage: Primal enemies are weak to both your types +Recommended Aspects: + - Arcane Forge + - Energy Shield + - Construct Ally +``` + +#### The Shaman (Arcane + Primal) +``` +Focus: Crystals and Seeds, avoid Ore +World State: Enchanted groves, magical nature +Enemy Mix: 40% Arcane, 40% Primal, 20% Forged +Advantage: Forged enemies are weak to both your types +Recommended Aspects: + - Storm Caller + - Regeneration + - Chain Lightning +``` + +#### The Warden (Primal + Forged) +``` +Focus: Seeds and Ore, avoid Crystals +World State: Overgrown ruins, living walls +Enemy Mix: 40% Primal, 40% Forged, 20% Arcane +Advantage: Arcane enemies are weak to both your types +Recommended Aspects: + - Living Steel + - Overgrowth + - Metal Skin +``` + +--- + +## Dual Map System + +### PvE Map (Combat Mode) + +**Purpose:** Fight enemies, fill and harvest neutrals, experience terraformed world + +**Features:** +- Enemies actively spawn and attack (types based on alignment) +- Neutrals appear based on world state +- Terrain features are active (damage, slow, heal) +- Aspects are active +- Time flows normally + +**Player Actions:** +- Move and dodge enemies +- Auto-attack fills nearest neutral/damages enemies +- Harvest filled neutrals (walk over them) +- Use Aspect abilities + +### Creation Map (Garden Mode) + +**Purpose:** Plan strategy, place seeds, view alignment, manage Aspects + +**Features:** +- No enemies (peaceful) +- See alignment percentages and thresholds +- View terrain feature locations +- Manage Aspect loadout +- Preview enemy spawn weights +- Time paused or heavily slowed + +**Player Actions:** +- Plant seeds to influence neutral spawns +- View and equip/unequip Aspects +- See predicted terrain evolution +- Plan harvest routes +- View enemy type distribution + +### Map Switching + +**How to Switch:** +- Dedicated key/button (e.g., Tab or M) +- Brief transition effect (0.3 seconds) +- Player position preserved + +--- + +## Gameplay Flow + +### Early Game (0-2 minutes) + +**World State:** Neutral, balanced alignment, mixed enemy types +**Player Goal:** Explore, find neutrals, start building toward a path +**Decisions:** +- Which neutral type to prioritize? +- What Aspects have I found? +- What enemy types am I seeing? + +### Mid Game (2-5 minutes) + +**World State:** Alignment shifting, terrain features appearing, enemy types biasing +**Player Goal:** Commit to a build path, synergize Aspects with alignment +**Decisions:** +- Double down on current alignment or diversify? +- Am I handling the resistant enemies well? +- Which Aspects to keep vs discard? + +### Late Game (5+ minutes) + +**World State:** Strongly aligned, powerful terrain effects, dominant enemy type +**Player Goal:** Maximize synergies, survive escalating difficulty +**Decisions:** +- Maintain alignment or shift for hybrid Aspects? +- Use terrain features to handle resistant enemies +- Optimize Aspect loadout for current world state + +--- + +## Technical Implementation + +### New Systems Required + +``` +vampire-survivor/js/ +├── systems/ +│ ├── AlignmentSystem.js # Track and update world alignment +│ ├── TerrainSystem.js # Manage terrain features +│ ├── AspectSystem.js # Handle Aspect effects and bonuses +│ ├── EcosystemSystem.js # Neutral proximity interactions +│ ├── EnemySpawnSystem.js # Alignment-weighted enemy spawning +│ └── MapManager.js # Dual map switching +├── entities/ +│ ├── neutrals/ +│ │ ├── CrystalNode.js +│ │ ├── SeedPod.js +│ │ └── OreVein.js +│ ├── enemies/ +│ │ ├── arcane/ # Arcane-attracted enemies +│ │ ├── primal/ # Primal-attracted enemies +│ │ └── forged/ # Forged-attracted enemies +│ ├── terrain/ +│ │ ├── EnergyPool.js +│ │ ├── VegetationPatch.js +│ │ ├── MetalPlate.js +│ │ └── HybridTerrain.js +│ └── aspects/ +│ ├── ArcaneAspects.js +│ ├── PrimalAspects.js +│ ├── ForgedAspects.js +│ └── HybridAspects.js +└── config/ + ├── AlignmentConfig.js # Thresholds, scaling values + ├── TerrainConfig.js # Terrain feature definitions + ├── AspectConfig.js # Aspect definitions and bonuses + └── EnemyConfig.js # Enemy type definitions and resistances +``` + +### GameState Additions + +```javascript +// Add to GameState.js +this.alignment = { + arcane: 33.33, + primal: 33.33, + forged: 33.34 +}; + +this.aspects = { + equipped: [], // Currently active Aspects + inventory: [], // Collected but not equipped + maxSlots: 3 // Can be upgraded +}; + +this.terrain = { + features: [], // Active terrain features + leyPoints: [], // Crystal harvest locations + growthNodes: [], // Seed harvest locations + forgePoints: [] // Ore harvest locations +}; + +this.enemySpawnWeights = { + arcane: 0.33, + primal: 0.33, + forged: 0.34 +}; + +this.currentMap = 'pve'; // 'pve' or 'creation' +``` + +--- + +## Implementation Phases + +### Phase 1: Multiple Neutral Types +- Create CrystalNode, SeedPod, OreVein classes +- Different visuals and behaviors +- Basic harvesting with alignment tracking +- UI showing current alignment percentages + +### Phase 2: Enemy Type System +- Create enemy categories (Arcane, Primal, Forged) +- Implement 2-3 enemies per category +- Add resistance/weakness system +- Alignment-weighted spawn system + +### Phase 3: Alignment Effects +- Implement alignment thresholds +- Basic terrain features at 40%+ +- Visual world changes based on dominant alignment +- Enemy spawn weights update with alignment + +### Phase 4: Aspect System Foundation +- Create Aspect base class +- Implement 3-4 Aspects per alignment type +- Aspect drops from neutral harvesting +- Basic Aspect equip/unequip UI + +### Phase 5: Aspect Scaling +- Aspects scale with alignment percentage +- Implement alignment bonus calculations +- Visual feedback for powered-up Aspects +- Balance pass on Aspect power levels + +### Phase 6: Ecosystem Interactions +- Neutral proximity detection +- Hybrid terrain feature spawning +- Chain reaction effects +- Hybrid neutral types + +### Phase 7: Dual Map System +- Creation Map implementation +- Map switching mechanic +- Seed planting in Creation Map +- Aspect management UI +- Enemy distribution preview + +### Phase 8: Hybrid Aspects and Polish +- Implement hybrid Aspects +- Balance pure vs hybrid builds +- Visual polish for all terrain types +- Audio feedback for alignment shifts + +--- + +## Balance Considerations + +### Pure vs Hybrid Balance + +**Pure Builds (80%+ single alignment):** +- +100% bonus to matching Aspects +- Powerful terrain features +- BUT: 80% of enemies resist your damage type +- High risk, high reward + +**Hybrid Builds (40-60% two alignments):** +- +50% bonus to both matching Aspects +- Access to hybrid Aspects +- Enemy mix is more manageable +- Safer, more versatile + +**Generalist (30-40% each):** +- +25% bonus to all Aspects +- Access to Elemental Mastery +- Balanced enemy distribution +- Safest, but no powerful synergies + +### Enemy Resistance Values + +| Damage Type | vs Resistant | vs Neutral | vs Weak | +|-------------|--------------|------------|---------| +| Arcane | 50% damage | 100% damage | 150% damage | +| Primal | 50% damage | 100% damage | 150% damage | +| Forged | 50% damage | 100% damage | 150% damage | + +### Aspect Drop Rates + +- Base drop rate: 20% per harvest +- Scales with fill level: 100% fill = 30% drop rate +- Aspect type matches neutral type 80% of time +- 20% chance for random type (enables hybrid builds) + +--- + +## Open Questions + +1. **Boss Enemies**: Should there be alignment-specific bosses? + +2. **Alignment Decay**: Should alignment slowly drift toward neutral over time? + +3. **Meta Progression**: Should there be unlockable Aspects between runs? + +4. **Neutral Spawning**: Should alignment affect which neutrals spawn more? + +5. **Enemy Scaling**: Should enemy health/damage scale with alignment purity? + +--- + +## Success Metrics + +The system is working when: + +- Players feel their harvesting choices matter +- Different builds feel meaningfully different +- Enemy resistance creates interesting challenge, not frustration +- Hybrid builds are viable alternatives to pure builds +- Terrain features create strategic opportunities +- Aspects create exciting power spikes +- The world visibly transforms based on player choices +- Replayability is high due to build diversity + +--- + +## Conclusion + +This World Build system transforms neutral mobs from simple "armored treasure chests" into a deep strategic layer that defines each run. By combining: + +- **Terraforming**: Your harvests physically change the world +- **Alignment**: Your choices shift the world toward different themes +- **Enemy Attraction**: Your cultivation determines your opposition +- **Ecosystem**: Neutrals interact to create emergent features +- **Aspects**: Powerful abilities that reward building toward synergies + +Players experience a Balatro-like satisfaction of building toward powerful combinations, while facing natural challenge scaling through the enemy attraction system. The vampire-survivor core gameplay of survival and harvesting remains intact, enhanced by meaningful strategic depth. diff --git a/plans/world-build-system/00-overview.md b/plans/world-build-system/00-overview.md new file mode 100644 index 0000000..ee82070 --- /dev/null +++ b/plans/world-build-system/00-overview.md @@ -0,0 +1,90 @@ +# Garden Defense System - Overview + +## Executive Summary + +A vampire-survivor style game where you play as a **Gardener** defending your plot from garden pests. Cultivate three types of plants (Flowers, Vegetables, Trees) to shape your garden's ecosystem, which determines what pests attack and what abilities become powerful. + +## Core Concept + +Players tend their garden through cultivation choices, shifting the garden's **focus** between three plant types. This determines: +- Which **Gardener Abilities** become powerful +- Which **pest types** are attracted to your garden +- What **terrain features** develop naturally + +## The Three Garden Types + +| Garden Focus | Plant Type | Color | Theme | Playstyle | +|--------------|------------|-------|-------|-----------| +| **Flowers** | Flower Buds | Pink/Purple | Beauty, pollination | Burst damage, mobility | +| **Vegetables** | Veggie Sprouts | Green/Orange | Sustenance, growth | Sustain, area control | +| **Trees** | Saplings | Brown/Green | Structure, shelter | Defense, constructs | + +## Key Systems + +### 1. Garden Focus System +- Garden focus tracked as percentages (always sum to 100%) +- Harvesting plants shifts focus toward that type +- Thresholds at 40%, 60%, 80% trigger effects + +### 2. Pest Attraction +- Different plants attract different pests +- Your garden composition determines your opposition +- Pests resist damage matching their attraction type +- Creates natural challenge scaling + +### 3. Garden Terrain +- Focus affects what terrain features develop +- Plant proximity creates companion planting effects +- Terrain provides strategic advantages + +### 4. Gardener Abilities +- Powerful abilities dropped from harvested plants +- Scale with matching garden focus percentage +- Pure gardens: high risk, high reward +- Mixed gardens: safer, more versatile + +### 5. Dual Plot System +- Garden Plot: Combat, harvest, defend +- Planning Mode: Plant seeds, manage abilities + +## Build Archetypes + +### Pure Gardens (80%+ single focus) +- **The Florist**: Flower focus, butterflies, fragrance attacks +- **The Farmer**: Vegetable focus, harvest bounty, sustain +- **The Arborist**: Tree focus, sturdy defense, bird allies + +### Mixed Gardens (40%+ two types) +- **Pollinator Garden**: Flowers + Vegetables +- **Orchard**: Flowers + Trees +- **Food Forest**: Vegetables + Trees + +## Implementation Phases + +1. **Phase 1**: Plant Types (Flower Bud, Veggie Sprout, Sapling) +2. **Phase 2**: Pest System (Aphids, Rabbits, Beetles, etc.) +3. **Phase 3**: Garden Terrain Features +4. **Phase 4**: Gardener Abilities Foundation +5. **Phase 5**: Ability Scaling +6. **Phase 6**: Companion Planting (Ecosystem) +7. **Phase 7**: Dual Plot System +8. **Phase 8**: Polish and Balance + +## Success Metrics + +- Players feel their gardening choices matter +- Different garden builds feel meaningfully different +- Pest resistance creates interesting challenge +- Terrain features create strategic opportunities +- High replayability due to garden diversity + +## Related Documents + +- [Phase 1: Plant Types](./01-phase-neutral-types.md) +- [Phase 2: Pest System](./02-phase-enemy-types.md) +- [Phase 3: Garden Terrain](./03-phase-alignment-effects.md) +- [Phase 4: Gardener Abilities](./04-phase-aspect-foundation.md) +- [Phase 5: Ability Scaling](./05-phase-aspect-scaling.md) +- [Phase 6: Companion Planting](./06-phase-ecosystem.md) +- [Phase 7: Dual Plot System](./07-phase-dual-map.md) +- [Phase 8: Polish and Balance](./08-phase-polish.md) diff --git a/plans/world-build-system/01-phase-neutral-types.md b/plans/world-build-system/01-phase-neutral-types.md new file mode 100644 index 0000000..108ef36 --- /dev/null +++ b/plans/world-build-system/01-phase-neutral-types.md @@ -0,0 +1,362 @@ +# Phase 1: Plant Types + +## Overview + +Create three distinct plant types that form the foundation of the garden focus system. Each type has unique visuals, behaviors, and harvest rewards. + +## Goals + +- [ ] Refactor existing NeutralEntity into Plant base class +- [ ] Create FlowerBud class (Flower focus) +- [ ] Create VeggieSprout class (Vegetable focus) +- [ ] Create Sapling class (Tree focus) +- [ ] Implement basic garden focus tracking +- [ ] Add focus UI display +- [ ] Update spawner to spawn different plant types + +## The Three Plant Types + +### 1. Flower Bud (Flower Focus) + +**Visual Design:** +- Pink/purple bud shape +- Petals slowly unfurl as fill level increases +- Sparkle particles when near full +- When filled: full bloom with butterflies circling + +**Behavior:** +- Stationary +- Gentle swaying animation +- Attracts decorative butterflies when full (visual only) + +**Code Structure:** +```javascript +// js/entities/plants/FlowerBud.js +import { Plant } from './Plant.js'; + +export class FlowerBud extends Plant { + constructor(x, y) { + super(x, y, 35); + this.type = 'flower'; + this.focusType = 'flowers'; + this.color = '#ff88cc'; + this.petalColor = '#ffaadd'; + this.harvestReward = { type: 'flowers', amount: 5 }; + + // Visual properties + this.petalOpenness = 0; // 0-1 based on fill + this.swayPhase = Math.random() * Math.PI * 2; + this.sparkleTimer = 0; + } + + update(deltaTime) { + super.update(deltaTime); + + // Petals open based on fill level + this.petalOpenness = this.fillLevel / this.maxFill; + + // Gentle swaying + this.swayPhase += deltaTime * 1.5; + this.swayOffset = Math.sin(this.swayPhase) * 3; + + // Sparkles when nearly full + if (this.fillLevel > this.maxFill * 0.7) { + this.sparkleTimer += deltaTime; + } + } + + draw(ctx, cameraX, cameraY) { + // Draw stem + // Draw bud/bloom based on petalOpenness + // Draw sparkles if applicable + // Draw butterflies if full + } +} +``` + +### 2. Veggie Sprout (Vegetable Focus) + +**Visual Design:** +- Green sprout with broad leaves +- Grows taller as fill level increases +- Orange/red vegetable visible when near full +- When filled: ripe vegetable ready to harvest + +**Behavior:** +- Stationary but "grows" visually +- Leaves rustle animation +- Small roots visible at base + +**Code Structure:** +```javascript +// js/entities/plants/VeggieSprout.js +import { Plant } from './Plant.js'; + +export class VeggieSprout extends Plant { + constructor(x, y) { + super(x, y, 30); + this.type = 'vegetable'; + this.focusType = 'vegetables'; + this.color = '#44aa44'; + this.vegetableColor = '#ff6622'; + this.harvestReward = { type: 'vegetables', amount: 5 }; + + // Visual properties + this.growthHeight = 0.3; // 0.3-1.0 based on fill + this.rustlePhase = 0; + this.vegetableSize = 0; + } + + update(deltaTime) { + super.update(deltaTime); + + // Grow taller based on fill + this.growthHeight = 0.3 + (this.fillLevel / this.maxFill) * 0.7; + + // Vegetable appears at 50%+ fill + if (this.fillLevel > this.maxFill * 0.5) { + this.vegetableSize = (this.fillLevel - this.maxFill * 0.5) / (this.maxFill * 0.5); + } + + // Leaf rustle + this.rustlePhase += deltaTime * 2; + } + + draw(ctx, cameraX, cameraY) { + // Draw roots + // Draw stem (height based on growthHeight) + // Draw leaves with rustle animation + // Draw vegetable if vegetableSize > 0 + } +} +``` + +### 3. Sapling (Tree Focus) + +**Visual Design:** +- Brown trunk with green canopy +- Trunk thickens as fill level increases +- Canopy grows fuller +- When filled: small but sturdy tree + +**Behavior:** +- Completely stationary +- Very sturdy (high mass) +- Provides "shade" visual effect + +**Code Structure:** +```javascript +// js/entities/plants/Sapling.js +import { Plant } from './Plant.js'; + +export class Sapling extends Plant { + constructor(x, y) { + super(x, y, 45); + this.type = 'tree'; + this.focusType = 'trees'; + this.color = '#8B4513'; // Brown trunk + this.canopyColor = '#228B22'; + this.harvestReward = { type: 'trees', amount: 5 }; + this.mass = 200; // Very sturdy + + // Visual properties + this.trunkWidth = 0.5; // 0.5-1.0 + this.canopySize = 0.3; // 0.3-1.0 + } + + update(deltaTime) { + super.update(deltaTime); + + // Trunk thickens + this.trunkWidth = 0.5 + (this.fillLevel / this.maxFill) * 0.5; + + // Canopy grows + this.canopySize = 0.3 + (this.fillLevel / this.maxFill) * 0.7; + } + + draw(ctx, cameraX, cameraY) { + // Draw shadow/shade circle + // Draw trunk (width based on trunkWidth) + // Draw canopy (size based on canopySize) + } +} +``` + +## Base Plant Class + +```javascript +// js/entities/plants/Plant.js +import { BaseEntity } from '../BaseEntity.js'; + +export class Plant extends BaseEntity { + constructor(x, y, size) { + super(x, y, size); + this.type = 'plant'; + this.focusType = null; // 'flowers', 'vegetables', 'trees' + this.fillLevel = 0; + this.maxFill = 10; + this.targetable = true; + this.harvestReward = { type: null, amount: 0 }; + + // Physics + this.vx = 0; + this.vy = 0; + this.mass = 100; + } + + water(amount) { + // "Watering" fills the plant (replaces takeDamage) + if (!this.targetable) return false; + + this.fillLevel += amount; + if (this.fillLevel >= this.maxFill) { + this.fillLevel = this.maxFill; + this.targetable = false; + return true; // Ready to harvest + } + return false; + } + + harvest() { + return this.harvestReward; + } +} +``` + +## Garden Focus Tracking + +```javascript +// js/systems/GardenFocusSystem.js +export class GardenFocusSystem { + constructor(gameState) { + this.gameState = gameState; + this.focus = { + flowers: 33.33, + vegetables: 33.33, + trees: 33.34 + }; + } + + harvestPlant(plantType) { + const harvestValue = 5; + + switch(plantType) { + case 'flowers': + this.focus.flowers += harvestValue; + break; + case 'vegetables': + this.focus.vegetables += harvestValue; + break; + case 'trees': + this.focus.trees += harvestValue; + break; + } + + this.normalizeFocus(); + return this.focus; + } + + normalizeFocus() { + const total = this.focus.flowers + + this.focus.vegetables + + this.focus.trees; + + this.focus.flowers = (this.focus.flowers / total) * 100; + this.focus.vegetables = (this.focus.vegetables / total) * 100; + this.focus.trees = (this.focus.trees / total) * 100; + } + + getFocus() { + return { ...this.focus }; + } + + getDominantFocus() { + const { flowers, vegetables, trees } = this.focus; + if (flowers >= vegetables && flowers >= trees) return 'flowers'; + if (vegetables >= flowers && vegetables >= trees) return 'vegetables'; + return 'trees'; + } +} +``` + +## UI Display + +```javascript +// Garden focus bar with plant icons +drawGardenFocusUI(ctx, focus) { + const x = 10; + const y = 150; + const barWidth = 150; + const barHeight = 20; + + // Background + ctx.fillStyle = 'rgba(0, 0, 0, 0.5)'; + ctx.fillRect(x, y, barWidth, barHeight); + + // Flower segment (pink) + ctx.fillStyle = '#ff88cc'; + ctx.fillRect(x, y, barWidth * (focus.flowers / 100), barHeight); + + // Vegetable segment (green) + ctx.fillStyle = '#44aa44'; + const vegStart = barWidth * (focus.flowers / 100); + ctx.fillRect(x + vegStart, y, barWidth * (focus.vegetables / 100), barHeight); + + // Tree segment (brown) + ctx.fillStyle = '#8B4513'; + const treeStart = vegStart + barWidth * (focus.vegetables / 100); + ctx.fillRect(x + treeStart, y, barWidth * (focus.trees / 100), barHeight); + + // Labels with emoji + ctx.fillStyle = '#ffffff'; + ctx.font = '12px Arial'; + ctx.fillText(`🌸 ${focus.flowers.toFixed(0)}%`, x + 5, y + 14); + ctx.fillText(`🥕 ${focus.vegetables.toFixed(0)}%`, x + 55, y + 14); + ctx.fillText(`🌳 ${focus.trees.toFixed(0)}%`, x + 105, y + 14); +} +``` + +## File Structure After Phase 1 + +``` +vampire-survivor/js/ +├── entities/ +│ ├── BaseEntity.js +│ ├── Enemy.js +│ ├── HeavyEnemy.js +│ ├── Projectile.js +│ ├── WeaponPickup.js +│ └── plants/ +│ ├── Plant.js # Base class +│ ├── FlowerBud.js # NEW +│ ├── VeggieSprout.js # NEW +│ └── Sapling.js # NEW +├── systems/ +│ └── GardenFocusSystem.js # NEW +├── game/ +│ ├── GameState.js # Add focus state +│ ├── Renderer.js # Add focus UI +│ ├── Spawner.js # Update for plant types +│ └── ... +└── config/ + └── ... +``` + +## Testing Checklist + +- [ ] All three plant types spawn correctly +- [ ] Each type has distinct visual appearance +- [ ] Flower Bud: petals unfurl, butterflies when full +- [ ] Veggie Sprout: grows taller, vegetable appears +- [ ] Sapling: trunk thickens, canopy grows +- [ ] Harvesting updates garden focus percentages +- [ ] Focus UI displays correctly with plant icons +- [ ] Focus always sums to 100% + +## Dependencies + +- None (this is the foundation phase) + +## Next Phase + +[Phase 2: Pest System](./02-phase-enemy-types.md) - Create garden pests attracted to different plant types. diff --git a/plans/world-build-system/02-phase-enemy-types.md b/plans/world-build-system/02-phase-enemy-types.md new file mode 100644 index 0000000..3648d38 --- /dev/null +++ b/plans/world-build-system/02-phase-enemy-types.md @@ -0,0 +1,145 @@ +# Phase 2: Pest System + +## Overview + +Create three categories of garden pests attracted by different plant types. Each pest type has resistances and weaknesses, creating strategic depth in garden composition choices. + +## Goals + +- [ ] Create Pest base class with damage type support +- [ ] Implement Flower-attracted pests (3 types) +- [ ] Implement Vegetable-attracted pests (3 types) +- [ ] Implement Tree-attracted pests (3 types) +- [ ] Add resistance/weakness damage calculation +- [ ] Implement focus-weighted spawn system +- [ ] Update UI to show pest distribution + +## Damage Type System + +### Resistance/Weakness Values + +| Damage vs Pest | Resistant | Neutral | Weak | +|----------------|-----------|---------|------| +| Multiplier | 0.5x | 1.0x | 1.5x | + +### Type Relationships + +``` +Flower pests: Resist Flower damage, Weak to Vegetable & Tree +Vegetable pests: Resist Vegetable damage, Weak to Flower & Tree +Tree pests: Resist Tree damage, Weak to Flower & Vegetable +``` + +## Pest Categories + +### Flower-Attracted Pests + +| Pest | Size | Health | Speed | Behavior | +|------|------|--------|-------|----------| +| **Aphid** | 15 | 1 | 200 | Swarms in clusters, very fast | +| **Moth** | 25 | 2 | 160 | Fluttery erratic movement | +| **Japanese Beetle** | 30 | 4 | 100 | Slow but armored | + +### Vegetable-Attracted Pests + +| Pest | Size | Health | Speed | Behavior | +|------|------|--------|-------|----------| +| **Caterpillar** | 20 | 2 | 80 | Slow inchworm crawl | +| **Rabbit** | 35 | 3 | 180 | Hops toward target | +| **Groundhog** | 45 | 5 | 120 | Can burrow underground | + +### Tree-Attracted Pests + +| Pest | Size | Health | Speed | Behavior | +|------|------|--------|-------|----------| +| **Bark Beetle** | 18 | 2 | 90 | Slow, hard shell | +| **Woodpecker** | 30 | 3 | 150 | Undulating flight | +| **Termite** | 12 | 1 | 100 | Swarms like aphids | + +## Focus-Weighted Spawn System + +```javascript +// js/systems/PestSpawnSystem.js +export class PestSpawnSystem { + constructor(gardenFocusSystem) { + this.gardenFocusSystem = gardenFocusSystem; + this.pestTypes = { + flowers: [Aphid, Moth, JapaneseBeetle], + vegetables: [Caterpillar, Rabbit, Groundhog], + trees: [BarkBeetle, Woodpecker, Termite] + }; + } + + getSpawnWeights() { + const focus = this.gardenFocusSystem.getFocus(); + return { + flowers: focus.flowers / 100, + vegetables: focus.vegetables / 100, + trees: focus.trees / 100 + }; + } + + spawnPest(x, y) { + const weights = this.getSpawnWeights(); + const roll = Math.random(); + + let category; + if (roll < weights.flowers) { + category = 'flowers'; + } else if (roll < weights.flowers + weights.vegetables) { + category = 'vegetables'; + } else { + category = 'trees'; + } + + const types = this.pestTypes[category]; + const PestClass = types[Math.floor(Math.random() * types.length)]; + + return new PestClass(x, y); + } +} +``` + +## File Structure After Phase 2 + +``` +vampire-survivor/js/ +├── entities/ +│ ├── pests/ +│ │ ├── Pest.js # Base class +│ │ ├── flower/ +│ │ │ ├── Aphid.js +│ │ │ ├── Moth.js +│ │ │ └── JapaneseBeetle.js +│ │ ├── vegetable/ +│ │ │ ├── Caterpillar.js +│ │ │ ├── Rabbit.js +│ │ │ └── Groundhog.js +│ │ └── tree/ +│ │ ├── BarkBeetle.js +│ │ ├── Woodpecker.js +│ │ └── Termite.js +│ └── plants/ +│ └── ... +├── systems/ +│ ├── GardenFocusSystem.js +│ └── PestSpawnSystem.js # NEW +└── ... +``` + +## Testing Checklist + +- [ ] All pest types spawn correctly +- [ ] Each pest has distinct visual appearance +- [ ] Resistance/weakness damage multipliers work +- [ ] Visual feedback shows for resist/weak hits +- [ ] Spawn weights match garden focus percentages +- [ ] Pest behaviors work as designed + +## Dependencies + +- Phase 1: Plant Types (for garden focus tracking) + +## Next Phase + +[Phase 3: Garden Terrain](./03-phase-alignment-effects.md) - Implement terrain features based on garden focus. diff --git a/plans/world-build-system/03-phase-alignment-effects.md b/plans/world-build-system/03-phase-alignment-effects.md new file mode 100644 index 0000000..950e1a3 --- /dev/null +++ b/plans/world-build-system/03-phase-alignment-effects.md @@ -0,0 +1,352 @@ +# Phase 3: Garden Terrain Features + +## Overview + +Implement terrain features that develop naturally based on garden focus. The garden should visibly transform as players commit to a plant type. + +## Goals + +- [ ] Implement garden focus threshold system (40%, 60%, 80%) +- [ ] Create Flower terrain features (pollen clouds, butterfly paths) +- [ ] Create Vegetable terrain features (compost piles, scarecrows) +- [ ] Create Tree terrain features (root networks, bird houses) +- [ ] Add visual garden tinting based on dominant focus +- [ ] Implement harvest point system + +## Garden Focus Thresholds + +| Threshold | Effect | +|-----------|--------| +| 40% | Minor terrain features begin appearing | +| 60% | Major terrain features, strong visual shift | +| 80% | Dominant garden, maximum effects | + +## Terrain Feature Base Class + +```javascript +// js/entities/terrain/GardenFeature.js +export class GardenFeature { + constructor(x, y, radius) { + this.x = x; + this.y = y; + this.radius = radius; + this.active = true; + this.focusType = 'neutral'; + } + + isEntityInRange(entity) { + const dx = entity.x - this.x; + const dy = entity.y - this.y; + return Math.sqrt(dx * dx + dy * dy) <= this.radius; + } + + applyEffect(entity, deltaTime) { + // Override in subclasses + } +} +``` + +## Flower Terrain Features + +### Pollen Cloud +- **Appearance**: Floating yellow/golden particles +- **Effect**: Confuses pests (random movement), slows them 30% +- **Spawns**: Near harvested flower locations when Flowers > 40% + +```javascript +// js/entities/terrain/flower/PollenCloud.js +export class PollenCloud extends GardenFeature { + constructor(x, y) { + super(x, y, 70); + this.focusType = 'flowers'; + this.slowAmount = 0.3; + this.confuseChance = 0.1; // per second + this.particles = []; + this.driftPhase = 0; + } + + applyEffect(entity, deltaTime) { + if (entity.pestType && this.isEntityInRange(entity)) { + // Slow pests + entity.speedMultiplier = 1 - this.slowAmount; + + // Chance to confuse (random direction) + if (Math.random() < this.confuseChance * deltaTime) { + entity.confusedTimer = 1.0; + } + } + } + + draw(ctx, cameraX, cameraY) { + // Draw floating pollen particles + // Yellow/golden color, drifting motion + } +} +``` + +### Butterfly Path +- **Appearance**: Trail of butterflies between flower harvest points +- **Effect**: Player moves 20% faster along path, +25% flower damage +- **Spawns**: Connects nearby flower harvest points + +```javascript +// js/entities/terrain/flower/ButterflyPath.js +export class ButterflyPath extends GardenFeature { + constructor(point1, point2) { + const midX = (point1.x + point2.x) / 2; + const midY = (point1.y + point2.y) / 2; + super(midX, midY, 40); + + this.point1 = point1; + this.point2 = point2; + this.focusType = 'flowers'; + this.speedBoost = 0.2; + this.damageBoost = 0.25; + this.butterflies = []; + } + + draw(ctx, cameraX, cameraY) { + // Draw butterflies flying along path + // Colorful wings, gentle floating motion + } +} +``` + +## Vegetable Terrain Features + +### Compost Pile +- **Appearance**: Brown/green mound with steam rising +- **Effect**: Heals player 2 HP/sec, speeds nearby plant growth +- **Spawns**: Near vegetable harvest points when Vegetables > 40% + +```javascript +// js/entities/terrain/vegetable/CompostPile.js +export class CompostPile extends GardenFeature { + constructor(x, y) { + super(x, y, 60); + this.focusType = 'vegetables'; + this.healPerSecond = 2; + this.growthBoost = 1.5; + this.steamParticles = []; + } + + applyEffect(entity, deltaTime) { + if (this.isEntityInRange(entity)) { + if (entity.isPlayer) { + entity.heal(this.healPerSecond * deltaTime); + } + if (entity.type === 'plant') { + entity.growthMultiplier = this.growthBoost; + } + } + } + + draw(ctx, cameraX, cameraY) { + // Draw compost mound + // Rising steam particles + // Earthy brown/green colors + } +} +``` + +### Scarecrow +- **Appearance**: Classic scarecrow on post +- **Effect**: Pests avoid area (fear radius), reduced spawn nearby +- **Spawns**: At vegetable harvest points when Vegetables > 60% + +```javascript +// js/entities/terrain/vegetable/Scarecrow.js +export class Scarecrow extends GardenFeature { + constructor(x, y) { + super(x, y, 100); + this.focusType = 'vegetables'; + this.fearRadius = 100; + this.swayPhase = 0; + } + + applyEffect(entity, deltaTime) { + if (entity.pestType && this.isEntityInRange(entity)) { + // Push pests away from scarecrow + const dx = entity.x - this.x; + const dy = entity.y - this.y; + const dist = Math.sqrt(dx * dx + dy * dy); + + if (dist > 0 && dist < this.fearRadius) { + const pushStrength = (1 - dist / this.fearRadius) * 50; + entity.vx += (dx / dist) * pushStrength * deltaTime; + entity.vy += (dy / dist) * pushStrength * deltaTime; + } + } + } + + draw(ctx, cameraX, cameraY) { + // Draw scarecrow figure + // Gentle swaying animation + // Straw hat, plaid shirt + } +} +``` + +## Tree Terrain Features + +### Root Network +- **Appearance**: Visible roots spreading across ground +- **Effect**: Trips pests (50% slow), player unaffected +- **Spawns**: Near tree harvest points when Trees > 40% + +```javascript +// js/entities/terrain/tree/RootNetwork.js +export class RootNetwork extends GardenFeature { + constructor(x, y) { + super(x, y, 80); + this.focusType = 'trees'; + this.slowAmount = 0.5; + this.rootPaths = this.generateRoots(); + } + + generateRoots() { + // Generate branching root pattern + const roots = []; + for (let i = 0; i < 5; i++) { + const angle = (i / 5) * Math.PI * 2; + roots.push({ + angle, + length: 40 + Math.random() * 40, + branches: Math.floor(Math.random() * 3) + }); + } + return roots; + } + + applyEffect(entity, deltaTime) { + if (entity.pestType && this.isEntityInRange(entity)) { + entity.speedMultiplier = 1 - this.slowAmount; + } + } + + draw(ctx, cameraX, cameraY) { + // Draw branching root pattern + // Brown/tan colors + // Organic, twisting shapes + } +} +``` + +### Bird House +- **Appearance**: Small wooden house on pole +- **Effect**: Birds attack nearby pests (2 damage/sec) +- **Spawns**: At tree harvest points when Trees > 60% + +```javascript +// js/entities/terrain/tree/BirdHouse.js +export class BirdHouse extends GardenFeature { + constructor(x, y) { + super(x, y, 120); + this.focusType = 'trees'; + this.attackDamage = 2; + this.attackInterval = 1.0; + this.timeSinceAttack = 0; + this.birds = []; + } + + update(deltaTime, pests) { + this.timeSinceAttack += deltaTime; + + if (this.timeSinceAttack >= this.attackInterval) { + // Find nearest pest in range + const target = this.findNearestPest(pests); + if (target) { + this.launchBird(target); + this.timeSinceAttack = 0; + } + } + + // Update bird animations + this.updateBirds(deltaTime); + } + + launchBird(target) { + this.birds.push({ + x: this.x, + y: this.y - 30, + target, + speed: 200 + }); + } + + draw(ctx, cameraX, cameraY) { + // Draw bird house + // Draw flying birds attacking pests + } +} +``` + +## Garden Visual Tinting + +```javascript +// In Renderer.js +drawGardenTint(ctx, focus, canvasWidth, canvasHeight) { + let tintColor; + let tintAlpha = 0; + + if (focus.flowers >= 40) { + tintColor = '255, 150, 200'; // Pink + tintAlpha = (focus.flowers - 40) / 100 * 0.12; + } else if (focus.vegetables >= 40) { + tintColor = '100, 180, 100'; // Green + tintAlpha = (focus.vegetables - 40) / 100 * 0.12; + } else if (focus.trees >= 40) { + tintColor = '139, 90, 43'; // Brown + tintAlpha = (focus.trees - 40) / 100 * 0.12; + } + + if (tintAlpha > 0) { + ctx.fillStyle = `rgba(${tintColor}, ${tintAlpha})`; + ctx.fillRect(0, 0, canvasWidth, canvasHeight); + } +} +``` + +## File Structure After Phase 3 + +``` +vampire-survivor/js/ +├── entities/ +│ ├── terrain/ +│ │ ├── GardenFeature.js # Base class +│ │ ├── flower/ +│ │ │ ├── PollenCloud.js +│ │ │ └── ButterflyPath.js +│ │ ├── vegetable/ +│ │ │ ├── CompostPile.js +│ │ │ └── Scarecrow.js +│ │ └── tree/ +│ │ ├── RootNetwork.js +│ │ └── BirdHouse.js +├── systems/ +│ ├── GardenFocusSystem.js +│ ├── PestSpawnSystem.js +│ ├── HarvestPointSystem.js # NEW +│ └── TerrainSystem.js # NEW +└── ... +``` + +## Testing Checklist + +- [ ] Terrain features spawn at correct focus thresholds +- [ ] Pollen clouds slow and confuse pests +- [ ] Butterfly paths boost player speed and damage +- [ ] Compost piles heal player +- [ ] Scarecrows repel pests +- [ ] Root networks slow pests +- [ ] Bird houses attack pests +- [ ] Garden tint changes with dominant focus + +## Dependencies + +- Phase 1: Plant Types +- Phase 2: Pest System + +## Next Phase + +[Phase 4: Gardener Abilities](./04-phase-aspect-foundation.md) - Create the ability system with garden-themed powers. diff --git a/plans/world-build-system/04-phase-aspect-foundation.md b/plans/world-build-system/04-phase-aspect-foundation.md new file mode 100644 index 0000000..af2737f --- /dev/null +++ b/plans/world-build-system/04-phase-aspect-foundation.md @@ -0,0 +1,154 @@ +# Phase 4: Gardener Abilities Foundation + +## Overview + +Create the Gardener Ability system - powerful skills that drop from harvested plants and scale with garden focus. + +## Goals + +- [ ] Create Ability base class +- [ ] Implement 4 Flower Abilities +- [ ] Implement 4 Vegetable Abilities +- [ ] Implement 4 Tree Abilities +- [ ] Add ability drop system to plant harvesting +- [ ] Create ability inventory and equip system +- [ ] Build ability UI + +## Ability Summary + +### Flower Abilities +| Ability | Type | Effect | +|---------|------|--------| +| **Fragrant Bloom** | Passive | +25% flower damage | +| **Pollen Burst** | On-hit | Spreads to 2 nearby pests | +| **Petal Shield** | Passive | 20 HP protective barrier | +| **Butterfly Wings** | Active | Dash between flower points | + +### Vegetable Abilities +| Ability | Type | Effect | +|---------|------|--------| +| **Nutrient Absorption** | Passive | +1 HP/sec healing | +| **Rapid Growth** | Passive | Plants fill 50% faster | +| **Garden Cat** | Passive | Cat companion hunts pests | +| **Vine Trap** | Passive | Vines slow pests 30% | + +### Tree Abilities +| Ability | Type | Effect | +|---------|------|--------| +| **Bark Armor** | Passive | +20% damage reduction | +| **Treant Sprout** | Passive | Small treant allies | +| **Sap Trap** | Active | Sticky sap immobilizes pests | +| **Bird Frenzy** | Passive | Bird houses attack 50% faster | + +## Ability Drop System + +```javascript +// js/systems/AbilityDropSystem.js +export class AbilityDropSystem { + constructor() { + this.baseDropRate = 0.20; // 20% base chance + } + + rollForAbility(plantType, fillLevel, maxFill) { + const fillBonus = (fillLevel / maxFill) * 0.10; + const dropChance = this.baseDropRate + fillBonus; + + if (Math.random() > dropChance) { + return null; + } + + // 80% matching type, 20% random + let abilityType = plantType; + if (Math.random() > 0.80) { + const types = ['flowers', 'vegetables', 'trees']; + abilityType = types[Math.floor(Math.random() * types.length)]; + } + + return this.createAbility(abilityType); + } +} +``` + +## Ability Manager + +```javascript +// js/systems/AbilityManager.js +export class AbilityManager { + constructor() { + this.equipped = []; + this.inventory = []; + this.maxSlots = 3; + this.maxInventory = 10; + } + + addAbility(ability) { + if (this.inventory.length < this.maxInventory) { + this.inventory.push(ability); + return true; + } + return false; + } + + equipAbility(ability) { + if (this.equipped.length >= this.maxSlots) { + return false; + } + + const index = this.inventory.indexOf(ability); + if (index > -1) { + this.inventory.splice(index, 1); + this.equipped.push(ability); + ability.equipped = true; + return true; + } + return false; + } +} +``` + +## File Structure After Phase 4 + +``` +vampire-survivor/js/ +├── entities/ +│ ├── abilities/ +│ │ ├── Ability.js +│ │ ├── flower/ +│ │ │ ├── FragrantBloom.js +│ │ │ ├── PollenBurst.js +│ │ │ ├── PetalShield.js +│ │ │ └── ButterflyWings.js +│ │ ├── vegetable/ +│ │ │ ├── NutrientAbsorption.js +│ │ │ ├── RapidGrowth.js +│ │ │ ├── GardenCat.js +│ │ │ └── VineTrap.js +│ │ └── tree/ +│ │ ├── BarkArmor.js +│ │ ├── TreantSprout.js +│ │ ├── SapTrap.js +│ │ └── BirdFrenzy.js +├── systems/ +│ ├── AbilityDropSystem.js +│ └── AbilityManager.js +├── ui/ +│ └── AbilityUI.js +└── ... +``` + +## Testing Checklist + +- [ ] Abilities drop from harvested plants +- [ ] Drop rate scales with fill level +- [ ] Abilities can be equipped/unequipped +- [ ] Passive effects apply correctly +- [ ] Active abilities trigger and go on cooldown +- [ ] UI shows equipped abilities + +## Dependencies + +- Phase 1-3 + +## Next Phase + +[Phase 5: Ability Scaling](./05-phase-aspect-scaling.md) diff --git a/plans/world-build-system/05-phase-aspect-scaling.md b/plans/world-build-system/05-phase-aspect-scaling.md new file mode 100644 index 0000000..a1445d4 --- /dev/null +++ b/plans/world-build-system/05-phase-aspect-scaling.md @@ -0,0 +1,122 @@ +# Phase 5: Ability Scaling + +## Overview + +Implement detailed garden focus scaling for abilities, including visual feedback when abilities are powered up and the pure garden bonus system. + +## Goals + +- [ ] Implement tiered scaling based on focus thresholds +- [ ] Add visual feedback for powered-up abilities +- [ ] Create pure garden bonus (80%+ focus) +- [ ] Add penalty system for off-type abilities +- [ ] Implement power indicators in UI + +## Scaling Tiers + +| Focus % | Matching Ability Bonus | Off-Type Penalty | +|---------|------------------------|------------------| +| 0-33% | 1.0x (base) | 1.0x | +| 34-59% | 1.25x | 0.9x | +| 60-79% | 1.5x | 0.75x | +| 80-100% | 2.0x (pure garden) | 0.5x | + +## Scaling System + +```javascript +// js/systems/AbilityScalingSystem.js +export class AbilityScalingSystem { + constructor(gardenFocusSystem) { + this.gardenFocusSystem = gardenFocusSystem; + + this.scalingTiers = [ + { threshold: 80, matchBonus: 2.0, offPenalty: 0.5 }, + { threshold: 60, matchBonus: 1.5, offPenalty: 0.75 }, + { threshold: 34, matchBonus: 1.25, offPenalty: 0.9 }, + { threshold: 0, matchBonus: 1.0, offPenalty: 1.0 } + ]; + } + + getScaleForAbility(ability) { + const focus = this.gardenFocusSystem.getFocus(); + const abilityType = ability.focusType; + const matchingPercent = focus[abilityType] || 33; + + const tier = this.scalingTiers.find(t => matchingPercent >= t.threshold); + + return { + multiplier: tier.matchBonus, + tier: this.getTierName(tier.threshold), + isPureGarden: tier.threshold >= 80 + }; + } + + getTierName(threshold) { + switch(threshold) { + case 80: return 'pure'; + case 60: return 'major'; + case 34: return 'minor'; + default: return 'base'; + } + } +} +``` + +## Visual Feedback + +### Ability Glow Effects + +| Tier | Visual Effect | +|------|---------------| +| Base | No glow | +| Minor | Subtle colored outline | +| Major | Pulsing glow | +| Pure | Bright glow + particle effects | + +### Pure Garden Notification + +When reaching 80% focus: +- Large notification: "PURE FLOWER GARDEN!" (or Vegetable/Tree) +- Screen flash in garden color +- Ability icons gain special border + +## Power Indicator UI + +```javascript +// Shows current ability power levels +drawPowerIndicator(ctx, x, y, focus) { + const barWidth = 100; + const barHeight = 8; + + // Flower power bar (pink) + ctx.fillStyle = '#ff88cc'; + ctx.fillRect(x, y, barWidth * (focus.flowers / 100), barHeight); + ctx.fillText(`🌸 ${this.getMultiplier('flowers')}x`, x + barWidth + 5, y + 7); + + // Vegetable power bar (green) + ctx.fillStyle = '#44aa44'; + ctx.fillRect(x, y + 12, barWidth * (focus.vegetables / 100), barHeight); + ctx.fillText(`🥕 ${this.getMultiplier('vegetables')}x`, x + barWidth + 5, y + 19); + + // Tree power bar (brown) + ctx.fillStyle = '#8B4513'; + ctx.fillRect(x, y + 24, barWidth * (focus.trees / 100), barHeight); + ctx.fillText(`🌳 ${this.getMultiplier('trees')}x`, x + barWidth + 5, y + 31); +} +``` + +## Testing Checklist + +- [ ] Abilities scale correctly at each threshold +- [ ] Off-type penalties apply when focus is high +- [ ] Visual glow effects show power level +- [ ] Pure garden notification triggers at 80% +- [ ] Power indicator UI updates smoothly + +## Dependencies + +- Phase 1-4 + +## Next Phase + +[Phase 6: Companion Planting](./06-phase-ecosystem.md) diff --git a/plans/world-build-system/06-phase-ecosystem.md b/plans/world-build-system/06-phase-ecosystem.md new file mode 100644 index 0000000..101f7a2 --- /dev/null +++ b/plans/world-build-system/06-phase-ecosystem.md @@ -0,0 +1,257 @@ +# Phase 6: Companion Planting (Ecosystem) + +## Overview + +Implement the companion planting system where plants near each other create beneficial effects, hybrid terrain features, and special plant varieties. + +## Goals + +- [ ] Implement plant proximity detection +- [ ] Create companion planting effects +- [ ] Add hybrid garden features (Pollinator Garden, Orchard, Food Forest) +- [ ] Create hybrid plant types +- [ ] Implement visual connections between companion plants + +## Companion Planting Concept + +In real gardening, certain plants grow better together. We'll use this concept: + +| Combination | Name | Effect | +|-------------|------|--------| +| Flower + Vegetable | **Pollinator Garden** | Bees boost both, healing + damage | +| Flower + Tree | **Orchard** | Fruit trees, beauty + structure | +| Vegetable + Tree | **Food Forest** | Sustainable harvest, defense + sustain | + +## Proximity Detection + +```javascript +// js/systems/CompanionPlantingSystem.js +export class CompanionPlantingSystem { + constructor(gameState) { + this.gameState = gameState; + this.companionRadius = 150; + this.connections = []; + this.hybridFeatures = []; + } + + update(deltaTime) { + this.updateConnections(); + this.checkForHybridSpawns(); + } + + updateConnections() { + this.connections = []; + const plants = this.gameState.plants; + + for (let i = 0; i < plants.length; i++) { + for (let j = i + 1; j < plants.length; j++) { + const p1 = plants[i]; + const p2 = plants[j]; + + if (p1.focusType === p2.focusType) continue; + + const dist = this.getDistance(p1, p2); + if (dist <= this.companionRadius) { + this.connections.push({ + from: p1, + to: p2, + types: [p1.focusType, p2.focusType].sort(), + strength: 1 - (dist / this.companionRadius) + }); + } + } + } + } +} +``` + +## Hybrid Garden Features + +### Pollinator Garden (Flowers + Vegetables) +- **Appearance**: Buzzing bees, colorful mixed plantings +- **Effect**: +25% to both flower and vegetable abilities, healing aura +- **Spawns**: Bee swarms that attack pests + +```javascript +// js/entities/terrain/hybrid/PollinatorGarden.js +export class PollinatorGarden extends GardenFeature { + constructor(x, y) { + super(x, y, 100); + this.hybridType = 'pollinator_garden'; + this.focusTypes = ['flowers', 'vegetables']; + + this.healPerSecond = 1; + this.damageBonus = 0.25; + this.bees = []; + } + + update(deltaTime, pests) { + // Bees attack nearby pests + for (const bee of this.bees) { + bee.update(deltaTime, pests); + } + + // Spawn new bees periodically + if (Math.random() < deltaTime * 0.5) { + this.spawnBee(); + } + } +} +``` + +### Orchard (Flowers + Trees) +- **Appearance**: Flowering fruit trees, blossoms falling +- **Effect**: Fruit drops heal player, beautiful barrier +- **Spawns**: Fruit that can be collected for health + +```javascript +// js/entities/terrain/hybrid/Orchard.js +export class Orchard extends GardenFeature { + constructor(x, y) { + super(x, y, 120); + this.hybridType = 'orchard'; + this.focusTypes = ['flowers', 'trees']; + + this.fruitDropInterval = 5; + this.fruitHealAmount = 5; + this.blossoms = []; + } +} +``` + +### Food Forest (Vegetables + Trees) +- **Appearance**: Layered garden with trees, shrubs, ground cover +- **Effect**: Sustainable harvest, regenerating walls +- **Spawns**: Living walls that regrow when damaged + +```javascript +// js/entities/terrain/hybrid/FoodForest.js +export class FoodForest extends GardenFeature { + constructor(x, y) { + super(x, y, 100); + this.hybridType = 'food_forest'; + this.focusTypes = ['vegetables', 'trees']; + + this.wallHealth = 50; + this.wallRegen = 2; // HP per second + this.harvestBonus = 1.5; + } +} +``` + +## Hybrid Plant Types + +### Sunflower (Flower + Vegetable hybrid) +- **Visual**: Tall yellow sunflower +- **Harvest**: Gives both flower and vegetable focus +- **Special**: Seeds can be planted for more sunflowers + +### Fruit Tree (Flower + Tree hybrid) +- **Visual**: Tree with blossoms and fruit +- **Harvest**: Gives both flower and tree focus +- **Special**: Drops fruit periodically + +### Berry Bush (Vegetable + Tree hybrid) +- **Visual**: Bushy shrub with berries +- **Harvest**: Gives both vegetable and tree focus +- **Special**: Berries heal player on contact + +## Visual Connections + +```javascript +// js/ui/CompanionVisuals.js +export class CompanionVisuals { + constructor(companionSystem) { + this.companionSystem = companionSystem; + this.pulsePhase = 0; + } + + draw(ctx, cameraX, cameraY) { + for (const conn of this.companionSystem.connections) { + this.drawConnection(ctx, conn, cameraX, cameraY); + } + } + + drawConnection(ctx, connection, cameraX, cameraY) { + const x1 = connection.from.x - cameraX; + const y1 = connection.from.y - cameraY; + const x2 = connection.to.x - cameraX; + const y2 = connection.to.y - cameraY; + + // Draw dotted line with hearts/bees/leaves + const color = this.getConnectionColor(connection.types); + ctx.strokeStyle = color; + ctx.setLineDash([5, 10]); + ctx.beginPath(); + ctx.moveTo(x1, y1); + ctx.lineTo(x2, y2); + ctx.stroke(); + ctx.setLineDash([]); + + // Draw companion icon at midpoint + const midX = (x1 + x2) / 2; + const midY = (y1 + y2) / 2; + this.drawCompanionIcon(ctx, midX, midY, connection.types); + } + + getConnectionColor(types) { + if (types.includes('flowers') && types.includes('vegetables')) { + return 'rgba(255, 200, 100, 0.6)'; // Golden (bees) + } else if (types.includes('flowers') && types.includes('trees')) { + return 'rgba(255, 180, 200, 0.6)'; // Pink (blossoms) + } else { + return 'rgba(100, 150, 100, 0.6)'; // Green (forest) + } + } + + drawCompanionIcon(ctx, x, y, types) { + // Draw bee, blossom, or leaf icon + if (types.includes('flowers') && types.includes('vegetables')) { + ctx.fillText('🐝', x - 8, y + 5); + } else if (types.includes('flowers') && types.includes('trees')) { + ctx.fillText('🌸', x - 8, y + 5); + } else { + ctx.fillText('🍃', x - 8, y + 5); + } + } +} +``` + +## File Structure After Phase 6 + +``` +vampire-survivor/js/ +├── entities/ +│ ├── plants/ +│ │ ├── hybrid/ +│ │ │ ├── Sunflower.js +│ │ │ ├── FruitTree.js +│ │ │ └── BerryBush.js +│ ├── terrain/ +│ │ ├── hybrid/ +│ │ │ ├── PollinatorGarden.js +│ │ │ ├── Orchard.js +│ │ │ └── FoodForest.js +├── systems/ +│ └── CompanionPlantingSystem.js +├── ui/ +│ └── CompanionVisuals.js +└── ... +``` + +## Testing Checklist + +- [ ] Connections form between nearby different-type plants +- [ ] Connection strength scales with distance +- [ ] Hybrid terrain spawns at connection midpoints +- [ ] Hybrid plants spawn from hybrid terrain +- [ ] Visual connections render correctly +- [ ] Companion icons animate along connections + +## Dependencies + +- Phase 1-5 + +## Next Phase + +[Phase 7: Dual Plot System](./07-phase-dual-map.md) diff --git a/plans/world-build-system/07-phase-dual-map.md b/plans/world-build-system/07-phase-dual-map.md new file mode 100644 index 0000000..20b1bfa --- /dev/null +++ b/plans/world-build-system/07-phase-dual-map.md @@ -0,0 +1,285 @@ +# Phase 7: Dual Plot System + +## Overview + +Implement the dual plot system with a Garden Plot for combat/defense and a Planning Mode for peaceful planting and ability management. + +## Goals + +- [ ] Create PlotManager for switching between modes +- [ ] Implement Planning Mode (paused pests, planting UI) +- [ ] Add seed planting system +- [ ] Create ability management UI for Planning Mode +- [ ] Implement mode transition effects +- [ ] Add pest distribution preview + +## Plot Manager + +```javascript +// js/systems/PlotManager.js +export class PlotManager { + constructor(gameState) { + this.gameState = gameState; + this.currentMode = 'garden'; // 'garden' or 'planning' + this.transitionProgress = 0; + this.isTransitioning = false; + } + + switchMode() { + if (this.isTransitioning) return; + + this.isTransitioning = true; + this.transitionProgress = 0; + this.targetMode = this.currentMode === 'garden' ? 'planning' : 'garden'; + } + + completeTransition() { + this.currentMode = this.targetMode; + this.isTransitioning = false; + + if (this.currentMode === 'planning') { + this.enterPlanningMode(); + } else { + this.enterGardenMode(); + } + } + + enterPlanningMode() { + // Pause pest AI + this.gameState.pestsPaused = true; + + // Show planting UI + this.gameState.showPlanningUI = true; + + // Enable seed placement + this.gameState.placementMode = true; + } + + enterGardenMode() { + // Resume pest AI + this.gameState.pestsPaused = false; + + // Hide planting UI + this.gameState.showPlanningUI = false; + + // Sync planted seeds + this.syncPlantedSeeds(); + } +} +``` + +## Seed Planting System + +```javascript +// js/systems/PlantingSystem.js +export class PlantingSystem { + constructor(gameState) { + this.gameState = gameState; + this.selectedSeedType = null; + this.placementPreview = null; + this.plantedSeeds = []; + } + + selectSeedType(type) { + this.selectedSeedType = type; + } + + updatePreview(mouseX, mouseY) { + if (!this.selectedSeedType) { + this.placementPreview = null; + return; + } + + this.placementPreview = { + x: mouseX, + y: mouseY, + type: this.selectedSeedType, + valid: this.isValidPlacement(mouseX, mouseY) + }; + } + + isValidPlacement(x, y) { + const minDistance = 80; + + // Check distance from existing plants + for (const plant of this.gameState.plants) { + const dist = Math.sqrt((plant.x - x) ** 2 + (plant.y - y) ** 2); + if (dist < minDistance) return false; + } + + return true; + } + + plantSeed(x, y) { + if (!this.selectedSeedType) return false; + if (!this.isValidPlacement(x, y)) return false; + + // Check seed inventory + const seedCount = this.gameState.seeds[this.selectedSeedType] || 0; + if (seedCount <= 0) return false; + + // Consume seed + this.gameState.seeds[this.selectedSeedType]--; + + // Create planted seed + const seed = { + x, y, + type: this.selectedSeedType, + plantedAt: Date.now(), + growthTime: 45 // seconds to mature + }; + + this.plantedSeeds.push(seed); + return true; + } +} +``` + +## Planning Mode UI + +```javascript +// js/ui/PlanningModeUI.js +export class PlanningModeUI { + constructor(gameState, abilityManager, plantingSystem) { + this.gameState = gameState; + this.abilityManager = abilityManager; + this.plantingSystem = plantingSystem; + } + + draw(ctx, canvasWidth, canvasHeight) { + // Peaceful overlay + ctx.fillStyle = 'rgba(200, 230, 200, 0.2)'; + ctx.fillRect(0, 0, canvasWidth, canvasHeight); + + // Draw panels + this.drawSeedPanel(ctx); + this.drawAbilityPanel(ctx); + this.drawFocusPanel(ctx); + this.drawPestPreviewPanel(ctx); + + // Mode indicator + this.drawModeIndicator(ctx, canvasWidth); + } + + drawSeedPanel(ctx) { + const x = 10, y = 100; + + ctx.fillStyle = 'rgba(20, 40, 20, 0.9)'; + ctx.fillRect(x, y, 180, 140); + + ctx.fillStyle = '#ffffff'; + ctx.font = 'bold 14px Arial'; + ctx.fillText('🌱 Seeds', x + 10, y + 20); + + // Seed buttons + const seeds = this.gameState.seeds; + let buttonY = y + 40; + + // Flower seeds + this.drawSeedButton(ctx, x + 10, buttonY, 'flowers', seeds.flowers || 0, '🌸'); + buttonY += 35; + + // Vegetable seeds + this.drawSeedButton(ctx, x + 10, buttonY, 'vegetables', seeds.vegetables || 0, '🥕'); + buttonY += 35; + + // Tree seeds + this.drawSeedButton(ctx, x + 10, buttonY, 'trees', seeds.trees || 0, '🌳'); + } + + drawSeedButton(ctx, x, y, type, count, emoji) { + const selected = this.plantingSystem.selectedSeedType === type; + + ctx.fillStyle = selected ? 'rgba(100, 150, 100, 0.8)' : 'rgba(50, 70, 50, 0.8)'; + ctx.fillRect(x, y, 160, 30); + + ctx.fillStyle = '#ffffff'; + ctx.font = '14px Arial'; + ctx.fillText(`${emoji} ${type}: ${count}`, x + 10, y + 20); + } + + drawModeIndicator(ctx, canvasWidth) { + ctx.fillStyle = 'rgba(50, 100, 50, 0.9)'; + ctx.fillRect(canvasWidth / 2 - 100, 10, 200, 40); + + ctx.fillStyle = '#ffffff'; + ctx.font = 'bold 18px Arial'; + ctx.textAlign = 'center'; + ctx.fillText('🌿 PLANNING MODE', canvasWidth / 2, 35); + ctx.textAlign = 'left'; + + ctx.font = '12px Arial'; + ctx.fillText('Press TAB to return to garden', canvasWidth / 2 - 75, 55); + } +} +``` + +## Mode Transition Effect + +```javascript +// js/ui/ModeTransition.js +export class ModeTransition { + constructor() { + this.progress = 0; + this.fromMode = null; + this.toMode = null; + } + + draw(ctx, canvasWidth, canvasHeight) { + if (this.progress <= 0) return; + + // Leaf swirl transition + const leafCount = 20; + const maxRadius = Math.max(canvasWidth, canvasHeight); + + for (let i = 0; i < leafCount; i++) { + const angle = (i / leafCount) * Math.PI * 2 + this.progress * 3; + const radius = maxRadius * this.progress * (0.5 + (i % 3) * 0.2); + + const x = canvasWidth / 2 + Math.cos(angle) * radius; + const y = canvasHeight / 2 + Math.sin(angle) * radius; + + ctx.font = '24px Arial'; + ctx.fillText('🍃', x, y); + } + + // Fade overlay + const alpha = Math.sin(this.progress * Math.PI) * 0.3; + ctx.fillStyle = this.toMode === 'planning' ? + `rgba(100, 150, 100, ${alpha})` : + `rgba(150, 100, 100, ${alpha})`; + ctx.fillRect(0, 0, canvasWidth, canvasHeight); + } +} +``` + +## File Structure After Phase 7 + +``` +vampire-survivor/js/ +├── systems/ +│ ├── PlotManager.js +│ └── PlantingSystem.js +├── ui/ +│ ├── PlanningModeUI.js +│ └── ModeTransition.js +└── ... +``` + +## Testing Checklist + +- [ ] Mode switching works with TAB key +- [ ] Transition effect plays smoothly +- [ ] Pests pause in Planning Mode +- [ ] Seeds can be selected and planted +- [ ] Invalid placements show red preview +- [ ] Planted seeds sync to Garden Mode +- [ ] Ability management works in Planning Mode + +## Dependencies + +- Phase 1-6 + +## Next Phase + +[Phase 8: Polish and Balance](./08-phase-polish.md) diff --git a/plans/world-build-system/08-phase-polish.md b/plans/world-build-system/08-phase-polish.md new file mode 100644 index 0000000..c17f2cc --- /dev/null +++ b/plans/world-build-system/08-phase-polish.md @@ -0,0 +1,194 @@ +# Phase 8: Polish and Balance + +## Overview + +Final phase focusing on hybrid abilities, visual polish, audio feedback, balance tuning, and overall game feel. + +## Goals + +- [ ] Implement hybrid Abilities (require mixed focus) +- [ ] Add visual effects polish (particles, screen effects) +- [ ] Implement audio feedback +- [ ] Balance pass on all systems +- [ ] Add tutorial hints +- [ ] Performance optimization + +## Hybrid Abilities + +### Pollinator's Gift (40% Flowers + 40% Vegetables) +- **Effect**: Bees heal you while attacking pests +- **Visual**: Golden bee swarm around player + +### Orchard Keeper (40% Flowers + 40% Trees) +- **Effect**: Fruit trees drop healing fruit automatically +- **Visual**: Falling blossoms and fruit + +### Forest Gardener (40% Vegetables + 40% Trees) +- **Effect**: Living walls regenerate and provide harvest bonus +- **Visual**: Vines and branches intertwining + +### Master Gardener (30% each) +- **Effect**: +15% bonus to all garden types +- **Visual**: Rainbow garden aura + +## Visual Effects + +### Particle Types + +| Effect | Trigger | Visual | +|--------|---------|--------| +| Petal Burst | Flower harvest | Pink petals floating | +| Leaf Scatter | Vegetable harvest | Green leaves spinning | +| Bark Chips | Tree harvest | Brown wood chips | +| Pollen Cloud | Flower ability | Yellow sparkles | +| Bee Swarm | Pollinator Garden | Buzzing golden dots | +| Falling Fruit | Orchard | Colorful fruit dropping | + +### Screen Effects + +| Effect | Trigger | Visual | +|--------|---------|--------| +| Garden Bloom | Pure garden achieved | Flash of garden color | +| Pest Swarm | Large pest wave | Screen shake | +| Harvest Glow | Successful harvest | Brief golden overlay | + +## Audio Feedback + +| Sound | Trigger | +|-------|---------| +| Gentle chime | Plant watered | +| Satisfying pop | Plant harvested | +| Buzzing | Bees active | +| Bird chirp | Bird house attack | +| Rustling leaves | Mode transition | +| Victory fanfare | Pure garden achieved | + +## Balance Configuration + +```javascript +// js/config/GardenBalanceConfig.js +export const GardenBalanceConfig = { + plants: { + fillRequired: 10, + harvestFocusGain: 5, + abilityDropRate: 0.20 + }, + + focus: { + thresholds: { + minor: 40, + major: 60, + pure: 80 + }, + bonuses: { + minor: 1.25, + major: 1.5, + pure: 2.0 + } + }, + + pests: { + baseSpawnRate: 2.0, + maxPests: 50, + resistanceMultiplier: 0.5, + weaknessMultiplier: 1.5 + }, + + terrain: { + pollenCloudSlow: 0.3, + compostHeal: 2, + rootNetworkSlow: 0.5, + birdHouseDamage: 2 + }, + + abilities: { + maxEquipped: 3, + maxInventory: 10, + hybridRequirement: 40 + } +}; +``` + +## Tutorial Hints + +| Hint | Trigger | +|------|---------| +| "Water plants to fill them, then harvest!" | First plant spawns | +| "Different plants attract different pests" | First pest spawns | +| "Press TAB for Planning Mode" | After first harvest | +| "Plant companions together for bonuses!" | Two different plants nearby | +| "Reach 80% focus for Pure Garden power!" | Focus reaches 60% | + +## Testing Checklist + +- [ ] Hybrid abilities activate at correct thresholds +- [ ] Particle effects enhance feedback +- [ ] Audio cues are clear and satisfying +- [ ] Tutorial hints appear at right times +- [ ] Game feels balanced and fun +- [ ] Performance stays smooth with many entities + +## Final File Structure + +``` +vampire-survivor/js/ +├── entities/ +│ ├── plants/ +│ │ ├── Plant.js +│ │ ├── FlowerBud.js +│ │ ├── VeggieSprout.js +│ │ ├── Sapling.js +│ │ └── hybrid/ +│ ├── pests/ +│ │ ├── Pest.js +│ │ ├── flower/ +│ │ ├── vegetable/ +│ │ └── tree/ +│ ├── terrain/ +│ │ ├── GardenFeature.js +│ │ ├── flower/ +│ │ ├── vegetable/ +│ │ ├── tree/ +│ │ └── hybrid/ +│ └── abilities/ +│ ├── Ability.js +│ ├── flower/ +│ ├── vegetable/ +│ ├── tree/ +│ └── hybrid/ +├── systems/ +│ ├── GardenFocusSystem.js +│ ├── PestSpawnSystem.js +│ ├── TerrainSystem.js +│ ├── AbilityManager.js +│ ├── AbilityScalingSystem.js +│ ├── CompanionPlantingSystem.js +│ ├── PlotManager.js +│ └── PlantingSystem.js +├── effects/ +│ ├── GardenParticles.js +│ └── ScreenEffects.js +├── audio/ +│ └── GardenAudio.js +├── ui/ +│ ├── GardenFocusUI.js +│ ├── AbilityUI.js +│ ├── PlanningModeUI.js +│ ├── CompanionVisuals.js +│ └── TutorialHints.js +└── config/ + └── GardenBalanceConfig.js +``` + +## Conclusion + +The Garden Defense System transforms the vampire-survivor gameplay into a charming gardening experience where: + +1. **Three plant types** (Flowers, Vegetables, Trees) create strategic choices +2. **Realistic pests** (Aphids, Rabbits, Beetles) provide thematic enemies +3. **Garden terrain** (Pollen clouds, Scarecrows, Bird houses) adds tactical depth +4. **Gardener abilities** scale with garden focus for build diversity +5. **Companion planting** rewards thoughtful plant placement +6. **Dual plot system** provides peaceful planning alongside action + +The 8-phase implementation allows incremental development while maintaining a playable, cohesive garden defense game.