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.
feature: traits are now active effects
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
20 changed files
with
241 additions
and
49 deletions.
There are no files selected for viewing
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
25 changes: 25 additions & 0 deletions
25
src/migrations/2021_12_29_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,25 @@ | ||
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) { | ||
//@ts-ignore | ||
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 | ||
//@ts-ignore | ||
.reduce((memo, scene) => memo.concat(scene.tokens.contents), []) | ||
.filter(s => s.actor.type === "traveller" && !s.data.actorLink) | ||
.map(token => token._actor); | ||
//@ts-ignore | ||
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
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.