diff --git a/src/module/documents/character.mjs b/src/module/documents/character.mjs
index ebc67b42..a17df7be 100644
--- a/src/module/documents/character.mjs
+++ b/src/module/documents/character.mjs
@@ -7,4 +7,21 @@ export class Character extends Actor {
this.prepareEmbeddedDocuments();
}
+ getRollData() {
+ const data = super.getRollData();
+
+ if (this.type !== 'character') return;
+
+ // Copy the ability scores to the top level, so that rolls can use
+ // formulas like `@str.mod + 4`.
+ if (data.attribute) {
+ for (let [k, v] of Object.entries(data.attribute)) {
+ data[k] = foundry.utils.deepClone(v);
+ }
+ }
+ console.log(data);
+ return data;
+ }
+
+
}
\ No newline at end of file
diff --git a/src/module/sheets/characterSheet.mjs b/src/module/sheets/characterSheet.mjs
index e1be95eb..41df263a 100644
--- a/src/module/sheets/characterSheet.mjs
+++ b/src/module/sheets/characterSheet.mjs
@@ -34,6 +34,49 @@ export class CharacterSheet extends ActorSheet {
// Add the actor's data to context.data for easier access, as well as flags.
context.system = actorData.system;
context.flags = actorData.flags;
+ context.attributs = [
+ {
+ attribut: "mu",
+ name: "Mut",
+ wert: actorData.system.attribute.mu ?? 0,
+ },
+ {
+ attribut: "kl",
+ name: "Klugheit",
+ wert: actorData.system.attribute.kl ?? 0,
+ },
+ {
+ attribut: "in",
+ name: "Intuition",
+ wert: actorData.system.attribute.in ?? 0,
+ },
+ {
+ attribut: "ch",
+ name: "Charisma",
+ wert: actorData.system.attribute.ch ?? 0,
+ },
+ {
+ attribut: "ff",
+ name: "Fingerfertigkeit",
+ wert: actorData.system.attribute.ff ?? 0,
+ },
+ {
+ attribut: "ge",
+ name: "Geschicklichkeit",
+ wert: actorData.system.attribute.ge ?? 0,
+ },
+ {
+ attribut: "ko",
+ name: "Konstitution",
+ wert: actorData.system.attribute.ko ?? 0,
+ },
+ {
+ attribut: "kk",
+ name: "Körperkraft",
+ wert: actorData.system.attribute.kk ?? 0,
+ },
+
+ ];
context.skills = [];
if ( context.system.talente?.length >= 0) {
context.system.talente.forEach(talent => {
@@ -51,9 +94,31 @@ export class CharacterSheet extends ActorSheet {
return context;
}
+ _onRoll(event) {
+ event.preventDefault();
+ const dataset = event.currentTarget.dataset;
+ console.log(dataset)
+ if (dataset.roll) {
+ let label = dataset.label ? `[Attribut] ${dataset.label}` : '';
+ console.log(this.actor.getRollData());
+ let roll = new Roll(dataset.roll, this.actor.getRollData());
+ roll.toMessage({
+ speaker: ChatMessage.getSpeaker({ actor: this.actor }),
+ flavor: label,
+ rollMode: game.settings.get('core', 'rollMode'),
+ });
+ return roll;
+ }
+ }
+
activateListeners(html) {
super.activateListeners(html);
+ html.on('click', '.attribut.rollable', (evt) => {
+ console.log(evt);
+ this._onRoll(evt);
+ });
+
// Everything below here is only needed if the sheet is editable
if (!this.isEditable) return;
diff --git a/src/templates/actor/actor-character-sheet.hbs b/src/templates/actor/actor-character-sheet.hbs
index f2e44565..768b7267 100644
--- a/src/templates/actor/actor-character-sheet.hbs
+++ b/src/templates/actor/actor-character-sheet.hbs
@@ -6,6 +6,18 @@