Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5e70e93
style(locales): Standardise string literal quotes
steverobertsuk Jun 15, 2026
063f800
build(scripts): Correctly load bumped version for build and filter pr…
steverobertsuk Jun 15, 2026
a1a30f7
feat(commands): Update primary command to `!ced` with legacy support
steverobertsuk Jun 15, 2026
bee8329
fix(locales): Correct formatting of encounterNotFoundHint in Finnish …
steverobertsuk Jun 15, 2026
0a4266c
refactor: Migrate VALID_LAYERS to use Set for improved performance
steverobertsuk Jun 15, 2026
81779bc
refactor: Extract applyBossHp function for clarity
steverobertsuk Jun 15, 2026
87dd11e
refactor: Use String.prototype.replaceAll for consistency
steverobertsuk Jun 15, 2026
08fdb17
refactor: Use Number.parseInt for explicit radix in parsing functions
steverobertsuk Jun 15, 2026
e78fb33
refactor: Improve state initialisation robustness
steverobertsuk Jun 15, 2026
6b7273c
refactor: Extract dedicated scale command handlers
steverobertsuk Jun 15, 2026
66c5a06
refactor: Extract dedicated reinforce command handlers
steverobertsuk Jun 15, 2026
798c211
feat: Implement legacy chat input handler
steverobertsuk Jun 15, 2026
7500e84
refactor: Extract encounter token restoration helpers
steverobertsuk Jun 15, 2026
6d655c6
refactor: Standardise encounter name sorting with localeCompare
steverobertsuk Jun 15, 2026
5510535
chore: Minor cleanup of imports and utility functions
steverobertsuk Jun 15, 2026
5ac3996
refactor: Standardise Command Deck section rendering
steverobertsuk Jun 15, 2026
3b1bb2b
feat: Add styled card container to Command Deck journal
steverobertsuk Jun 15, 2026
b34e9d0
chore: Update and reorder JSDoc for command handlers
steverobertsuk Jun 15, 2026
df2363f
chore: Prevent duplicate stable versions in history
steverobertsuk Jun 15, 2026
d0049e9
feat: Migrate primary command to !ced and enhance script robustness
steverobertsuk Jun 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10,332 changes: 10,332 additions & 0 deletions CombatEncounterDirector/1.0.1/CombatEncounterDirector.js

Large diffs are not rendered by default.

25 changes: 23 additions & 2 deletions CombatEncounterDirector/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

## 1.0.1

### Added

- Legacy command compatibility for `!director` when no conflicting Director mod is detected.

### Changed

- Primary command changed from `!director` to `!ced` to avoid command collisions.
- Localized help and error hints now reference `!ced` in command examples.
- Command Deck and Status handouts now consistently render with the intended dark theme.
- One-Click language configuration is now a select list with all supported locale options.

### Fixed

- If a conflicting Director mod is installed, using `!director` now warns the GM to use `!ced`.

### Developer Notes

- Technical implementation details for 1.0.1 are documented in `DEVELOPERS.md`.

## 1.0.0 (initial release)

### Added
Expand All @@ -13,6 +34,6 @@
- **Reset & recovery** — restore any modified token to its original values (selected, page, or all).
- **Status reporting** — generate an HTML status report in the Combat Encounter Director - Status journal; filter by selected or changed tokens.
- **Journal control panel** — all features accessible via the Combat Encounter Director handout with one-click action buttons.
- **Configuration** — configurable HP bar (bar1/bar2/bar3) and AC bar (bar1/bar2/bar3/none) via `!director config` or Roll20 One-Click useroptions.
- **Internationalisation** — full i18n system with `t(key, locale, vars)` lookup; 24 supported locales (af, ca, zh-TW, cs, da, nl, en-US, fi, fr, de, el, he, hu, it, ja, ko, pl, pt-PT, pt-BR, ru, es, sv, tr, uk); active language configurable at runtime via `!director config language <code>` or the One-Click `language` useroption; falls back to `en-US` for any missing key.
- **Configuration** — configurable HP bar (bar1/bar2/bar3) and AC bar (bar1/bar2/bar3/none) via `!ced config` or Roll20 One-Click useroptions.
- **Internationalisation** — full i18n system with `t(key, locale, vars)` lookup; 24 supported locales (af, ca, zh-TW, cs, da, nl, en-US, fi, fr, de, el, he, hu, it, ja, ko, pl, pt-PT, pt-BR, ru, es, sv, tr, uk); active language configurable at runtime via `!ced config language <code>` or the One-Click `language` useroption; falls back to `en-US` for any missing key.
- **Locale sync script** — `npm run sync-locales` / `npm run regenerate-locales` using Google Translate with placeholder masking to translate all locale files automatically.
1,625 changes: 966 additions & 659 deletions CombatEncounterDirector/CombatEncounterDirector.js

