diff --git a/src/module/dialog/attributeDialog.mjs b/src/module/dialog/attributeDialog.mjs
new file mode 100644
index 00000000..102b8feb
--- /dev/null
+++ b/src/module/dialog/attributeDialog.mjs
@@ -0,0 +1,187 @@
+import {LiturgyData} from "../data/miracle/liturgydata.mjs";
+import {Talent} from "../data/talent.mjs";
+import {ATTRIBUTE} from "../data/attribute.mjs";
+
+const {ApplicationV2, HandlebarsApplicationMixin} = foundry.applications.api
+
+export class AttributeDialog extends HandlebarsApplicationMixin(ApplicationV2) {
+
+ static DEFAULT_OPTIONS = {
+ classes: ['dsa41', 'dialog', 'eigenschaft'],
+ tag: "form",
+ position: {
+ width: 480,
+ height: 800
+ },
+ window: {
+ resizable: false,
+ title: "Eigenschaft nutzen"
+ },
+ form: {
+ submitOnChange: true,
+ closeOnSubmit: false,
+ handler: AttributeDialog.#onSubmitForm
+ },
+ actions: {
+ use: AttributeDialog.#use,
+ }
+ }
+
+
+ static PARTS = {
+ form: {
+ template: 'systems/DSA_4-1/templates/dialog/attribute-dialog.hbs',
+ }
+ }
+
+ static data = {}
+
+ /**
+ *
+ * @type {Actor}
+ * @private
+ */
+ _actor = null
+
+ constructor(actor, attributeOrAdvantageId) {
+ super()
+ this._actor = actor
+ const advantage = this._actor.itemTypes["Advantage"].find(p => p._id === attributeOrAdvantageId)
+ if (advantage) {
+ const badAttribute = advantage
+ this._name = badAttribute.name
+ this._value = badAttribute.system.value
+ this._flaw = true
+ this._symbol = "flaw"
+ this._text = badAttribute.system.description
+ } else {
+ this._name = attributeOrAdvantageId.name
+ this._value = this._actor.system.attribute[attributeOrAdvantageId.symbol.toLowerCase()].aktuell
+ this._flaw = false
+ this._symbol = attributeOrAdvantageId.symbol
+ }
+
+ this._circumstance = 0
+ this._mods = []
+ }
+
+ static async #onSubmitForm(event, form, formData) {
+ event.preventDefault()
+
+ this._circumstance = formData.object["circumstance"]
+ this._mods = []
+ Object.entries(formData.object).filter(([key, value]) => key.startsWith("mods.")).forEach(([key, value]) => {
+ const [_, suffix] = key.split("mods.")
+ if (value != null) {
+ this._mods.push({
+ name: suffix,
+ value: value
+ })
+ }
+
+ })
+ this.render({parts: ["form"]})
+ }
+
+
+ static async #use(event, target) {
+
+
+ let modValue = this._circumstance
+ this._mods.forEach(mod => {
+ modValue += Number(mod.value)
+ })
+
+ const targetValue = this._value + modValue
+
+ let roll = await new Roll(`1d20`).evaluate()
+ let diff = targetValue - roll.terms[0].results[0].result
+ roll.toMessage({
+ speaker: ChatMessage.getSpeaker({actor: this.actor}),
+ flavor: `${this._flaw ? "Schlechte " : ""}Eigenschaft: ${this._name}
Ergebnis: ${Math.abs(diff)}${diff > 0 ? " übrig" : " daneben"}`,
+ rollMode: game.settings.get('core', 'rollMode'),
+ });
+
+ this.close()
+ }
+
+ _configureRenderOptions(options) {
+ super._configureRenderOptions(options)
+
+ if (options.window) {
+ if (this._flaw) {
+ options.window.title = `Schlechte Eigenschaft: ${this._name}`
+ } else {
+ options.window.title = `Eigenschaft: ${this._name}`
+ }
+
+ options.position.height = 640
+ }
+
+
+ return options
+ }
+
+
+ async _prepareContext(options) {
+ const context = await super._prepareContext(options)
+ context.actor = this._actor
+ context.colorfulDice = game.settings.get('DSA_4-1', 'optional_colorfuldice')
+
+ context.text = this._text
+
+ context.dice = []
+
+ if (this._flaw) {
+ context.dice.push({
+ wert: this._value,
+ name: "",
+ tooltip: "flaw",
+ })
+ } else {
+ context.dice.push({
+ wert: this._actor.system.attribute[this._symbol.toLowerCase()].aktuell,
+ name: this._symbol.toUpperCase(),
+ tooltip: ATTRIBUTE[this._symbol.toLowerCase()],
+ })
+ }
+
+ context.mods = [] // ADV, DDV, SF that may influence this talent atleast BE
+
+ const categories = ["Advantage", "SpecialAbility"]
+ categories.forEach(category => this._actor.itemTypes[category].forEach(adv => {
+
+ const mods = adv.system.getActiveMod()
+
+ mods?.forEach(mod => {
+
+ if (mod.name) {
+
+ if (mod.name === `attribute.${this._symbol.toLowerCase()}.mod`) {
+ context.mods.push({
+ name: adv.name,
+ value: mod.value,
+ mod: adv.name + "eigenschaft",
+ active: this._mods.find(mod => mod.name === adv.name + "eigenschaft")
+ })
+ }
+
+ }
+
+ })
+
+ }))
+
+ context.value = this._value
+ context.circumstance = this._circumstance
+ context.penalty = 0
+ this._mods.forEach(mod => {
+ context.penalty += Number(mod.value)
+ })
+
+ context.modResult = context.circumstance + context.penalty
+ context.displayModResult = context.modResult > 0 ? `+${context.modResult}` : context.modResult
+
+ return context
+ }
+}
\ No newline at end of file
diff --git a/src/module/dialog/modify-liturgy.mjs b/src/module/dialog/liturgyDialog.mjs
similarity index 100%
rename from src/module/dialog/modify-liturgy.mjs
rename to src/module/dialog/liturgyDialog.mjs
diff --git a/src/module/sheets/advantageSheet.mjs b/src/module/sheets/advantageSheet.mjs
index db810b8e..957e3475 100644
--- a/src/module/sheets/advantageSheet.mjs
+++ b/src/module/sheets/advantageSheet.mjs
@@ -44,6 +44,8 @@ export class AdvantageSheet extends HandlebarsApplicationMixin(DocumentSheetV2)
event.preventDefault()
await this.document.update(formData.object) // Note: formData.object
+
+ console.log(formData.object, this.document)
}
/** @override */
@@ -56,7 +58,7 @@ export class AdvantageSheet extends HandlebarsApplicationMixin(DocumentSheetV2)
context.hasChoices = context.system.auswahl?.length > 0;
context.choices = {}
context.system.auswahl?.forEach(a => {
- context.choices[a] = a
+ context.choices[a.name] = a.name
})
context.hasModality = context.system.value != null
diff --git a/src/module/sheets/characterSheet.mjs b/src/module/sheets/characterSheet.mjs
index 9d26d1c5..d918cb5a 100644
--- a/src/module/sheets/characterSheet.mjs
+++ b/src/module/sheets/characterSheet.mjs
@@ -12,8 +12,9 @@ import {ActionManager} from "./actions/action-manager.mjs";
import {DefenseActionDialog} from "../dialog/defenseAction.mjs";
import {RestingDialog} from "../dialog/restingDialog.mjs";
import {Character} from "../documents/character.mjs";
-import {LiturgyDialog} from "../dialog/modify-liturgy.mjs";
+import {LiturgyDialog} from "../dialog/liturgyDialog.mjs";
import {TalentDialog} from "../dialog/talentDialog.mjs";
+import {AttributeDialog} from "../dialog/attributeDialog.mjs";
const {HandlebarsApplicationMixin, DocumentSheetV2} = foundry.applications.api
const {ActorSheetV2} = foundry.applications.sheets
@@ -39,7 +40,7 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
rollCombatSkill: CharacterSheet.#rollCombatSkill,
rollSkill: CharacterSheet.#rollSkill,
rollFlaw: CharacterSheet.#rollFlaw,
- roll: CharacterSheet.#dieRoll,
+ rollAttribute: CharacterSheet.#rollAttribute,
editImage: DocumentSheetV2.DEFAULT_OPTIONS.actions.editImage,
openEmbeddedDocument: CharacterSheet.#openEmbeddedDocument,
openCultureDocument: CharacterSheet.#openCultureDocument,
@@ -120,37 +121,17 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
}
}
- static #dieRoll(event, target) {
- event.preventDefault()
- const {roll} = target.dataset
- if (roll) {
- let label = dataset.label ? `[Attribut] ${dataset.label}` : ''
- 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
- }
+ static #rollAttribute(event, target) {
+
+ new AttributeDialog(this.document, {
+ name: target.dataset.name,
+ value: target.dataset.value,
+ symbol: target.dataset.symbol,
+ }).render(true)
}
static async #rollFlaw(event, target) {
- event.preventDefault()
- const {itemId} = target.dataset
- if (itemId) {
- const flaw = this.document.items.get(itemId)
- if (flaw) {
- const target = flaw.system.value
- let roll = await new Roll(`1d20`).evaluate()
- let diff = target - roll.terms[0].results[0].result
- roll.toMessage({
- speaker: ChatMessage.getSpeaker({actor: this.actor}),
- flavor: `Schlechte Eigenschaft: ${flaw.name}
Ergebnis: ${Math.abs(diff)}${diff > 0 ? " übrig" : " daneben"}`,
- rollMode: game.settings.get('core', 'rollMode'),
- });
- }
- }
+ new AttributeDialog(this.document, target.dataset.itemId).render(true)
}
static async #progressCooldown(event, target) {
diff --git a/src/packs/_source/nachteile/miserableEigenschaft.json b/src/packs/_source/nachteile/miserableEigenschaft.json
index 9a209ddc..d0f09e3e 100644
--- a/src/packs/_source/nachteile/miserableEigenschaft.json
+++ b/src/packs/_source/nachteile/miserableEigenschaft.json
@@ -6,66 +6,39 @@
"description": "Eine Eigenschaft, die der Held bei der Generierung auf einen Wert von 8 gesetzt hat (vor Einrechnung der Modifikatoren aus Rasse, Kultur, Profession und eventuellen anderen Vor- und Nachteilen), wird auf 7 gesenkt. Diese Eigenschaft kann in der späteren Laufbahn des Helden nur zu den doppelten Steigerungskosten angehoben werden. Dieser Nachteil kann mehr fach gewählt werden, allerdings für jede Eigenschaft nur einmal.",
"auswahl": [
{
- "name": "Miserable Eigenschaft: Intuition",
+ "name": "Intuition",
"mod": [
- {
- "name": "attribute.in.aktuell",
- "value": "7"
- }
]
},
{
- "name": "Miserable Eigenschaft: Klugheit",
+ "name": "Klugheit",
"mod": [
- {
- "name": "attribute.kl.aktuell",
- "value": "7"
- }
]
},
{
- "name": "Miserable Eigenschaft: Mut",
+ "name": "Mut",
"mod": [
- {
- "name": "attribute.mu.aktuell",
- "value": "7"
- }
]
},
{
- "name": "Miserable Eigenschaft: Körperkraft",
+ "name": "Körperkraft",
"mod": [
- {
- "name": "attribute.kk.aktuell",
- "value": "7"
- }
]
},
{
- "name": "Miserable Eigenschaft: Fingerfertigkeit",
+ "name": "Fingerfertigkeit",
"mod": [
- {
- "name": "attribute.ff.aktuell",
- "value": "7"
- }
]
},
{
- "name": "Miserable Eigenschaft: Gewandtheit",
+ "name": "Gewandtheit",
"mod": [
- {
- "name": "attribute.ge.aktuell",
- "value": "7"
- }
+
]
},
{
- "name": "Miserable Eigenschaft: Konstitution",
+ "name": "Konstitution",
"mod": [
- {
- "name": "attribute.ko.aktuell",
- "value": "7"
- }
]
}
]
diff --git a/src/style/atoms/_colours.scss b/src/style/atoms/_colours.scss
index e533a041..bcbe7eec 100644
--- a/src/style/atoms/_colours.scss
+++ b/src/style/atoms/_colours.scss
@@ -52,6 +52,8 @@ $attribute-die-ag-color: #d5b467;
$attribute-die-bd-color: #a3a3a3;
$attribute-die-st-color: #d6a878;
+$attribute-die-flaw-color: #6a24d8;
+
$attribute-die-co-text-color: #fff;
$attribute-die-sm-text-color: #fff;
$attribute-die-in-text-color: #fff;
@@ -62,6 +64,8 @@ $attribute-die-ag-text-color: #000;
$attribute-die-bd-text-color: #000;
$attribute-die-st-text-color: #000;
+$attribute-die-flaw-text-color: #FFF;
+
$attribute-label-color: #000;
diff --git a/src/style/molecules/_attribute-die.scss b/src/style/molecules/_attribute-die.scss
index c5ec248a..a434c284 100644
--- a/src/style/molecules/_attribute-die.scss
+++ b/src/style/molecules/_attribute-die.scss
@@ -140,5 +140,16 @@
color: colours.$attribute-die-st-text-color;
}
}
+
+ .flaw {
+
+ .die svg path {
+ fill: colours.$attribute-die-flaw-color;
+ }
+
+ .wert {
+ color: colours.$attribute-die-flaw-text-color;
+ }
+ }
}
}
diff --git a/src/templates/actor/character/main-sheet.hbs b/src/templates/actor/character/main-sheet.hbs
index dccc8ead..94027a79 100644
--- a/src/templates/actor/character/main-sheet.hbs
+++ b/src/templates/actor/character/main-sheet.hbs
@@ -18,7 +18,10 @@
| + + | ++ {{this.name}} + | ++ {{this.value}} + | +