Overview
Utopia Fleet Builder stores all Star Trek Attack Wing game data as JavaScript modules insrc/data/. During the build process, these modules are compiled into a single data.json file that the application loads.
The data generation process is defined in
src/data/index.js and executed via npm run data.Data Architecture
Data Modules
The data directory contains the following modules:Data Generation Process
Thesrc/data/index.js script compiles all data modules:
src/data/index.js
- Requires each data module
- Combines them into a single object
- Creates
staw-utopia/data/directory if needed - Writes the complete data as JSON
Card Data Structure
Ships
Ship cards contain specifications and abilities:Example Ship Card
Common Ship Properties
Common Ship Properties
| Property | Type | Description |
|---|---|---|
id | string | Unique identifier (e.g., “S415”) |
name | string | Ship name |
class | string | Ship class |
attack | number | Attack value |
agility | number | Agility value |
hull | number | Hull points |
shields | number | Shield points |
cost | number | Squadron point cost |
actions | array | Available actions |
upgrades | array | Upgrade slot types |
factions | array | Allowed faction(s) |
Action Types
Action Types
Standard actions available to ships:
evade- Evade actiontarget-lock- Target Lock actionscan- Scan actionbattlestations- Battle Stations actioncloak- Cloak actionsensor-echo- Sensor Echo actionregenerate- Regenerate action
Upgrade Slot Types
Upgrade Slot Types
Types of upgrade slots:
weapon- Weapon upgradescrew- Crew upgradestech- Tech upgradestalent- Talent upgradesborg- Borg upgradesadmiral- Admiral slotambassador- Ambassador slot
Captains
Captain cards define ship commanders:Example Captain
Upgrades
Upgrade cards enhance ships:Example Upgrade
Faction System
Cards belong to one or more factions:Factions
Multi-faction cards can be used by any of their listed factions.
Set System
Each card references expansion sets by ID:Example Set Definition
Adding New Data
Choose the Correct Module
Determine which data file to edit:
- Ships →
ships.js - Captains →
captains.js - Upgrades →
upgrades.js - etc.
Use Proper ID Format
Follow the ID conventions:
- Ships:
S###(e.g.,S415) - Captains:
C###(e.g.,C123) - Upgrades:
U###(e.g.,U456) - Resources:
R###(e.g.,R001)
Include HTML in Text
Card text supports HTML formatting:Use
<b> for bold, <br> for line breaks, <hr> for separators.Lint and Generate
Run the data build process:This will:
- Run ESLint to check syntax
- Generate
data.json - Report any errors
Data Validation
ESLint Configuration
Data files are linted with ESLint using the configuration insrc/data/.eslintrc:
ESLint automatically fixes many issues (semicolons, quotes, etc.). Check the output for unfixable errors.
Common Validation Errors
Missing required fields
Missing required fields
Error: Card is missing
id, name, type, or cost.Solution: Ensure all required fields are present.Duplicate IDs
Duplicate IDs
Error: Two cards have the same ID.Solution: Use a unique ID for each card. Check existing cards to avoid conflicts.
Invalid faction
Invalid faction
Error: Faction name is misspelled or not recognized.Solution: Use exact faction names from the list above.
Syntax errors
Syntax errors
Error: ESLint reports parsing errors.Solution: Check for:
- Missing commas between properties
- Unclosed brackets or braces
- Unescaped quotes in strings
Data File Sizes
The data files are substantial:upgrades.js
701 KBLargest data file
ships.js
240 KBSecond largest
captains.js
180 KBThird largest
Viewing Generated Data
The compiledstaw-utopia/data/data.json file is minified (no formatting). To inspect it:
Using jq (Command Line)
Using Online Tools
- Copy the contents of
data.json - Paste into a JSON formatter like:
Using Code Editor
Most editors can format JSON:- VS Code: Right-click → “Format Document”
- Notepad++: Plugins → JSTool → JSFormat
Performance Considerations
Keep Data Normalized
Avoid duplicating information across cards. Reference sets, classes, and other shared data by ID.
Next Steps
Contributing
Learn how to submit your data changes
Build Process
Understanding how data is built