Skip to content

Commit

Permalink
v2.1.3
Browse files Browse the repository at this point in the history
- Fixed issue where having a player other than GM in the world would prevent the importer from correctly importing anything.
  • Loading branch information
sneat authored May 23, 2022
2 parents c31e6e3 + b988f2c commit 201528e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 16 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v2.1.3

- Fixed issue where having a player other than GM in the world would prevent the importer from correctly importing anything.

## v2.1.2

* Better handling of config options to make it less likely to break on certain module's configuration settings.
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"flags": {
"allowBugReporter": true
},
"version": "2.1.2",
"version": "2.1.3",
"minimumCoreVersion": "0.6.0",
"compatibleCoreVersion": "10",
"scripts": [],
Expand Down
18 changes: 13 additions & 5 deletions scripts/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export default class Core extends FormApplication {
}
this.playerSettings.push(setting.value);
this.hasPlayerSettings = true;
break;
default:
throw new Error(`Unknown setting type: ${setting.type}`);
}
}
} catch (e) {
Expand All @@ -72,7 +75,12 @@ export default class Core extends FormApplication {

this.settings = Object.entries(Object.fromEntries(this.settingGroups));
this.settings.sort((a, b) => a[0].localeCompare(b[0]));
this.playerSettings.sort((a, b) => a.key.localeCompare(b.key));
for (const playerSetting of this.playerSettings) {
playerSetting.playerDifferences = Object.entries(playerSetting.playerDifferences);
playerSetting.playerDifferences.sort((a, b) => a[0].localeCompare(b[0]));
playerSetting.playerFlagDifferences = Object.entries(playerSetting.playerFlagDifferences);
playerSetting.playerFlagDifferences.sort((a, b) => a[0].localeCompare(b[0]));
}

log(true, 'Processing world settings', this.settings);
log(true, 'Processing player settings', this.playerSettings);
Expand Down Expand Up @@ -280,12 +288,12 @@ export default class Core extends FormApplication {

if (type === 'core') {
changes[fieldName] =
this.playerSettings[target].playerDifferences[fieldName].newVal;
Object.fromEntries(this.playerSettings[target].playerDifferences)[fieldName].newVal;
}

if (type === 'flag') {
changes.flags[fieldName] =
this.playerSettings[target].playerFlagDifferences[fieldName].newVal;
Object.fromEntries(this.playerSettings[target].playerFlagDifferences)[fieldName].newVal;
}
}

Expand Down Expand Up @@ -359,7 +367,7 @@ export default class Core extends FormApplication {

text += `\n${game.i18n.localize('forien-copy-environment.message')}`;

log(false, text);
log(true, text);

return text;
}
Expand Down Expand Up @@ -443,7 +451,7 @@ export default class Core extends FormApplication {
let coreSettings = new Core(settings);
coreSettings.render(true);
} catch (e) {
log(false, 'Could not parse import data.');
console.error('Copy Environment | Could not parse import data.', e);
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class Setting {
this.value = undefined;

if (!data || typeof data !== 'object') {
log(false, 'Unknown setting received:', data);
console.error('Copy Environment | Unknown setting received:', data);
return this;
}

Expand Down Expand Up @@ -100,7 +100,7 @@ export class WorldSetting {

return new Difference(this.key, existingSetting, newValue);
} catch (e) {
log(false, 'Could not parse world setting values:', e, this.key);
console.error('Copy Environment | Could not parse world setting values:', this.key, e);
}

// Return the difference of the original values, not the parsed values.
Expand Down
16 changes: 8 additions & 8 deletions templates/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,29 @@ <h2>{{localize 'forien-copy-environment.intro'}}</h2>
</thead>
<tbody>
{{#each playerDifferences as |diff|}}
{{#with (concat ../name "--" name) as |fkey|}}
{{#with (concat ../name "--" diff.[1].name) as |fkey|}}
<tr>
<td><label for="{{fkey}}"><input name="{{fkey}}" id="{{fkey}}" type="checkbox"
data-for="{{ @../index }}" data-type="core" {{checked (lookup @root.selectedProperties fkey)}}>{{ diff.name }}</label></td>
data-for="{{ @../index }}" data-type="core" {{checked (lookup @root.selectedProperties fkey)}}>{{ diff.[1].name }}</label></td>
<td class="value">
<label for="{{fkey}}">{{ diff.newString }}
<label for="{{fkey}}">{{ diff.[1].newString }}</label>
</td>
<td class="value">
<label for="{{fkey}}">{{ diff.oldString }}</label>
<label for="{{fkey}}">{{ diff.[1].oldString }}</label>
</td>
</tr>
{{/with}}
{{/each}}
{{#each playerFlagDifferences as |diff|}}
{{#with (concat ../name "--flag--" name) as |fdkey|}}
{{#with (concat ../name "--flag--" diff.[1].name) as |fdkey|}}
<tr>
<td><label for="{{fdkey}}"><input name="{{fdkey}}" type="checkbox" id="{{fdkey}}" data-for="{{ @../index }}" data-type="flag"
{{checked (lookup @root.selectedProperties fdkey)}}>{{ diff.name }}</label></td>
{{checked (lookup @root.selectedProperties fdkey)}}>{{ diff.[1].name }}</label></td>
<td class="value">
<label for="{{fdkey}}">{{ diff.newString }}</label>
<label for="{{fdkey}}">{{ diff.[1].newString }}</label>
</td>
<td class="value">
<label for="{{fdkey}}">{{ diff.oldString }}</label>
<label for="{{fdkey}}">{{ diff.[1].oldString }}</label>
</td>
</tr>
{{/with}}
Expand Down

0 comments on commit 201528e

Please sign in to comment.