# CSI World — Browser Game Design

> Brainstorming document. Not final. To be refined iteratively.

---

## Concept

A semi-MMO browser RPG set in the CSI universe. Players share a persistent world with a common economy, market, and map — but never interact in real time. The experience is fully asynchronous: you take actions, leave, come back, see the results.

Think Kingdom of Loathing or Torn City in feel, but with the CSI aesthetic and combat system.

---

## Characters

### Player's roster
The player builds and manages a collection of characters, Pokémon-style. Each character belongs to the player and is distinct from the others.

**At creation:**
- Name (chosen by player)
- Appearance (likely from a set of options — sprites, portraits)
- Class (chosen once, defines the character's identity and stat growth)

**Over time:**
- Level (gained through combat and activities)
- Equipment (weapons, armors, accessories — drawn from the existing item system)
- Spells / active skills
- Passives
- Individual stats that scale with level and class

**Class design questions to answer:**
- How many classes? What archetypes (tank, mage, rogue, healer...)?
- Do classes restrict equipment like the existing `usableWeapons` / `usableArmors` on Character entities?
- Can a character reclass later, or is the choice permanent?
- Do classes have distinct progression trees, or just different stat growth curves?

### Premium characters
Some characters can be made available temporarily through premium services or events — pre-built with fixed names, appearances, classes and starting stats. They slot into the player's roster like any other character but can't be reconfigured from scratch.

This is a good monetisation/event hook without being pay-to-win if balanced correctly (cosmetic identity, not necessarily stronger).

---

## World

### Shared but asynchronous
All players operate in the same world. This means:
- A shared **market / economy** where players list and buy items
- Shared **enemy spawns** on the map (an enemy instance killed by one player is gone for others)
- Shared **events** that affect everyone (a time-limited zone opens, a raid boss appears)
- **Leaderboards** that rank players globally

Players never see each other in real time — no live avatars, no chat (or chat is purely a separate forum-style layer). The shared world is felt through the economy and competitive structures, not through synchronous play.

### Time as a game mechanic
Time gates what's available, adding rhythm and reason to return:
- **Enemy spawns:** certain enemies or spawn rates change by time of day or day of week
- **Shop stock:** vendors rotate their inventory (daily reset, weekly specials)
- **Events:** limited-time map zones, seasonal bosses, double-drop weekends
- **Raid windows:** raids open for a fixed time period, then close regardless of completion

This also naturally limits grinding without needing an explicit energy/stamina system — though stamina is worth considering (see below).

**Open question:** Is there a stamina / action point system?  
A finite resource that refills over time (e.g. 100 AP, each combat costs 10, +5/hour) prevents one player from trivially clearing the entire map in an afternoon and keeps daily check-ins meaningful. Without it, progression needs another brake.

---

## Map

### Adventure interface
A large PNG map of the CSI world with clickable zones. Implementation-wise: an `<img>` with an HTML `<map>` overlay (or a `<div>` with absolutely-positioned hotspot buttons).

Each zone can have:
- A type (town, dungeon, raid zone, field, event area)
- State (unlocked / locked / cleared / active event)
- Available enemies, shops, or interactions based on current time and player progress
- A visual state indicator (color overlay, icon badge) to communicate what's there without clicking

**Open questions:**
- Is the map the same for all players (one shared map), or does each player have their own progression state over the same map?
- Do zones require prerequisite zones to unlock (linear path), or is the map open from the start?
- Are there separate maps per game (CSI Forever zone, CSII Forever zone, Narval Souls zone)?

---

## Combat

### Flow (PPBO-inspired)
1. Player clicks on an enemy instance visible on the map
2. A prompt appears: enemy name, rough power level, potential loot — **fight or flee**
3. Player confirms → POST request sent → server resolves the combat instantly
4. Page reloads (or AJAX response) → result screen: turn-by-turn log, loot gained, XP, outcome

This is the right model for a browser game. No real-time engine needed. The result is fully deterministic given the inputs (or seeded random), computed server-side, then displayed.

### Combat resolution (server-side)
The existing formula system on skills (`a.atk * 4 - b.def * 2`) is a strong base. A full combat round would:
1. Determine turn order (vitesse stat)
2. Each unit acts: use a skill (AI-driven for enemies, auto-selected or queue-selected for player characters)
3. Apply damage, status effects, heals
4. Repeat until one side is down or max turns reached
5. Return a structured log of every action

**Open questions:**
- Does the player control their team's skill selection before combat, or is it fully automatic?
- How does a team of multiple player characters work — turn-based round robin, or a formation/role system?
- Are there flee mechanics (chance-based? always succeeds? costs something)?

### Enemy instances
Enemies on the map should be instanced per-player or shared:
- **Per-player:** each player sees the same spawns but fights their own copy → no competition over enemies, simpler
- **Shared:** enemy is a world object, first player to engage locks it, others must wait → creates scarcity and urgency, more MMO-like but more complex

Given the semi-MMO framing and the difficulty of coordinating shared instances in an async game, **per-player instances** are likely the right starting point.

---

## PvP

### Concept
Players don't fight each other live. Instead, PvP is **asynchronous challenge-based**:
- A player challenges another player's team (which is treated as an AI-controlled opponent)
- The server resolves the fight using the defender's stats and last-known team composition
- Result goes to both players (attacker sees result immediately, defender sees it in a log/notification)

### Stakes and rewards
- **Leaderboards:** ranked by PvP wins, points earned, or a season-based rating
- **Prizes:** top-ranked players at season end receive exclusive equipment, cosmetics, or premium characters
- **Challenges per day:** PvP attempts are limited (stamina-gated or a separate PvP token system) to prevent farming weak players

### Open questions:
- Is PvP opt-in or mandatory? Can a player shield themselves from challenges?
- How are matchups determined — free pick, rating-matched, or bracket-based?
- Does losing PvP have consequences (lost items, rating drop only)?

---

## Raids

### Concept
Raid bosses are extremely powerful enemies with multi-phase combat, available for a limited time window. They are not per-player — they are **shared world encounters** where multiple players contribute damage.

Possible model:
- A raid boss spawns with a large HP pool shared across all participants
- Each player attacks independently (their contribution is logged)
- When the boss's HP reaches zero (from accumulated player damage), it is defeated for everyone
- Loot is distributed based on contribution percentage or a lottery weighted by contribution

### Rewards
- Rare equipment not available anywhere else
- Exclusive cosmetics, titles, or avatar frames
- Raid-specific currency exchangeable at a special vendor

### Open questions:
- How is contribution tracked and rewarded fairly?
- What prevents a single high-level player from monopolising raid loot?
- Are there coordination mechanics (different players filling tank/dps/healer roles), or is it pure individual DPS?

---

## Economy and Market

### Player-to-player market
A shared auction house / bazaar where players list equipment, materials, or consumables for in-game currency. Other players buy at listed price or make offers.

Currencies to define:
- **Primary currency** (earned through all activities — combat, quests, events)
- **Premium currency** (bought with real money or earned through very hard content — for cosmetics and premium characters only, not power)
- **Raid currency** (earned only in raids — for rare gear at a special shop)
- **PvP currency** (earned through ranked PvP — for exclusive competitive rewards)

Keeping currencies siloed prevents the economy from collapsing and gives each activity type its own reward structure.

### Open questions:
- Is there a tax on market transactions (gold sink)?
- Can premium characters or cosmetics be traded between players?
- Is there crafting (combining materials into equipment)?

---

## Progression Loop — Draft

```
Log in
  → Check time-gated content (new shop stock? event active? raid window open?)
  → Go to map
      → Explore zones (enemies, shops, events)
      → Fight enemies → gain XP, loot, primary currency
      → Level up characters → unlock skills, stats improve
      → Equip loot → stronger team
  → Visit market → sell surplus loot, buy missing pieces
  → Challenge a PvP opponent → climb leaderboard
  → Participate in active raid → contribute damage → earn rare loot
  → Check back tomorrow for new spawns / event / shop rotation
```

The loop needs a **medium-term goal** beyond daily activities: a story-gated progression (unlock new map zones by completing chapters), a gear score target (hit a threshold to enter a raid tier), or a collection goal (complete the character roster).

---

## Technical Notes (for later)

- Combat resolution is a pure PHP function given two teams and a random seed — easy to unit test
- Enemy spawns and shop stock can be seeded by `date('Ymd')` for daily rotation without storing state
- Raid HP is a shared counter — needs a DB row with optimistic locking to handle concurrent hits
- Market is a standard listings table (seller, item, quantity, price, expires_at)
- PvP challenge log is an append-only table (challenger, defender, result, timestamp)
- All time-based content needs server time as the canonical clock, not client time

---

## Open Questions Summary

1. Is there a stamina / action point system?
- No, each character loses an amount of HP after each battle depending on the result and passives
2. Is the map shared or per-player progression?
- each player's progression is independant on other players
3. Is the map one world or split by CSI game universe?
- this is a spin-off game, so it's in the same universe as a standalone game
4. Per-player or shared enemy instances?
- will depend on areas, but let's make it per-player for now
5. How many classes, and how different are they mechanically?
- around 8 basic classes the player chooses from when creating a character. each of those basic classes splits into two possible choice at a certain level - and 8 more advanced unlockable classes
6. Does the player control skill selection before/during combat?
- yes, although combat isn't officially defined now
7. Is PvP opt-in?
No, there are dedicated PvP services and areas
8. How is raid loot distributed?
- taken from a random pool per player
9. Is there crafting?
- yes, everything else is gatherable/purchasable
10. What is the medium-term progression goal that anchors the loop?
- reaching the endgame by getting higher and higher gear, getting rich to buy exclusive items or trade them for a real life goodies/advantages (titles, etc...), leaderboards
