# KING: Archipelago - User Manual

## 🏝️ Game Overview

**KING: Archipelago** is a strategic multiplayer game where you govern an island nation for 8 years, balancing economic growth with environmental protection. You'll compete with other island rulers in a shared ecosystem where your decisions affect not only your own island but the entire archipelago.

Your goal is to survive your 8-year term while achieving the highest score through wise governance that balances citizen welfare, economic prosperity, and environmental stewardship.

---

## 🎮 Getting Started

### Game Modes

**Local Multiplayer** (2-4 players)
- Play with friends on the same computer
- Players take turns on one device
- No internet connection required

**Online Multiplayer** (2-4 players)
- Play with friends across different computers
- Real-time chat and simultaneous play
- Requires internet connection and signaling server

### Setting Up a Game

#### Local Multiplayer:
1. Click "Local Multiplayer" from the main menu
2. Add 2-4 players (human or AI)
3. Choose names and colors for each player
4. Click "Start Game"

#### Online Multiplayer:
1. **To Host**: Click "Host Online Game"
   - Share the 4-letter room code with other players
   - Wait for players to join
   - Click "Start Game Setup" when ready

2. **To Join**: Click "Join Online Game"
   - Enter the room code provided by the host
   - Wait for the host to start setup

---

## 📊 Understanding Your Island

### Island Statistics

**Treasury**: Your government's money (measured in R - Resources)
- Used for all government expenditures
- Earned through industry, crops, and tourism
- Must stay above zero or your government collapses

**Citizens**: Your island's population
- Need 100R per citizen each year to survive
- Insufficient funding causes starvation and death
- More citizens can work more land but require more resources

**Land**: Your island's territory
- **Farmland**: Used for growing crops
- **Forest Land**: Provides tourism income and environmental benefits
- Can be sold to industries for immediate income

### Environmental Health

**Air Quality** (0-100%)
- Affected by industrial pollution
- Influences citizen health and tourism

**Water Quality** (0-100%)
- Affected by industrial runoff
- Impacts crop yields and citizen health

**Soil Quality** (0-100%)
- Affects crop productivity
- Degraded by intensive farming

**Biodiversity** (0-100%)
- Represents wildlife health
- Affects pollination and ecosystem stability

**Wildlife Population**
- **Fish**: Affected by shared ocean health
- **Birds, Mammals, Pollinators**: Support ecosystem functions

---

## 🏭 Making Decisions Each Year

Every year, you must make several key decisions for your island:

### 1. Industrial Development
**Sell Land to Industry** - Convert farmland to industrial use

**Mining** (High profit, high pollution)
- Income: 150% of land price
- Heavy environmental damage to air, water, and soil
- Attracts foreign workers

**Factory** (Very high profit, very high pollution)
- Income: 200% of land price
- Severe pollution across all categories
- High worker demand

**Logging** (Moderate profit, moderate impact)
- Income: 100% of land price
- Moderate environmental impact
- Some worker attraction

**Eco-tourism** (Lower profit, minimal impact)
- Income: 80% of land price
- Minimal environmental damage
- Sustainable income source

### 2. Citizen Welfare
**Distribute Money to Citizens**
- Citizens need 100R each to survive
- Insufficient funding causes starvation deaths
- Excess funding improves citizen satisfaction

### 3. Agriculture
**Plant Crops** - Convert farmland to active farming

**Crop Types:**
- **Traditional**: Standard yield and environmental impact
- **Organic**: 20% lower yield but improves soil quality
- **Intensive**: 30% higher yield but damages soil

**Factors affecting crop yield:**
- Soil quality
- Pollinator population
- Weather patterns
- Available workers (citizens)

### 4. Environmental Protection
**Environmental Spending** - Investment in pollution control
- Improves air quality, water quality, and biodiversity
- Higher spending = greater improvement
- Essential for long-term sustainability

### 5. Trade & Cooperation
**Sell Fishing Rights** - Generate income from shared fish stocks
- 500R per 100 fish sold
- Reduces shared fish population
- Affects other islands

**Carbon Offset Agreements** - Reduce global warming
- Costs money but reduces global temperature
- Benefits all islands in the archipelago

---

## 🌊 Shared Environment

All islands exist in a connected ecosystem:

### Ocean Health (0-100%)
- Affects fish populations for all islands
- Damaged by industrial pollution from any island
- Slowly recovers over time

### Fish Stocks
- Shared resource among all islands
- Depleted by overfishing
- Supports island economies and wildlife

### Global Temperature
- Increased by industrial activity from all islands
- Affects weather patterns and crop yields
- Can be reduced through carbon offset agreements

### Pollution Drift
- Air pollution spreads between neighboring islands
- Your industrial decisions affect other players
- Creates strategic interdependence

---

## 💰 Economics and Income

### Income Sources

**Industry** - Immediate large income from land sales
- One-time payment when land is sold
- Ongoing economic activity
- Attracts foreign workers

