Public
Fantasy MUD with web GUI, APIs, and extensible world
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

⚔️ Fantasy MUD - Multiplayer Text Adventure

A browser-based fantasy MUD (Multi-User Dungeon) with a web GUI and authenticated REST API for 3rd party clients. Built on Val Town with SQLite for easy modding and extension.

🎮 Features

World

  • 8 continents with unique climates and cultures (Aetheria, Drak'thor, Silverwood, Irondeep, Mistral Isles, Shadowmere, Solaria, Frostheim)
  • 120+ countries with diverse governments, economies, laws, traditions, and lore
  • 60+ islands (inhabited and uninhabited) + 35 island city-states
  • 50+ wilderness areas across all continents
  • Seasons & calendar (Spring, Summer, Autumn, Winter with 28-day seasons)

Characters & Races

  • 20 races: Human, Elf, Dwarf, Halfling, Orc, Dark Elf, Beastkin, Dragonborn, Demon, Angel, Fairy, Vampire, Werewolf, Goblin, Slime, Merfolk, Giant, Spirit, Golem, Undead
  • 15 classes: Warrior, Mage, Ranger, Rogue, Cleric, Paladin, Necromancer, Bard, Monk, Summoner, Berserker, Alchemist, Farmer, Merchant, Knight
  • Detailed stats: STR, DEX, INT, WIS, CON, CHA, LUK

Magic System (Morrowind-inspired)

  • 12 schools: Destruction, Restoration, Alteration, Conjuration, Illusion, Mysticism, Enchanting, Necromancy, Nature Magic, Blood Magic, Divination, Rune Magic
  • 20+ spells with MP costs, damage, healing, range, and cooldowns

Combat

  • Melee: Swords, axes, daggers, unarmed, warhammers, spears
  • Ranged: Bows, crossbows, throwing stars, throwing daggers
  • Magic: Spells from all 12 schools
  • 12 combat skills with leveling and proficiency

Life Simulation (Stardew Valley / Rune Factory inspired)

  • Farming: Plant seeds, water crops, harvest by season
  • Housing: Buy and build houses, camps, villages, towns
  • Relationships: Friendship, affection, romance, marriage, gift-giving
  • Children: With age-up consent system
  • Content toggles: Configurable per race, age group, sentience for romance/marriage/trading

Economy & Trade

  • Per-country currencies with exchange rates
  • Shops with buy/sell modifiers
  • Player-to-player trading with barter system
  • Import/export trade routes between countries

Guilds & Schools

  • 10+ guilds: Adventure, Trade, Warrior, Mage, Thief, Farming, Fishing, Monster Hunter
  • Hierarchy: Novice → Apprentice → Journeyman → Expert → Master → Grandmaster
  • 8+ schools: Magic academies, combat schools, general education
  • Join fees and rank progression

NPCs & Dialog

  • 20+ unique NPCs with jobs, families, and personalities
  • Dialog tree system stored in database - filterable by race, class, job, age, relationship level
  • Multiple dialog options with branching conversations and effects

Monsters & Taming

  • 15 monster types: Slimes, wolves, goblins, spiders, dragons, griffins, phoenixes, etc.
  • Taming system: Use Taming Collars, success based on CHA and difficulty
  • Mounts: Ride tamed creatures (horses, griffins, etc.)

Followers (Ultima 7 inspired)

  • Recruit NPCs with high enough friendship
  • Give orders: follow, guard, quest, build, patrol
  • Assign followers to quests or construction projects

Travel (Morrowind inspired)

  • Boat: Between coastal cities and islands
  • Carriage: Between inland locations
  • Magical teleportation: Between academy waypoints
  • Each with different costs and travel times

Languages

  • 12 languages: Common, Elvish, Dwarvish, Orcish, Draconic, Infernal, Celestial, Sylvan, Abyssal, Merfolk, Beast Tongue, Ancient
  • Proficiency system affects NPC interactions

Social Features

  • Friend requests (send, accept, reject)
  • Private messaging (friends only)
  • Player-to-player trading

Export/Import

  • Export character as JSON (stats, inventory, skills, quests, followers, tamed creatures)
  • Export entire world as JSON (all database tables)
  • Share worlds and characters between instances

🏗️ Architecture

Rendering mermaid diagram...

Files

  • main.ts - HTTP entry point
  • db/schema.ts - 30+ database tables
  • db/seed.ts - World data: races, classes, spells, continents, countries, islands, NPCs, dialogs, items, monsters, guilds, quests
  • lib/auth.ts - Registration, login, sessions, API keys
  • lib/game-engine.ts - All game mechanics
  • api/routes.ts - 40+ REST API endpoints
  • gui/index.html - Full web GUI

🔑 API Authentication

Two methods:

  1. Session cookie (for browser): Login via POST /api/auth/login
  2. API key (for 3rd party): Send X-API-Key header or Authorization: Bearer <key>

📡 API Endpoints

Auth

MethodPathDescription
POST/api/auth/registerCreate account
POST/api/auth/loginLogin, returns session cookie
POST/api/auth/logoutLogout
GET/api/auth/meCurrent account info

Reference Data (Public)

| GET | /api/data/races | All playable races | | GET | /api/data/classes | All classes | | GET | /api/data/magic-schools | Magic schools | | GET | /api/data/spells | All spells | | GET | /api/data/guilds | All guilds | | GET | /api/data/quests | All quests | | GET | /api/data/continents | All continents | | GET | /api/data/countries | All countries | | GET | /api/data/islands | All islands | | GET | /api/data/calendar | Current game date |

Characters

| POST | /api/characters | Create character | | GET | /api/characters | List your characters | | GET | /api/characters/:id | Get character details |

Game Actions

| POST | /api/game/look | Look around | | POST | /api/game/move | Move direction | | POST | /api/game/attack | Attack target | | POST | /api/game/cast | Cast spell | | POST | /api/game/equip | Equip item | | POST | /api/game/dialog/start | Start NPC dialog | | POST | /api/game/dialog/continue | Continue dialog | | POST | /api/game/shop/buy | Buy from shop | | POST | /api/game/shop/sell | Sell to shop | | POST | /api/game/trade/offer | Create trade offer | | POST | /api/game/trade/respond | Accept/reject trade | | POST | /api/game/gift | Give gift to NPC | | POST | /api/game/propose | Propose marriage | | POST | /api/game/guild/join | Join guild | | POST | /api/game/quest/accept | Accept quest | | POST | /api/game/tame | Tame creature | | POST | /api/game/travel | Use travel route | | POST | /api/game/farm/plant | Plant crop | | POST | /api/game/farm/water | Water crop | | POST | /api/game/farm/harvest | Harvest crop | | POST | /api/game/build | Start construction | | POST | /api/game/follower/recruit | Recruit follower | | POST | /api/game/follower/order | Order follower | | POST | /api/game/advance-day | Advance calendar |

Social

| POST | /api/social/friend-request | Send friend request | | POST | /api/social/friend-request/respond | Accept/reject | | GET | /api/social/friend-requests | Pending requests | | GET | /api/social/friends | Friends list | | POST | /api/social/message | Send message | | GET | /api/social/messages | Inbox |

Export

| GET | /api/export/character/:id | Export character JSON | | GET | /api/export/world | Export world JSON |

🔧 Modding

All game data is in SQLite. To add content:

  1. New races: INSERT INTO races (name, description, base_hp, ...) VALUES (...)
  2. New items: INSERT INTO items (name, item_type, damage, ...) VALUES (...)
  3. New NPCs: INSERT INTO characters (name, is_npc, npc_job, ...) VALUES (...)
  4. New dialog: Add to dialog_trees, dialog_nodes, dialog_options
  5. New quests: INSERT INTO quests (name, description, steps, rewards, ...) VALUES (...)
  6. New monsters: INSERT INTO monster_templates (...) VALUES (...)
  7. Content toggles: Configure romance/marriage/trading per race/age in content_toggles

🎨 Themes & Inspirations

  • Morrowind: Magic schools, travel systems (silt striders → boats/carriages/teleporters)
  • Diablo/Diablo 2: Loot, combat, character classes
  • Stardew Valley: Farming, seasons, relationships, gift-giving
  • Rune Factory: Monster taming, farming + combat hybrid
  • My Time in Portia: Building, construction projects
  • Ultima 7: Follower system, open world interaction
  • Isekai anime/manga: Race variety, guild hierarchies, adventure themes
  • Dwarf Fortress: Laws, traditions, families, economy simulation