Skip to content

Commit

Permalink
Flipped the order of aliases to "newName": "oldName"
Browse files Browse the repository at this point in the history
  • Loading branch information
lupestro committed Dec 7, 2022
1 parent ba765d7 commit 53a966a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 19 deletions.
25 changes: 18 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@

## Middle Kingdom - v10 branch

### Unreleased - December 6, 2022
- [FEATURE] (Lupestro) Updated README for clarity in creating user settings. (Issue #27 - many participants)
- [FEATURE] (Lupestro) Improved and simplified source JSON syntax with defaults for most fields. (Issue #27 - many participants)
* This change shouldn't invalidate any existing light source JSON files.
- [FEATURE] (Lupestro) Introduced aliases to JSON to give new names to light sources defined elsewhere.
* Using this in a very simple custom JSON will make this module more useful to those who play in a non-English language.
- [FEATURE] (Lupestro) Provided aliases for dnd5e light sources that should provide smoother integration with ddb-importer. (Issues raised by MrPrimate and emmoth)
- [FEATURE] (Lupestro) Improved name and description of options for consuming torches, candles, etc. to avoid confusion. (In response to comments by vgeirnaert)

I'm looking at loading localized language JSON files for the out-of-the-box sources on startup in a future release. This will need the actual (i.e. matching letter-by-letter) light source names used in various games when played in different languages. Contact me if you play with light sources in another language and you're interested in helping out.

### 2.1.4 - December 4, 2022
- [BUGFIX] DnD5e Bullseye Lantern had wrong dim/bright ranges due to copy/paste error.
- [BUGFIX] Bullseye lanterns in all systems that had 53 degree radius, now have 57 degree radius.
- [BUGFIX] (Lupestro) DnD5e Bullseye Lantern had wrong dim/bright ranges due to copy/paste error. (Issue reported by Fragmenri. Thanks!)
- [BUGFIX] (Lupestro) Bullseye lanterns in all systems that had 53 degree radius, now have 57 degree radius.
* 53 degrees is technically correct for a cone (n units wide at center distance n, per rules).
* 57 degrees (1 radian) would be correct for a (spherical) sector of radius n and arc length n.
* Foundry projects light radially, so you get a spherical sector, regardless of the game rules.
Expand All @@ -13,13 +24,13 @@
* You can always reduce it back to 53 degrees with a custom JSON, of course, if you feel strongly about it.

### 2.1.3 - October 8, 2022
- [BUGFIX] Corrected issue (found by vkdolea) where user-supplied sources for new systems weren't processing properly.
- [BUGFIX] Now pulling non-dim/bright light properties for the light source configured in settings from the prototype token.
- [BUGFIX] Fixed the translation files for several languages.
- [BUGFIX] (Lupestro) Corrected issue (found by vkdolea) where user-supplied sources for new systems weren't processing properly.
- [BUGFIX] (Lupestro) Now pulling non-dim/bright light properties for the light source configured in settings from the prototype token. (Issue reported by Jensenator360)
- [BUGFIX] (Lupestro) Fixed the translation files for several languages.

### 2.1.2 - September 14, 2022
- [BUGFIX] Fixed image used for dancing lights
- [BUGFIX] Reset precedence order to user-supplied light sources first, then the source in config settings, then module-provided defaults based on game rules.
- [BUGFIX] (Lupestro) Fixed image used for dancing lights
- [BUGFIX] (Lupestro) Reset precedence order to user-supplied light sources first, then the source in config settings, then module-provided defaults based on game rules.

### 2.1.1 - September 6, 2022
- [BUGFIX] (Lupestro) Fixed issue where unlinked tokens were adjusting inventory on source token.
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ This module just sheds light from the location of a player token upon demand bas
Because the light source to use is now user-configurable, we no longer select a light source for you based on fallbacks. As it stands, if you do not explicitly select your light source, it will pick any among the light sources you have equipped, in no particular order.
## Customizing light sources

You can supersede these settings or supply settings for your own light sources for any system with a JSON file, which you can deliver through the "Additional Light Sources" setting. The following shows a fully specified light source:
You can supersede these settings or supply settings for your own light sources for any system with a JSON file, which you can deliver through the "Additional Light Sources" setting. The following shows a fully specified light source and a couple of aliases:
```json
{
"dnd5e": {
"system": "dnd5e",
"topology": "standard",
"quantity" : "quantity",
"aliases": {
"Bullseye Lantern": "Lantern (Bullseye)",
"Hooded Lantern": "Lantern (Hooded)"
"Lantern (Bullseye)": "Bullseye Lantern",
"Lantern (Hooded)": "Hooded Lantern"
}
"sources": {
"Candle": {
Expand Down Expand Up @@ -78,8 +78,8 @@ The JSON has one top-level property per system, keyed by the Foundry id of the s
* If you supply a single object rather than an array of objects, the module will treat it as an array of one item, (a light source with a single "on" state, the most common condition), and `states` will default to 2.

* The `aliases` property lets you specify alternate names for existing sources. Each entry has a key and a value:
* The key is the name of the existing source that the alias will duplicate.
* The value is the name of the new source as a string.
* The key is the new name of the source .
* The value is the name (as a string) of the existing source being duplicated.
* The source you duplicate with a new name can either be one of the predefined sources or one of the sources from the same user settings.

### Determining your system's id, topology, and quantity
Expand Down
4 changes: 2 additions & 2 deletions library.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export default class SourceLibrary {
}
let sources = library[system].sources;
let aliases = library[system].aliases;
for (const aliasref in aliases) {
let alias = aliases[aliasref];
for (const alias in aliases) {
let aliasref = aliases[alias];
let aliasedSource = sources[aliasref] ? sources[aliasref] : ref && ref.sources[aliasref] ? ref.sources[aliasref] : null;
if (aliasedSource) {
sources[alias] = Object.assign({}, aliasedSource, {name: alias});
Expand Down
4 changes: 2 additions & 2 deletions sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"topology": "standard",
"quantity" : "quantity",
"aliases": {
"Hooded Lantern": "Lantern, Hooded",
"Bullseye Lantern": "Lantern, Bullseye"
"Lantern, Hooded": "Hooded Lantern",
"Lantern, Bullseye": "Bullseye Lantern"
},
"sources": {
"Candle": {
Expand Down
6 changes: 3 additions & 3 deletions test/common-library-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export let torchCommonLibraryTests = (context) => {
other: { light: [ {bright: 10, dim: 20, angle: 360} ] }
},
aliases: {
nuke: "bomb",
other: "alt"
bomb: "nuke",
alt: "other"
}
}
}
Expand Down Expand Up @@ -51,7 +51,7 @@ export let torchCommonLibraryTests = (context) => {
other: { light: [ {bright: 10, dim: 20, angle: 360} ] }
},
aliases: {
special: "crazy"
crazy: "special"
}
}
};
Expand Down

0 comments on commit 53a966a

Please sign in to comment.