**Agriculture** - Sustainable annual income
- Income varies based on yield and market prices
- Affected by environmental conditions
- Requires annual replanting investment

**Tourism** - Passive income based on environment
- Higher income with better air/water quality
- Depends on forest land and natural beauty
- Sustainable but lower than industry

### Managing Finances

**Annual Costs:**
- Citizen support (100R per citizen minimum)
- Crop planting (varies by land and type)
- Environmental protection (optional but recommended)

**Economic Strategy Tips:**
- Balance immediate income (industry) with long-term sustainability
- Don't neglect citizen welfare - dead citizens can't work
- Environmental protection is an investment in future productivity

---

## 🏆 Winning and Scoring

### Game End Conditions
The game ends when:
- 8 years have passed, OR
- Only one player remains alive

### Victory Conditions
**Survival** - Keep your government functioning
- Citizens > 0
- Treasury ≥ 0
- Foreign workers < citizen population

**Score Calculation** (for surviving players)
- **Citizens × 10**: Reward for population management
- **Treasury ÷ 100**: Reward for financial success  
- **Environmental Score × 50**: Reward for sustainability

Environmental Score = Average of (Air + Water + Biodiversity + Soil Quality) ÷ 4

**Highest total score wins!**

---

## 🤖 AI Players

The game includes 4 AI personality types:

**Balanced** - Moderate approach to all aspects
- Balances growth with environmental concerns
- Makes steady, conservative decisions
- Good for learning game mechanics

**Industrialist** - Prioritizes economic growth
- Sells lots of land to high-profit industries
- Minimal environmental protection
- High risk, high reward strategy

**Environmentalist** - Protects nature above all
- Minimal industrial development
- Heavy environmental protection spending
- Sustainable but potentially low-growth strategy

**Aggressive** - High risk, high reward
- Makes dramatic, risky decisions
- Unpredictable strategy changes
- Can achieve great success or spectacular failure

---

## 💬 Online Features

### Real-time Chat
- Available during setup and gameplay in online mode
- Click the "💬 Game Chat" icon to expand
- Coordinate strategies or negotiate with other players

### Reconnection
- Game automatically saves your progress in online mode
- If disconnected, the game will offer to reconnect you
- Saved games expire after 24 hours

### Page Protection
- Browser warns before accidentally leaving during a game
- Prevents loss of progress from accidental refresh/close

---

## 🎯 Strategy Tips

### Early Game (Years 1-3)
- **Secure Basics**: Ensure citizen survival and basic income
- **Selective Industry**: Choose industries carefully - location and type matter
- **Build Foundation**: Some environmental protection prevents later crises

### Mid Game (Years 4-6)
- **Balance Growth**: Expand economy while managing environmental impact
- **Monitor Shared Resources**: Watch ocean health and fish stocks
- **Respond to Crises**: Address pollution or citizen welfare issues

### Late Game (Years 7-8)
- **Survival Focus**: Ensure you can meet citizen needs
- **Score Optimization**: Balance final score components
- **Defensive Play**: Avoid risky moves that could end your government

### Advanced Strategies

**Economic Strategies:**
- **Industrial Rush**: Quick land sales for immediate wealth, invest heavily in citizen welfare
- **Sustainable Growth**: Eco-tourism and organic farming for long-term stability
- **Mixed Economy**: Balance different income sources to reduce risk

**Environmental Strategies:**
- **Green Leadership**: High environmental spending for long-term score benefits
- **Pollution Haven**: Accept environmental damage for economic gain
- **Adaptive Management**: Adjust environmental spending based on shared ecosystem health

**Social Strategies:**
- **Population Growth**: Maintain high citizen count for score multiplication
- **Efficient Governance**: Minimize citizen support while avoiding deaths
- **Worker Management**: Balance citizens vs foreign workers carefully

---

## 🚫 Common Mistakes to Avoid

1. **Ignoring Citizens**: Not providing enough support leads to mass deaths
2. **Treasury Mismanagement**: Spending all money early can cause bankruptcy
3. **Environmental Neglect**: Pollution accumulates and reduces future productivity
4. **Overexpansion**: Selling too much farmland reduces crop income potential
5. **Isolation**: Ignoring shared resources affects long-term sustainability
6. **Short-term Thinking**: Focusing only on immediate gains vs long-term survival

---

## 🔧 Technical Notes

### System Requirements
- Modern web browser (Chrome, Firefox, Safari, Edge)
- For online multiplayer: Internet connection
- For hosting: Node.js server running on port 8081

### Controls
- **Mouse/Touch**: Navigate menus and make decisions
- **Enter**: Send chat messages
- **F12**: Open browser console for debugging

### Troubleshooting
- **Connection Issues**: Check that signaling server is running
- **Game Not Loading**: Check browser console for JavaScript errors
- **Missing Features**: Ensure you're using a modern browser
- **Reconnection Problems**: Room codes expire after 24 hours
