Project "Wasteland Conquest": Complete Status, Action Plan, and Knowledge Base
Document Purpose: This document serves as a complete and detailed project brief for the ongoing development of the "Wasteland Conquest" browser-based game. It is intended to be used by an AI assistant to understand the project's current state, its unresolved issues, and the full scope of planned features.

Core Development Rules: The developer (user) has established the following strict rules for the AI assistant:

No Apologies: Do not apologize for errors. Acknowledge the error and provide the corrected path forward.

Be Direct and Precise: Avoid conversational filler. Instructions and explanations must be clear, direct, and unambiguous.

Debug Before Sending: All proposed code changes must be mentally debugged against the current, known state of the code. The assistant must verify that the proposed change will work and will not introduce new bugs.

Follow Instructions Exactly: Adhere strictly to the developer's instructions regarding the scope and format of the response (e.g., "don't send code yet," "show me the snippet," "explain the workflow").

One Step at a Time: Unless explicitly asked for a full code block, all changes should be proposed as small, incremental, and clearly explained steps.

Part 1: Immediate Task - The Critical Bug
1.1. The Bug:
The game's visual theme (grainy overlay, desaturated colors, scanlines) fails to apply correctly when a game is initiated using a preset where the "Faction Perks" mechanic is disabled (e.g., "Classic Conquest," "Apocalypse Now"). This results in a map with bright, vibrant, unfiltered colors. Presets where "Faction Perks" are enabled display the correct, grainy, atmospheric theme.

1.2. The Root Cause (Confirmed):
The bug originates in the game's boot menu JavaScript. The code that applies the visual theme (document.body.classList.add(...)) is unintentionally and incorrectly linked to the logic that handles the "Faction Perks" system.

When Perks are ON: A code path is executed that involves populating the faction dropdown menu. This path inadvertently triggers the theme application logic as a side-effect.

When Perks are OFF: This code path is never executed. Consequently, the theme application logic is never called, and the theme's CSS class is not added to the webpage's <body> element.

1.3. The Objective:
To decouple the visual theme system from the game mechanics system. The visual theme should be determined only by the "Loaded Holotape (Theme)" dropdown on the boot menu and must be applied consistently at the start of every game, regardless of which game mode preset or custom mechanics are selected.

Part 2: Master Feature Roadmap & Implementation Status
This is the complete list of all planned features and their current development status.

✅ Boot Screen Overhaul: Complete.

Current State: The original grid of checkboxes has been successfully replaced with a "Game Mode" preset dropdown. This system includes a dynamic description box for presets and a "Custom Ruleset" option that reveals the checkboxes for manual selection. Special logic for "Alliance Warfare" (read-only faction input) is also implemented.

Remaining Work: None. This feature is functionally complete, pending the resolution of the critical bug detailed in Part 1.

✅ Inventory & Item System: Complete.

Current State: The bobbleheads and stimpaks systems are fully coded. All functions for rendering the inventory UI (renderInventory), activating items (activateBobblehead, useStimpak), and handling cooldowns are present and functional.

✅ Fog of War System (Map Layer): Complete.

Current State: The Gamestate.updateInfo function correctly calculates territory visibility based on player ownership, allied status (Idolized reputation), and the active state of the Perception Bobblehead. It correctly adds/removes the .fog-shroud CSS class.

✅ Intelligence Blackout (Leaderboard): Complete.

Current State: The leaderboard UI logic within Gamestate.updateInfo correctly hides or reveals enemy army, supply, and Bottle Cap counts based on the Fog of War visibility rules and the active state of the Intelligence Bobblehead.

🚧 Faction Perks: Partially Implemented.

Current State: The core data object (FACTIONS) defining each perk is complete. Many passive perks (e.g., NCR's logistical_superiority, BoS's power_armor_infantry) are already integrated into the game logic and function correctly.

Implementation Plan:

Add Perk UI: A new UI element (a dedicated "Perk Action" button) needs to be added to the main player panel.

Control Logic: The Gamestate.updateInfo function must be modified to show/hide this button and change its text/function based on the player's active perk (e.g., show "Mercenary Contract" for Gunners).

Implement Active Perks: Implement the specific front-end onclick functions for perks that require player activation, such as The Gunners' "Mercenary Contracts" and the Mojave Brotherhood's "Elder's Edict."

🚧 Wasteland Economy: Partially Implemented.

Current State: The system is flag-activated by the wastelandEconomyActive variable. Player caps are initialized. The showRecruitmentModal function exists but is not fully integrated.

Implementation Plan:

Integrate Recruitment Modal: Modify the Gamestate.aiMove function. After a player's turn begins and income is calculated, the game must await a call to this.showRecruitmentModal() before proceeding to the "Fortify" phase.

Link UI Button: The main UI button (view-cards-btn) needs its onclick event handler changed when the economy is active. It should call this.showRecruitmentModal() instead of opening the card stash.

Convert AI Rewards: Modify the AI's turn logic. When an AI player would normally receive a card after a conquest, they should instead receive a set amount of raw Caps (e.g., 5-10 Caps). This prevents the AI from accumulating useless cards and allows them to participate in the economy.

🚧 Dynamic Map Encounters: Partially Implemented.

Current State: Creature encounters are functional via resolveCreatureEncounter. The trigger check at the start of a turn (triggerEncounterCheck('start_of_turn')) works.

Implementation Plan:

Implement Story Templates: Create a new function, resolveStoryEncounter(), that uses the data from the encounterData object (locations, people, containers) to generate small narrative events with choices.

