From 74ee2e93cc21c75e624272cd94ce572c1bbd2f66 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 1 Apr 2021 00:05:46 +0200 Subject: [PATCH] Fix Chanter la chanson --- dev-notes.md | 61 ++++++++++++++++++++++++++++++ templates/chat-resultat-chant.html | 2 +- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 dev-notes.md diff --git a/dev-notes.md b/dev-notes.md new file mode 100644 index 00000000..9816dda6 --- /dev/null +++ b/dev-notes.md @@ -0,0 +1,61 @@ +# Actor notes + +> The Actor#getData default implementation gives you the following for use in sheet rendering: + +``` + actor -> the Actor instance + data -> a cloned copy of Actor#data + items -> a cloned copy of Actor#data#items + effects -> a cloned copy of Actor#data#effects +``` + +> if all you need is a safe copy of `Actor#data`, you'll be much better off by simply defining your own function and avoiding all the wasted work that the parent class does which will slow down your sheet +```js +getData(options) { + return { + data: foundry.utils.deepClone(this.object.data) + } +} +``` + +who knows, maybe you don't even need to copy your actor data, skip the copy and it's even faster: +```js +getData(options) { + return { + data: this.object.data + } +} +``` + + +Atropos19/02/2021 +There are two recommended ways to create owned items in 0.8.0: +```js +await Item.create(itemData, {parent: actor}); +await actor.createEmbeddedDocuments("Item", itemDataArray); +``` + + +You can update an embedded item in one of two ways: +```js +//Method 1: + +const item = actor.items.get(itemId); +item.update(data); + +//Method 2: +actor.updateEmbeddedDocuments("Item", [{_id: itemId, ...}]); +``` + + +I noticed adding an ActiveEffect to an actor in code using + +```js +this.createEmbeddedDocuments('ActiveEffect', [effet], options); +this.applyActiveEffects(); +``` + +Atropos — Aujourd’hui à 14:42 +Two notes on this: +1. You don't actually need to call this.applyActiveEffects() because this will happen automatically whenever an effect is created/updated/deleted +2. If you want to suppress the automatic display of the sheet for the newly created document, you can pass options.renderSheet = false as part of your options object \ No newline at end of file diff --git a/templates/chat-resultat-chant.html b/templates/chat-resultat-chant.html index 4ebcacbc..eb2b072e 100644 --- a/templates/chat-resultat-chant.html +++ b/templates/chat-resultat-chant.html @@ -1,6 +1,6 @@ {{oeuvre.data.competence}}

- {{alias}} tente de chanter la chanson : {{oeuvre.name}} (niveau {{oeuvre.data.niveau}}) + {{alias}} tente de chanter : {{oeuvre.name}} (niveau {{oeuvre.data.niveau}})

{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.html"}}