ENhance and fix
This commit is contained in:
@@ -57,7 +57,7 @@ export class ChiaroscuroDiceDialog extends FormApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param options actor, actorId, ringId, skillId
|
||||
* @param options actor, actorId, ringId, skillId, itemUuid
|
||||
*/
|
||||
constructor(options = {}) {
|
||||
super({}, options);
|
||||
@@ -74,6 +74,9 @@ export class ChiaroscuroDiceDialog extends FormApplication {
|
||||
}
|
||||
});
|
||||
|
||||
// Resolve item from uuid (weapon, technique, etc.)
|
||||
this._item = options.itemUuid ? fromUuidSync(options.itemUuid) : null;
|
||||
|
||||
// Default ring: options > actor default_ring > void
|
||||
const ringId = options.ringId ?? this._actor?.system?.default_ring ?? "void";
|
||||
this.ringId = ringId;
|
||||
@@ -272,32 +275,8 @@ export class ChiaroscuroDiceDialog extends FormApplication {
|
||||
[`${aspectsPath}.solar`]: 0,
|
||||
[`${aspectsPath}.lunar`]: 0,
|
||||
});
|
||||
// Remove all desequilibre conditions
|
||||
const toRemove = this._actor.items
|
||||
.filter((i) => i.type === "etat" && ["desequilibre_solaire", "desequilibre_lunaire"].includes(i.system?.condition_type))
|
||||
.map((i) => i.id);
|
||||
if (toRemove.length) {
|
||||
await this._actor.deleteEmbeddedDocuments("Item", toRemove);
|
||||
}
|
||||
} else {
|
||||
await this._actor.update({ [`${aspectsPath}.gauge`]: newGauge });
|
||||
|
||||
if (Math.abs(newGauge) >= 5) {
|
||||
// Apply opposing desequilibre
|
||||
const condType = this.object.aspectType === "solar" ? "desequilibre_lunaire" : "desequilibre_solaire";
|
||||
const existing = this._actor.items.find(
|
||||
(i) => i.type === "etat" && i.system?.condition_type === condType
|
||||
);
|
||||
if (!existing) {
|
||||
await this._actor.createEmbeddedDocuments("Item", [
|
||||
{
|
||||
type: "etat",
|
||||
name: game.i18n.localize(`chiaroscuro.aspects.${condType}`),
|
||||
system: { condition_type: condType },
|
||||
},
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,6 +300,9 @@ export class ChiaroscuroDiceDialog extends FormApplication {
|
||||
useAssistance: this.object.useAssistance,
|
||||
modifier: this.object.modifier,
|
||||
quickInfo: this._actor?.system?.quick_info ?? "",
|
||||
l5r5e: {
|
||||
item: this._item ?? null,
|
||||
},
|
||||
...rollData,
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user