Large diffs are not rendered by default.

46 changes: 37 additions & 9 deletions CombatEncounterDirector/DEVELOPERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ CombatEncounterDirector/
| `encounters.js` | Encounter template CRUD |
| `reporting.js` | Build and write the status journal HTML |
| `journals.js` | Build and write the control panel journal HTML |
| `commands.js` | Route `!director` subcommands; whisper feedback |
| `commands.js` | Route `!ced` subcommands; whisper feedback |
| `i18n.js` | `t()`, `normalizeLocale()`, `isRtlLocale()` — translation lookup |
| `locales/metadata.js` | Locale definitions, `VALID_LOCALES`, `LOCALE_ALIASES` |
| `locales/index.js` | Assembles `TRANSLATIONS` map from all locale files |
Expand Down Expand Up @@ -118,13 +118,13 @@ state.CombatEncounterDirector = {
This project uses [Rollup](https://rollupjs.org) to bundle ES modules into a single Roll20-compatible script.

```bash
npm install # Install dependencies
npm run build # Auto-bump patch version, then build
npm run build -- 1.1.0 # Set explicit version, then build
npm run build -- 1.1.0-alpha.1 # Enter prerelease cycle, then build
npm run watch # Watch mode — rebuilds on change, no version bump
npm run set-version -- 1.1.0 # Set version only, no build
npm run format # Format source with Prettier
npm install # Install dependencies
npm run build # Auto-bump patch version, then build
npm run build -- 1.1.0 # Set explicit version, then build
npm run build -- 1.1.0-alpha.1 # Enter prerelease cycle, then build
npm run watch # Watch mode — rebuilds on change, no version bump
npm run set-version -- 1.1.0 # Set version only, no build
npm run format # Format source with Prettier
```

The build (`scripts/build.mjs`):
Expand Down Expand Up @@ -165,7 +165,7 @@ All user-facing strings are translated via `t(key, locale, vars?)` in `src/i18n.
2. `src/locales/metadata.js` declares the 24 supported locales and their aliases.
3. `src/locales/index.js` imports all locale files and assembles the `TRANSLATIONS` map.
4. `t('section.key', lang, { var: value })` looks up `TRANSLATIONS[lang].section.key`, interpolates `{var}` placeholders, and falls back to `en-US` when a key is missing.
5. The active locale is stored in `state.CombatEncounterDirector.config.language` and can be changed at runtime with `!director config language <code>`.
5. The active locale is stored in `state.CombatEncounterDirector.config.language` and can be changed at runtime with `!ced config language <code>`.

### Key structure in `en-US.js`

Expand Down Expand Up @@ -254,3 +254,31 @@ All command handlers are wrapped in a try-catch in `handleInput`. Validation fun
- `token.set(...)` changes are immediate but not undoable by the GM.
- `createObj('graphic', {...})` requires `_pageid` and `subtype: 'token'`.
- `playerIsGM(msg.playerid)` guards all commands — non-GMs are silently ignored.

## Release Notes For Maintainers

### 1.0.1 Technical Notes

- Command migration:
- Primary command constant changed to `!ced`.
- Legacy alias `!director` is still accepted for backwards compatibility.
- Conflict detection uses `DIRECTOR_CONFLICT_STATE_KEY = 'DIRECTOR_STATE'`; when present, legacy alias usage triggers a GM warning instead of routing under the legacy name.

- i18n updates:
- Locale hint strings and command examples were updated from `!director` to `!ced` across locale files used in the generated bundle.

- Journal rendering:
- Command Deck and Status handout HTML now uses an explicit wrapper/background container to prevent white default journal rendering and preserve intended theme styling.

- One-Click metadata and options:
- `script.json` select-style options were normalized to remove pipe-delimited labels.
- `language` useroption was changed to a select option containing all supported locale codes.

- Build/versioning pipeline:
- Build flow now bumps/sets version before loading version-dependent config, preventing stale version output paths.
- Explicit version builds now write snapshots to the matching `<version>/CombatEncounterDirector.js` directory.
- Prerelease versions are excluded from `previousversions` history handling.

- Code quality hardening:
- Source files feeding the generated bundle were refactored to address SonarQube warnings and improve maintainability.
- JSDoc coverage and placement were reviewed and corrected in source modules.
12 changes: 6 additions & 6 deletions CombatEncounterDirector/MOD_FILE_MAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ A quick reference for where to find each feature in the source.

## Command Routing

| Task | File | Key function |
| ----------------------------- | ----------------- | -------------- |
| Handle `!director` chat input | `src/commands.js` | `handleInput` |
| Route subcommands | `src/commands.js` | `routeCommand` |
| Quick-action menu | `src/commands.js` | `showMainMenu` |
| Help reference card | `src/commands.js` | `showHelp` |
| Task | File | Key function |
| ------------------------ | ----------------- | -------------- |
| Handle `!ced` chat input | `src/commands.js` | `handleInput` |
| Route subcommands | `src/commands.js` | `routeCommand` |
| Quick-action menu | `src/commands.js` | `showMainMenu` |
| Help reference card | `src/commands.js` | `showHelp` |

## Party Scaling

Expand Down
79 changes: 39 additions & 40 deletions CombatEncounterDirector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ The mod is designed to support anything from solo adventures to large convention

## Quick Start

Type `!director` in chat for the quick-action menu, or open the **Combat Encounter Director - Command Deck** journal for the full control panel.
Type `!ced` in chat for the quick-action menu, or open the **Combat Encounter Director - Command Deck** journal for the full control panel.

## Primary Command

```
!director
!ced
```

No aliases are provided to avoid collisions with other scripts.
Legacy `!director` is accepted for backward compatibility when no conflicting Director mod is detected. If a conflict is detected, the GM is warned to use `!ced`.

---

Expand All @@ -50,28 +50,28 @@ Scale enemy HP, AC, and damage for different party sizes.
Apply a preset to selected tokens:

```
!director scale preset standard
!director scale party 6
!ced scale preset standard
!ced scale party 6
```

Set individual values:

```
!director scale hp 150
!director scale ac +2
!director scale damage 125
!director scale apply
!ced scale hp 150
!ced scale ac +2
!ced scale damage 125
!ced scale apply
```

### Boss Tools

Apply a boss-type preset to selected tokens:

```
!director boss minion
!director boss elite
!director boss boss
!director boss legendary
!ced boss minion
!ced boss elite
!ced boss boss
!ced boss legendary
```

| Preset | HP | AC | Damage |
Expand All @@ -86,78 +86,78 @@ Apply a boss-type preset to selected tokens:
Duplicate selected tokens and auto-enumerate them:

```
!director reinforce duplicate 3
!director reinforce enumerate
!ced reinforce duplicate 3
!ced reinforce enumerate
```

Duplicate copies are placed 1 grid square to the right of the original.

### Layer & Visibility

```
!director layer token
!director layer gm
!director layer map
!director hide
!director reveal
!ced layer token
!ced layer gm
!ced layer map
!ced hide
!ced reveal
```

### Position Management

Save and restore token positions:

```
!director position save
!director position restore
!ced position save
!ced position restore
```

### Encounter Templates

Save the full state of all tokens on the current page and restore them later:

```
!director encounter save goblin-ambush
!director encounter load goblin-ambush
!director encounter delete goblin-ambush
!director encounter list
!ced encounter save goblin-ambush
!ced encounter load goblin-ambush
!ced encounter delete goblin-ambush
!ced encounter list
```

### Reset & Recovery

Every modified token retains its original values. Reset at any time:

```
!director reset selected
!director reset page
!director reset all
!ced reset selected
!ced reset page
!ced reset all
```

### Reporting

Generate a status report in the **Combat Encounter Director - Status** journal:

```
!director report refresh
!director report selected
!director report changed
!director report clear
!ced report refresh
!ced report selected
!ced report changed
!ced report clear
```

### Configuration

```
!director config
!director config hp-bar bar1
!director config ac-bar bar2
!director config ac-bar none
!ced config
!ced config hp-bar bar1
!ced config ac-bar bar2
!ced config ac-bar none
```

### Journal Management

Rebuild the control panel and status journals:

```
!director journal rebuild
!ced journal rebuild
```

---
Expand All @@ -169,7 +169,7 @@ Rebuild the control panel and status journals:
| HP Bar | bar1 | bar1, bar2, bar3 | Which token bar tracks HP |
| AC Bar | bar2 | bar1, bar2, bar3, none | Which token bar tracks AC |

Configure via Roll20 One-Click settings or with `!director config`.
Configure via Roll20 One-Click settings or with `!ced config`.

---

Expand All @@ -194,4 +194,3 @@ Maintainer: [MidNiteShadow7](https://app.roll20.net/users/16506286/midniteshadow
## License

This script is licensed under the MIT License.

Loading
Loading