Fiche PNJ : Autorise multi-attaques
Release Creation / build (release) Failing after 49s

This commit is contained in:
2026-04-26 15:45:53 +02:00
parent 6883cc1020
commit c6ddc96148
19 changed files with 197 additions and 60 deletions
+34
View File
@@ -265,3 +265,37 @@
.dnc-pnj-sheet .pnj-combat-grid .span-two { .dnc-pnj-sheet .pnj-combat-grid .span-two {
grid-column: 1 / -1; grid-column: 1 / -1;
} }
.dnc-pnj-sheet .pnj-attack-list {
display: flex;
flex-direction: column;
gap: @spacing-md;
}
.dnc-pnj-sheet .pnj-attack-list .section-header {
margin-bottom: 0;
}
.dnc-pnj-sheet .pnj-attack-list h3 {
margin: 0;
font-size: 0.95rem;
color: @color-ink;
}
.dnc-pnj-sheet .pnj-attack-rows {
display: flex;
flex-direction: column;
gap: @spacing-md;
}
.dnc-pnj-sheet .pnj-attack-row {
display: grid;
grid-template-columns: minmax(0, 1fr) 4.5rem max-content;
gap: @spacing-md;
align-items: end;
}
.dnc-pnj-sheet .pnj-attack-row .item-actions {
align-self: end;
gap: @spacing-sm;
}
@@ -22,7 +22,9 @@ export default class DonjonEtCiePNJSheet extends DonjonEtCieActorSheet {
...super.DEFAULT_OPTIONS.actions, ...super.DEFAULT_OPTIONS.actions,
rollPnjArmor: DonjonEtCiePNJSheet.#onRollPnjArmor, rollPnjArmor: DonjonEtCiePNJSheet.#onRollPnjArmor,
rollPnjCourage: DonjonEtCiePNJSheet.#onRollPnjCourage, rollPnjCourage: DonjonEtCiePNJSheet.#onRollPnjCourage,
rollPnjAttackDamage: DonjonEtCiePNJSheet.#onRollPnjAttackDamage rollPnjAttackDamage: DonjonEtCiePNJSheet.#onRollPnjAttackDamage,
createPnjAttack: DonjonEtCiePNJSheet.#onCreatePnjAttack,
deletePnjAttack: DonjonEtCiePNJSheet.#onDeletePnjAttack
} }
}; };
@@ -48,7 +50,7 @@ export default class DonjonEtCiePNJSheet extends DonjonEtCieActorSheet {
armorDisplay: Number(system.defense?.armure?.delta ?? 0) ? `Δ${system.defense.armure.delta}` : "—", armorDisplay: Number(system.defense?.armure?.delta ?? 0) ? `Δ${system.defense.armure.delta}` : "—",
storedArmor: Number(system.defense?.armure?.resultatProtection ?? 0) > 0 ? system.defense.armure.resultatProtection : "—", storedArmor: Number(system.defense?.armure?.resultatProtection ?? 0) > 0 ? system.defense.armure.resultatProtection : "—",
courageDisplay: Number(system.defense?.courage?.delta ?? 0) ? `Δ${system.defense.courage.delta}` : "—", courageDisplay: Number(system.defense?.courage?.delta ?? 0) ? `Δ${system.defense.courage.delta}` : "—",
hasAttackDamage: Boolean(system.attaque?.degats) pnjAttacks: this.document.getPnjAttacks()
}; };
} }
@@ -64,6 +66,16 @@ export default class DonjonEtCiePNJSheet extends DonjonEtCieActorSheet {
static async #onRollPnjAttackDamage(event) { static async #onRollPnjAttackDamage(event) {
event.preventDefault(); event.preventDefault();
return this.document.rollPnjAttackDamage(); return this.document.rollPnjAttackDamage(event.target.closest("[data-attack-index]")?.dataset.attackIndex ?? 0);
}
static async #onCreatePnjAttack(event) {
event.preventDefault();
return this.document.createPnjAttack();
}
static async #onDeletePnjAttack(event) {
event.preventDefault();
return this.document.deletePnjAttack(event.target.closest("[data-attack-index]")?.dataset.attackIndex ?? 0);
} }
} }
+50 -4
View File
@@ -14,6 +14,12 @@ import { DonjonEtCieUtility } from "./donjon-et-cie-utility.mjs";
import { DonjonEtCieRollDialog } from "./applications/donjon-et-cie-roll-dialog.mjs"; import { DonjonEtCieRollDialog } from "./applications/donjon-et-cie-roll-dialog.mjs";
export class DonjonEtCieActor extends Actor { export class DonjonEtCieActor extends Actor {
static defaultPnjAttack = {
nom: "Attaque",
degats: "1d6",
notes: ""
};
prepareDerivedData() { prepareDerivedData() {
super.prepareDerivedData(); super.prepareDerivedData();
@@ -163,6 +169,45 @@ export class DonjonEtCieActor extends Actor {
if (item?.type === "entrainement") return item.resetUsageDie(); if (item?.type === "entrainement") return item.resetUsageDie();
} }
getPnjAttacks() {
if (this.type !== "pnj") return [];
const attacks = Array.isArray(this.system.attaques) ? this.system.attaques : [];
if (attacks.length) return attacks.map((attack, index) => ({
index,
nom: attack.nom || `Attaque ${index + 1}`,
degats: attack.degats || "",
notes: attack.notes || ""
}));
const legacy = this.system.attaque;
if (legacy) {
return [{
index: 0,
nom: legacy.nom || "Attaque",
degats: legacy.degats || "",
notes: legacy.notes || ""
}];
}
return [{ index: 0, ...foundry.utils.deepClone(this.constructor.defaultPnjAttack) }];
}
async createPnjAttack() {
if (this.type !== "pnj") return null;
const attaques = this.getPnjAttacks().map(({ nom, degats, notes }) => ({ nom, degats, notes }));
attaques.push(foundry.utils.deepClone(this.constructor.defaultPnjAttack));
return this.update({ "system.attaques": attaques });
}
async deletePnjAttack(index) {
if (this.type !== "pnj") return null;
const attaques = this.getPnjAttacks().map(({ nom, degats, notes }) => ({ nom, degats, notes }));
attaques.splice(Number(index), 1);
if (!attaques.length) attaques.push(foundry.utils.deepClone(this.constructor.defaultPnjAttack));
return this.update({ "system.attaques": attaques });
}
#createPnjResourceProxy({ label, deltaPath, protectionPath = null }) { #createPnjResourceProxy({ label, deltaPath, protectionPath = null }) {
const delta = Number(foundry.utils.getProperty(this, deltaPath) ?? 0); const delta = Number(foundry.utils.getProperty(this, deltaPath) ?? 0);
const protection = protectionPath ? Number(foundry.utils.getProperty(this, protectionPath) ?? 0) : 0; const protection = protectionPath ? Number(foundry.utils.getProperty(this, protectionPath) ?? 0) : 0;
@@ -203,9 +248,10 @@ export class DonjonEtCieActor extends Actor {
})); }));
} }
async rollPnjAttackDamage() { async rollPnjAttackDamage(index = 0) {
const attackName = this.system.attaque?.nom || "Attaque"; const attack = this.getPnjAttacks()[Number(index)] ?? null;
const attackDamage = this.system.attaque?.degats || ""; const attackName = attack?.nom || "Attaque";
const attackDamage = attack?.degats || "";
if (!attackDamage) return null; if (!attackDamage) return null;
return DonjonEtCieRollDialog.createDamage(this, { return DonjonEtCieRollDialog.createDamage(this, {
@@ -213,7 +259,7 @@ export class DonjonEtCieActor extends Actor {
type: "attaque", type: "attaque",
system: { system: {
degats: attackDamage, degats: attackDamage,
portee: this.system.attaque?.notes || "" portee: attack?.notes || ""
} }
}); });
} }
+8 -4
View File
@@ -13,6 +13,11 @@
export default class PnjDataModel extends foundry.abstract.TypeDataModel { export default class PnjDataModel extends foundry.abstract.TypeDataModel {
static defineSchema() { static defineSchema() {
const fields = foundry.data.fields; const fields = foundry.data.fields;
const makeAttack = () => new fields.SchemaField({
nom: new fields.StringField({ initial: "Attaque" }),
degats: new fields.StringField({ initial: "1d6" }),
notes: new fields.StringField({ initial: "" })
});
return { return {
espece: new fields.StringField({ initial: "" }), espece: new fields.StringField({ initial: "" }),
@@ -35,10 +40,9 @@ export default class PnjDataModel extends foundry.abstract.TypeDataModel {
delta: new fields.NumberField({ initial: 0, integer: true }) delta: new fields.NumberField({ initial: 0, integer: true })
}) })
}), }),
attaque: new fields.SchemaField({ attaque: makeAttack(),
nom: new fields.StringField({ initial: "Attaque" }), attaques: new fields.ArrayField(makeAttack(), {
degats: new fields.StringField({ initial: "1d6" }), initial: [{ nom: "Attaque", degats: "1d6", notes: "" }]
notes: new fields.StringField({ initial: "" })
}), }),
pouvoirsSpeciaux: new fields.HTMLField({ initial: "" }), pouvoirsSpeciaux: new fields.HTMLField({ initial: "" }),
description: new fields.HTMLField({ initial: "" }), description: new fields.HTMLField({ initial: "" }),
+1 -1
View File
@@ -1 +1 @@
MANIFEST-000035 MANIFEST-000040
+7 -11
View File
@@ -1,11 +1,7 @@
2026/04/19-18:55:51.456726 7ff1abfff6c0 Delete type=3 #1 2026/04/26-15:24:50.959107 7f57a5fef6c0 Recovering log #37
2026/04/19-19:06:36.056435 7ff1a9ffb6c0 Level-0 table #38: started 2026/04/26-15:24:50.969309 7f57a5fef6c0 Delete type=3 #35
2026/04/19-19:06:36.056473 7ff1a9ffb6c0 Level-0 table #38: 0 bytes OK 2026/04/26-15:24:50.969397 7f57a5fef6c0 Delete type=0 #37
2026/04/19-19:06:36.063121 7ff1a9ffb6c0 Delete type=0 #36 2026/04/26-15:45:09.958844 7f57977fe6c0 Level-0 table #43: started
2026/04/19-19:06:36.069412 7ff1a9ffb6c0 Manual compaction at level-0 from '!folders!K9aiFu0dE6UYiXBd' @ 72057594037927935 : 1 .. '!items!zyqLzmpbHxK3jt5q' @ 0 : 0; will stop at '!items!zyqLzmpbHxK3jt5q' @ 188 : 1 2026/04/26-15:45:09.959077 7f57977fe6c0 Level-0 table #43: 0 bytes OK
2026/04/19-19:06:36.069420 7ff1a9ffb6c0 Compacting 1@0 + 0@1 files 2026/04/26-15:45:09.966304 7f57977fe6c0 Delete type=0 #41
2026/04/19-19:06:36.073487 7ff1a9ffb6c0 Generated table #39@0: 189 keys, 41244 bytes 2026/04/26-15:45:09.985022 7f57977fe6c0 Manual compaction at level-0 from '!folders!K9aiFu0dE6UYiXBd' @ 72057594037927935 : 1 .. '!items!zyqLzmpbHxK3jt5q' @ 0 : 0; will stop at (end)
2026/04/19-19:06:36.073509 7ff1a9ffb6c0 Compacted 1@0 + 0@1 files => 41244 bytes
2026/04/19-19:06:36.079534 7ff1a9ffb6c0 compacted to: files[ 0 1 0 0 0 0 0 ]
2026/04/19-19:06:36.079617 7ff1a9ffb6c0 Delete type=2 #14
2026/04/19-19:06:36.106853 7ff1a9ffb6c0 Manual compaction at level-0 from '!items!zyqLzmpbHxK3jt5q' @ 188 : 1 .. '!items!zyqLzmpbHxK3jt5q' @ 0 : 0; will stop at (end)
+11 -4
View File
@@ -1,4 +1,11 @@
2026/04/19-18:55:51.316755 7ff1abfff6c0 Log #33: 0 ops saved to Table #34 OK 2026/04/19-18:55:51.456726 7ff1abfff6c0 Delete type=3 #1
2026/04/19-18:55:51.316821 7ff1abfff6c0 Archiving /home/morr/foundry/foundrydata-dev/Data/systems/fvtt-donjon-et-cie/packs/equipment/000033.log: OK 2026/04/19-19:06:36.056435 7ff1a9ffb6c0 Level-0 table #38: started
2026/04/19-18:55:51.316935 7ff1abfff6c0 Table #14: 189 entries OK 2026/04/19-19:06:36.056473 7ff1a9ffb6c0 Level-0 table #38: 0 bytes OK
2026/04/19-18:55:51.320226 7ff1abfff6c0 **** Repaired leveldb /home/morr/foundry/foundrydata-dev/Data/systems/fvtt-donjon-et-cie/packs/equipment; recovered 1 files; 41244 bytes. Some data may have been lost. **** 2026/04/19-19:06:36.063121 7ff1a9ffb6c0 Delete type=0 #36
2026/04/19-19:06:36.069412 7ff1a9ffb6c0 Manual compaction at level-0 from '!folders!K9aiFu0dE6UYiXBd' @ 72057594037927935 : 1 .. '!items!zyqLzmpbHxK3jt5q' @ 0 : 0; will stop at '!items!zyqLzmpbHxK3jt5q' @ 188 : 1
2026/04/19-19:06:36.069420 7ff1a9ffb6c0 Compacting 1@0 + 0@1 files
2026/04/19-19:06:36.073487 7ff1a9ffb6c0 Generated table #39@0: 189 keys, 41244 bytes
2026/04/19-19:06:36.073509 7ff1a9ffb6c0 Compacted 1@0 + 0@1 files => 41244 bytes
2026/04/19-19:06:36.079534 7ff1a9ffb6c0 compacted to: files[ 0 1 0 0 0 0 0 ]
2026/04/19-19:06:36.079617 7ff1a9ffb6c0 Delete type=2 #14
2026/04/19-19:06:36.106853 7ff1a9ffb6c0 Manual compaction at level-0 from '!items!zyqLzmpbHxK3jt5q' @ 188 : 1 .. '!items!zyqLzmpbHxK3jt5q' @ 0 : 0; will stop at (end)
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
MANIFEST-000022 MANIFEST-000027
+7 -11
View File
@@ -1,11 +1,7 @@
2026/04/19-18:55:51.477710 7ff1abfff6c0 Delete type=3 #1 2026/04/26-15:24:50.974308 7f57a57ee6c0 Recovering log #24
2026/04/19-19:06:36.063191 7ff1a9ffb6c0 Level-0 table #25: started 2026/04/26-15:24:50.984638 7f57a57ee6c0 Delete type=3 #22
2026/04/19-19:06:36.063213 7ff1a9ffb6c0 Level-0 table #25: 0 bytes OK 2026/04/26-15:24:50.984738 7f57a57ee6c0 Delete type=0 #24
2026/04/19-19:06:36.069246 7ff1a9ffb6c0 Delete type=0 #23 2026/04/26-15:45:09.972734 7f57977fe6c0 Level-0 table #30: started
2026/04/19-19:06:36.079744 7ff1a9ffb6c0 Manual compaction at level-0 from '!tables!PPsxQgHwLCQ2gjSW' @ 72057594037927935 : 1 .. '!tables.results!wJZXUo4q5b5vE3Dy.zFTPLMc9zOl5hISV' @ 0 : 0; will stop at '!tables.results!wJZXUo4q5b5vE3Dy.zFTPLMc9zOl5hISV' @ 208 : 1 2026/04/26-15:45:09.972793 7f57977fe6c0 Level-0 table #30: 0 bytes OK
2026/04/19-19:06:36.079754 7ff1a9ffb6c0 Compacting 1@0 + 0@1 files 2026/04/26-15:45:09.978845 7f57977fe6c0 Delete type=0 #28
2026/04/19-19:06:36.084239 7ff1a9ffb6c0 Generated table #26@0: 120 keys, 28120 bytes 2026/04/26-15:45:09.985047 7f57977fe6c0 Manual compaction at level-0 from '!tables!PPsxQgHwLCQ2gjSW' @ 72057594037927935 : 1 .. '!tables.results!wJZXUo4q5b5vE3Dy.zFTPLMc9zOl5hISV' @ 0 : 0; will stop at (end)
2026/04/19-19:06:36.084267 7ff1a9ffb6c0 Compacted 1@0 + 0@1 files => 28120 bytes
2026/04/19-19:06:36.090555 7ff1a9ffb6c0 compacted to: files[ 0 1 0 0 0 0 0 ]
2026/04/19-19:06:36.090673 7ff1a9ffb6c0 Delete type=2 #5
2026/04/19-19:06:36.106868 7ff1a9ffb6c0 Manual compaction at level-0 from '!tables.results!wJZXUo4q5b5vE3Dy.zFTPLMc9zOl5hISV' @ 208 : 1 .. '!tables.results!wJZXUo4q5b5vE3Dy.zFTPLMc9zOl5hISV' @ 0 : 0; will stop at (end)
+11 -4
View File
@@ -1,4 +1,11 @@
2026/04/19-18:55:51.460010 7ff1abfff6c0 Log #20: 0 ops saved to Table #21 OK 2026/04/19-18:55:51.477710 7ff1abfff6c0 Delete type=3 #1
2026/04/19-18:55:51.460123 7ff1abfff6c0 Archiving /home/morr/foundry/foundrydata-dev/Data/systems/fvtt-donjon-et-cie/packs/random-tables/000020.log: OK 2026/04/19-19:06:36.063191 7ff1a9ffb6c0 Level-0 table #25: started
2026/04/19-18:55:51.460233 7ff1abfff6c0 Table #5: 210 entries OK 2026/04/19-19:06:36.063213 7ff1a9ffb6c0 Level-0 table #25: 0 bytes OK
2026/04/19-18:55:51.463454 7ff1abfff6c0 **** Repaired leveldb /home/morr/foundry/foundrydata-dev/Data/systems/fvtt-donjon-et-cie/packs/random-tables; recovered 1 files; 39147 bytes. Some data may have been lost. **** 2026/04/19-19:06:36.069246 7ff1a9ffb6c0 Delete type=0 #23
2026/04/19-19:06:36.079744 7ff1a9ffb6c0 Manual compaction at level-0 from '!tables!PPsxQgHwLCQ2gjSW' @ 72057594037927935 : 1 .. '!tables.results!wJZXUo4q5b5vE3Dy.zFTPLMc9zOl5hISV' @ 0 : 0; will stop at '!tables.results!wJZXUo4q5b5vE3Dy.zFTPLMc9zOl5hISV' @ 208 : 1
2026/04/19-19:06:36.079754 7ff1a9ffb6c0 Compacting 1@0 + 0@1 files
2026/04/19-19:06:36.084239 7ff1a9ffb6c0 Generated table #26@0: 120 keys, 28120 bytes
2026/04/19-19:06:36.084267 7ff1a9ffb6c0 Compacted 1@0 + 0@1 files => 28120 bytes
2026/04/19-19:06:36.090555 7ff1a9ffb6c0 compacted to: files[ 0 1 0 0 0 0 0 ]
2026/04/19-19:06:36.090673 7ff1a9ffb6c0 Delete type=2 #5
2026/04/19-19:06:36.106868 7ff1a9ffb6c0 Manual compaction at level-0 from '!tables.results!wJZXUo4q5b5vE3Dy.zFTPLMc9zOl5hISV' @ 208 : 1 .. '!tables.results!wJZXUo4q5b5vE3Dy.zFTPLMc9zOl5hISV' @ 0 : 0; will stop at (end)
Binary file not shown.
Binary file not shown.
+28
View File
@@ -469,6 +469,34 @@
.dnc-pnj-sheet .pnj-combat-grid .span-two { .dnc-pnj-sheet .pnj-combat-grid .span-two {
grid-column: 1 / -1; grid-column: 1 / -1;
} }
.dnc-pnj-sheet .pnj-attack-list {
display: flex;
flex-direction: column;
gap: 0.75rem;
}
.dnc-pnj-sheet .pnj-attack-list .section-header {
margin-bottom: 0;
}
.dnc-pnj-sheet .pnj-attack-list h3 {
margin: 0;
font-size: 0.95rem;
color: #221b18;
}
.dnc-pnj-sheet .pnj-attack-rows {
display: flex;
flex-direction: column;
gap: 0.75rem;
}
.dnc-pnj-sheet .pnj-attack-row {
display: grid;
grid-template-columns: minmax(0, 1fr) 4.5rem max-content;
gap: 0.75rem;
align-items: end;
}
.dnc-pnj-sheet .pnj-attack-row .item-actions {
align-self: end;
gap: 0.4rem;
}
.application.fvtt-donjon-et-cie.item { .application.fvtt-donjon-et-cie.item {
display: flex !important; display: flex !important;
flex-direction: column; flex-direction: column;
File diff suppressed because one or more lines are too long
+23 -16
View File
@@ -72,23 +72,30 @@
<span>Valeurs</span> <span>Valeurs</span>
<p>ARM {{armorDisplay}} · COU {{courageDisplay}}</p> <p>ARM {{armorDisplay}} · COU {{courageDisplay}}</p>
</div> </div>
<label> <section class="pnj-attack-list span-two">
<span>ATT</span> <header class="section-header">
<input type="text" name="system.attaque.nom" value="{{system.attaque.nom}}"> <h3>Attaques</h3>
</label> <button type="button" class="text-button" data-action="createPnjAttack">+ Ajouter</button>
<label> </header>
<span>Degats</span> <div class="pnj-attack-rows">
<div class="counter-field"> {{#each pnjAttacks}}
<input type="text" name="system.attaque.degats" value="{{system.attaque.degats}}"> <article class="pnj-attack-row" data-attack-index="{{this.index}}">
{{#if hasAttackDamage}} <label>
<button type="button" data-action="rollPnjAttackDamage" aria-label="Lancer les degats de l'attaque" title="Lancer les degats"><i class="fa-solid fa-burst"></i></button> <input type="text" name="system.attaques.{{this.index}}.nom" value="{{this.nom}}" aria-label="Nom de l'attaque" title="Nom de l'attaque">
{{/if}} </label>
<label>
<input type="text" name="system.attaques.{{this.index}}.degats" value="{{this.degats}}" aria-label="Dégâts" title="Dégâts">
</label>
<div class="item-actions">
{{#if this.degats}}
<button type="button" data-action="rollPnjAttackDamage" aria-label="Lancer les degats de {{this.nom}}" title="Lancer les degats"><i class="fa-solid fa-burst"></i></button>
{{/if}}
<button type="button" data-action="deletePnjAttack" aria-label="Supprimer {{this.nom}}" title="Supprimer"><i class="fa-solid fa-trash"></i></button>
</div>
</article>
{{/each}}
</div> </div>
</label> </section>
<label class="span-two">
<span>Notes d'attaque</span>
<input type="text" name="system.attaque.notes" value="{{system.attaque.notes}}">
</label>
</div> </div>
</section> </section>