forked from xdy/twodsix-foundryvtt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previsouly adding a trait did not affect the actor. This change makes it so that a trait is an active effect and can change the actor. Fix xdy#272
- Loading branch information
Showing
19 changed files
with
272 additions
and
60 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/migrations/2022_01_03_05_08_25_active-effects-for-traits.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
async function applyActiveEffects(p, actor) { | ||
await p; | ||
return Promise.all(actor.items.filter(item => item.type === "trait").map(async item => { | ||
if (!item.data.data.effectId) { | ||
const effects = await actor.createEmbeddedDocuments("ActiveEffect", [{ | ||
origin: item.uuid, | ||
icon: "systems/twodsix/assets/icons/science.svg" | ||
}]); | ||
await item.update({ "data.effectId": effects[0].id }); | ||
} | ||
return Promise.resolve(); | ||
})); | ||
} | ||
|
||
export async function migrate(): Promise<void> { | ||
const tokenActor = game.scenes?.reduce((memo: TokenDocument[], scene: Scene) => memo.concat(scene.tokens.contents), []) | ||
.filter((token: TokenDocument) => token.actor?.type === "traveller" && !token.data.actorLink) | ||
.map((token: TokenDocument) => token.actor); | ||
await game.actors?.filter(actor => actor.type === "traveller").reduce(applyActiveEffects, Promise.resolve()); | ||
await tokenActor?.reduce(applyActiveEffects, Promise.resolve()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.