Implement New Triggers: Expand the triggerEncounterCheck(triggerType) function. Add logic to handle a post_conquest trigger type, which will have a chance to call resolveStoryEncounter(). Add another check for when a player enters a territory containing a Vault, which will trigger a unique Vault-specific encounter.

🚧 Expanded Diplomacy & Reputation: Partially Implemented.

Current State: The core data structures for reputation, truces, and grudges exist. The player can initiate trades.

Implementation Plan:

AI Diplomacy AI: Create a new function, Gamestate.aiDiplomacy(player), that runs during each AI's turn. This function will make the AI evaluate its reputation with other factions. If it is Hostile towards a weak neighbor, it will be more likely to attack. If it is Liked/Idolized by a strong neighbor, it may choose to avoid conflict.

AI-Initiated Trades: Within aiDiplomacy, add a small chance for an AI to initiate a trade or truce offer with the human player if their reputation is Neutral or higher.

🔲 Multi-Page Terminal Manual: Not Started.

Implementation Plan:

Redesign the #help-modal HTML to include a tab navigation bar ("Basics," "Perks," "Economy," etc.).

Create separate div containers for the content of each page.

Write JavaScript to show/hide the content divs when the corresponding tab is clicked.

🔲 Faction Commander Icons: Not Started.

Implementation Plan:

Modify the leaderboard logic within Gamestate.updateInfo.

When generating the HTML for each player's info box, add a condition to check if Commanders are enabled.

If they are, add a <span> element next to the Commander's name that will serve as the icon container. A simple star (★) can be used as a placeholder.

🔲 Mission Objective Screen: Not Started.

Implementation Plan:

Design and add a new hidden modal (#missions-modal) to the HTML.

Create a new JavaScript object to store potential objectives (e.g., { id: 'conquer_europe', text: 'Conquer all of Europe', reward: 50 }).

At the start of the game, randomly select 1-3 objectives and display them in the missions modal.

Create a new function, checkObjectiveCompletion(), that runs at the end of each player's turn to see if any objective conditions have been met.

Part 4: Game Data & Asset Catalogue
This is the complete list of data variables available for use in game logic, primarily for the Dynamic Encounters system, as defined in 3.txt. This data is essential for generating narrative events, creature attacks, and location-based scenarios.

Creatures (and their associated Threat Level):

Centaur (Threat: 10.0)

Deathclaw (Threat: 15.0)

Enclave Deathclaw (Threat: 20.0)

Feral Ghoul (Threat: 1.2)

Feral Ghoul Reaver (Threat: 12.0)

Feral Ghoul Roamer (Threat: 6.0)

Fire Ant Soldier (Threat: 3.5)

Fire Ant Warrior (Threat: 4.5)

Giant Ant (Threat: 1.5)

Giant Radscorpion (Threat: 7.0)

Giant Soldier Ant (Threat: 3.0)

Giant Worker Ant (Threat: 2.0)

Guard Dog (Threat: 4.0)

Mirelurk (Threat: 5.0)

Mirelurk Hunter (Threat: 8.0)

Mole Rat (Threat: 0.3)

Radroach (Threat: 0.5)

Radscorpion (Threat: 2.5)

Savage Dog (Threat: 0.1)

Scavenger's Dog (Threat: 1.8)

Super Mutant (Threat: 25.0)

Super Mutant Behemoth (Threat: 50.0)

Super Mutant Master (Threat: 30.0)

Super Mutant Overlord (Threat: 40.0)

Vicious Dog (Threat: 9.0)

Yao Guai (Threat: 1.0)

Bloatfly (Threat: 0.4)

Generic Locations (for random encounters):

a Broadcasting Tower

a crashed Vertibird

a collapsed metro tunnel

a flooded sewer system

a ruined church

a ruined highway overpass

an Abandoned Shack

an abandoned drive-in theater

an abandoned Red Rocket station

a Pre-War police station

Sub-Locations (rooms/areas within the above locations):

a hidden Refrigerator

a locked Safe

the cockpit

the evidence locker

the main server room

the manager's office

the pharmacy counter

the projection booth

the sacristy

the underground pump station

People (NPCs for encounters):

a Brotherhood of Steel scribe

a Drunken Drifter

a Fugitive Slave

a Ghoul scavenger

a Lost Farmer

a Merchant

a Mister Handy

a scared Settler

a shifty-eyed Mercenary

a Wasteland Doctor

a Wounded Sheriff

Talon Company Mercs

Containers (for loot-based events):

a doctor's bag

a footlocker

a first aid box

a locked safe

a steamer trunk

a weapons locker

an ammo box

Named Locations (with specific possible sub-locations or people):

C.I.T. Ruins: Can contain an escaped Synth or the main server room.

Diner: Can contain a Mister Handy or a Drunken Drifter.

Gas Station: Can contain abandoned Red Rocket station or a hidden Refrigerator.

Gwinnett Brewery: Can contain a Mister Handy or a Drunken Drifter.

Hubris Comics Store: Can contain a Ghoul scavenger.

Robot Factory: Can contain an escaped Synth or the main server room.

Slave Camp: Can contain Fugitive Slave or shifty-eyed Mercenary.

Super Duper Mart: Can contain the pharmacy counter, the manager's office, or a locked safe.

Water Treatment Plant: Can contain the underground pump station or a locked safe.

Vaults (and their associated map territory):

Vault 3: (central_america)

Vault 13: (western_us)

Vault 15: (alberta)

Vault 21: (central_america)

Vault 34: (central_america)

Vault 77: (ural)

Vault 81: (quebec)

Vault 95: (quebec)

Vault 101: (eastern_us)

Vault 111: (quebec)

Vault 112: (ontario)

Vault 114: (quebec)

Vault 118: (china)tem.