mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
[Fix] Party And Effect Minifixes (#1337)
* . * Added migration to remove ghosts from the TagTeamDialog
This commit is contained in:
parent
d616ddc113
commit
44b805d0df
6 changed files with 55 additions and 2 deletions
|
|
@ -106,6 +106,21 @@ export default class BaseDataActor extends foundry.abstract.TypeDataModel {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _preDelete() {
|
||||||
|
/* Clear all partyMembers from tagTeam setting.*/
|
||||||
|
/* Revisit this when tagTeam is improved for many parties */
|
||||||
|
if (this.parent.parties.size > 0) {
|
||||||
|
const tagTeam = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.TagTeamRoll);
|
||||||
|
await tagTeam.updateSource({
|
||||||
|
initiator: this.parent.id === tagTeam.initiator ? null : tagTeam.initiator,
|
||||||
|
members: Object.keys(tagTeam.members).find(x => x === this.parent.id)
|
||||||
|
? { [`-=${this.parent.id}`]: null }
|
||||||
|
: {}
|
||||||
|
});
|
||||||
|
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.TagTeamRoll, tagTeam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async _preUpdate(changes, options, userId) {
|
async _preUpdate(changes, options, userId) {
|
||||||
const allowed = await super._preUpdate(changes, options, userId);
|
const allowed = await super._preUpdate(changes, options, userId);
|
||||||
if (allowed === false) return;
|
if (allowed === false) return;
|
||||||
|
|
|
||||||
|
|
@ -678,6 +678,8 @@ export default class DhCharacter extends BaseDataActor {
|
||||||
}
|
}
|
||||||
|
|
||||||
async _preDelete() {
|
async _preDelete() {
|
||||||
|
super._preDelete();
|
||||||
|
|
||||||
if (this.companion) {
|
if (this.companion) {
|
||||||
this.companion.updateLevel(1);
|
this.companion.updateLevel(1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,23 @@ export default class DhParty extends BaseDataActor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _preDelete() {
|
||||||
|
/* Clear all partyMembers from tagTeam setting.*/
|
||||||
|
/* Revisit this when tagTeam is improved for many parties */
|
||||||
|
const tagTeam = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.TagTeamRoll);
|
||||||
|
await tagTeam.updateSource({
|
||||||
|
initiator: this.partyMembers.some(x => x.id === tagTeam.initiator) ? null : tagTeam.initiator,
|
||||||
|
members: Object.keys(tagTeam.members).reduce((acc, key) => {
|
||||||
|
if (this.partyMembers.find(x => x.id === key)) {
|
||||||
|
acc[`-=${key}`] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}, {})
|
||||||
|
});
|
||||||
|
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.TagTeamRoll, tagTeam);
|
||||||
|
}
|
||||||
|
|
||||||
_onDelete(options, userId) {
|
_onDelete(options, userId) {
|
||||||
super._onDelete(options, userId);
|
super._onDelete(options, userId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ export default class EffectsField extends fields.ArrayField {
|
||||||
let effects = this.effects;
|
let effects = this.effects;
|
||||||
const messageTargets = [];
|
const messageTargets = [];
|
||||||
targets.forEach(async baseToken => {
|
targets.forEach(async baseToken => {
|
||||||
if (this.hasSave && token.saved.success === true) effects = this.effects.filter(e => e.onSave === true);
|
if (this.hasSave && baseToken.saved.success === true) effects = this.effects.filter(e => e.onSave === true);
|
||||||
if (!effects.length) return;
|
if (!effects.length) return;
|
||||||
|
|
||||||
const token =
|
const token =
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,25 @@ export async function runMigrations() {
|
||||||
|
|
||||||
lastMigrationVersion = '1.2.0';
|
lastMigrationVersion = '1.2.0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (foundry.utils.isNewerVersion('1.2.7', lastMigrationVersion)) {
|
||||||
|
const tagTeam = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.TagTeamRoll);
|
||||||
|
const initatorMissing = tagTeam.initiator && !game.actors.some(actor => actor.id === tagTeam.initiator);
|
||||||
|
const missingMembers = Object.keys(tagTeam.members).reduce((acc, id) => {
|
||||||
|
if (!game.actors.some(actor => actor.id === id)) {
|
||||||
|
acc[`-=${id}`] = null;
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
await tagTeam.updateSource({
|
||||||
|
initiator: initatorMissing ? null : tagTeam.initiator,
|
||||||
|
members: missingMembers
|
||||||
|
});
|
||||||
|
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.TagTeamRoll, tagTeam);
|
||||||
|
|
||||||
|
lastMigrationVersion = '1.2.7';
|
||||||
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LastMigrationVersion, lastMigrationVersion);
|
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LastMigrationVersion, lastMigrationVersion);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"id": "daggerheart",
|
"id": "daggerheart",
|
||||||
"title": "Daggerheart",
|
"title": "Daggerheart",
|
||||||
"description": "An unofficial implementation of the Daggerheart system",
|
"description": "An unofficial implementation of the Daggerheart system",
|
||||||
"version": "1.2.6",
|
"version": "1.2.7",
|
||||||
"compatibility": {
|
"compatibility": {
|
||||||
"minimum": "13",
|
"minimum": "13",
|
||||||
"verified": "13.351",
|
"verified": "13.351",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue