Support des tâches à plusieurs
Release Creation / build (release) Successful in 1m50s

This commit was merged in pull request #820.
This commit is contained in:
2026-07-11 16:12:15 +02:00
parent 66a8eb0e8a
commit 7d5903aa84
20 changed files with 177 additions and 42 deletions
+16
View File
@@ -70,6 +70,7 @@ export class RdDActorSheet extends RdDBaseActorSangSheet {
fatigue: RdDUtility.calculFatigueHtml(formData.system.sante.fatigue.value, formData.system.sante.endurance.max)
})
this.amendTacheCommunes(formData)
formData.competences.forEach(item => {
item.system.isHidden = this.options.recherche
@@ -111,9 +112,24 @@ export class RdDActorSheet extends RdDBaseActorSangSheet {
<br>Ajoutez-lui la tête "Don de Haut-Rêve" pour lui permettre d'utiliser ses compétences et d'accéder aux terres médianes du rêve`);
}
}
else {
console.error("Ouverture actor-sheet avec un acteur non personnage")
}
return formData;
}
amendTacheCommunes(formData) {
formData.taches
.forEach(tache => {
if (tache.isTacheCommune()) {
const tacheCommune = tache.getTacheOuCommune()
tache.system = foundry.utils.duplicate(tacheCommune.system)
tache.system.tacheCommuneId = tache.system.tacheCommuneId
}
return tache
})
}
/* -------------------------------------------- */
/** @override */
activateListeners(html) {
+23 -11
View File
@@ -1883,7 +1883,7 @@ export class RdDActor extends RdDBaseActorSang {
const rollData = {
ids: { actorId: this.id },
selected: { tache: { key: tache.id, forced: options.forced } },
type: { allowed: [ROLL_TYPE_TACHE], current: ROLL_TYPE_TACHE}
type: { allowed: [ROLL_TYPE_TACHE], current: ROLL_TYPE_TACHE }
}
return await RollDialog.create(rollData, options)
}
@@ -1912,22 +1912,34 @@ export class RdDActor extends RdDBaseActorSang {
/* -------------------------------------------- */
async _tacheResult(rollData, options) {
// Mise à jour de la tache
rollData.appliquerFatigue = ReglesOptionnelles.isUsing("appliquer-fatigue");
rollData.tache = foundry.utils.duplicate(rollData.tache);
rollData.tache.system.points_de_tache_courant += rollData.rolled.ptTache;
rollData.appliquerFatigue = ReglesOptionnelles.isUsing("appliquer-fatigue")
const tacheCommuneId = rollData.tache.system.tacheCommuneId;
const tache = tacheCommuneId
? game.items.get(tacheCommuneId)
: this.items.get(rollData.tache.id)
const tacheUpdates = {
system: {
points_de_tache_courant: tache.system.points_de_tache_courant + rollData.rolled.ptTache,
tentatives: tache.system.tentatives + 1
}
}
if (rollData.rolled.isETotal) {
rollData.tache.system.difficulte--;
tacheUpdates.system['difficulte'] = tache.system.difficulte - 1
}
if (rollData.rolled.isSuccess) {
rollData.tache.system.nb_jet_succes++;
tacheUpdates.system['nb_jet_succes'] = tache.system.nb_jet_succes + 1;
} else {
rollData.tache.system.nb_jet_echec++;
tacheUpdates.system['nb_jet_echec'] = tache.tache.system.nb_jet_echec + 1
}
rollData.tache.system.tentatives = rollData.tache.system.nb_jet_succes + rollData.tache.system.nb_jet_echec;
await this.updateEmbeddedDocuments('Item', [rollData.tache]);
await tache.update(tacheUpdates)
await this.santeIncDec("fatigue", rollData.tache.system.fatigue);
if (rollData.tache.system.tacheCommuneId != "") {
rollData.tache.render()
}
await RdDRollResult.displayRollData(rollData, this, 'chat-resultat-tache.hbs');
if (options?.callbacks) {
await Promise.all(callbacks.map(callback => callback(rollData)))
@@ -2422,7 +2434,7 @@ export class RdDActor extends RdDBaseActorSang {
onRollDone: RollDialog.onRollDoneClose,
verb: "applique des soins complets à",
title: "Soins complets",
forced: true
forced: true
})
}
}
+1 -1
View File
@@ -711,8 +711,8 @@ export class RdDBaseActor extends Actor {
}
}
}
await this.computeEncTotal()
}
await this.computeEncTotal()
return result;
}
+1 -1
View File
@@ -105,7 +105,7 @@ export class RdDItemSheetV1 extends foundry.appv1.sheets.ItemSheet {
descriptionmj: await RdDTextEditor.enrichHTML(this.item.system.descriptionmj, this.item),
isComestible: this.item.getUtilisationCuisine(),
options: RdDSheetUtility.mergeDocumentRights({}, this.item, this.isEditable),
competences: [new RdDItemCompetence(SANS_COMPETENCE), ...competences],
competences: [SANS_COMPETENCE, ...competences],
categories: RdDItem.getCategories(this.item.type),
isAppreciable: Apprecier.isAppreciable(this.item)
}
+1
View File
@@ -79,6 +79,7 @@ export const defaultItemImg = {
sort: "systems/foundryvtt-reve-de-dragon/icons/competence_oniros.webp",
sortreserve: "systems/foundryvtt-reve-de-dragon/icons/competence_oniros.webp",
souffle: "systems/foundryvtt-reve-de-dragon/icons/souffle_dragon.webp",
tache: "systems/foundryvtt-reve-de-dragon/assets/actions/tache.svg",
tarot: "systems/foundryvtt-reve-de-dragon/icons/tarots/dos-tarot.webp",
tete: "systems/foundryvtt-reve-de-dragon/icons/tete_dragon.webp",
monnaie: "systems/foundryvtt-reve-de-dragon/icons/objets/piece_etain_poisson.webp",
+33
View File
@@ -0,0 +1,33 @@
import { ITEM_TYPES } from "../constants.js";
// import { RdDItemTache } from "tache.js";
import { RdDItemSheetV1 } from "../item-sheet.js";
export class RdDTacheItemSheet extends RdDItemSheetV1 {
static get ITEM_TYPE() { return ITEM_TYPES.tache };
async getData() {
const formData = await super.getData()
if (this.item.system.tacheCommuneId) {
formData.tacheCommune = game.items.get(this.item.system.tacheCommuneId);
formData.system = formData.tacheCommune.system
formData.disabled = this.item.actor != undefined
}
return formData
}
activateListeners(html) {
super.activateListeners(html);
this.html.find('input[name="is-tache-partagee"]').click((event) => this.checktacheCommune(event.currentTarget.checked))
}
async checktacheCommune(checked) {
if (!this.item.parent) {
const tacheCommuneId = checked ? this.item.id : ""
this.item.update({ 'system.tacheCommuneId': tacheCommuneId })
}
}
}
+17
View File
@@ -0,0 +1,17 @@
import { RdDItem } from "../item.js";
export class RdDItemTache extends RdDItem {
static get defaultIcon() {
return "systems/foundryvtt-reve-de-dragon/assets/actions/tache.svg"
}
isTacheCommune() {
return this.system.tacheCommuneId != ""
}
getTacheOuCommune() {
if (this.isTacheCommune()) {
return game.items.get(this.system.tacheCommuneId)
}
return this
}
}
+1 -1
View File
@@ -231,7 +231,7 @@ export class Misc {
*/
static documentIfResponsible(document) {
if (Misc.isFirstConnectedGM() || (Misc.connectedGMs().length == 0 && Misc.isFirstOwnerPlayer(document))) {
if (document.isOwner) {
if (document?.isOwner) {
return document
}
}
+4
View File
@@ -60,6 +60,7 @@ import { RdDItemRace } from "./item/race.js"
import { RdDItemSigneDraconique } from "./item/signedraconique.js"
import { RdDItemSort } from "./item-sort.js"
import { RdDItemSouffle } from "./item/souffle.js"
import { RdDItemTache } from "./item/tache.js"
import { RdDItemTete } from "./item/tete.js"
import { RdDRencontre } from "./item/rencontre.js"
@@ -76,6 +77,7 @@ import { RdDPotionItemSheet } from "./item/sheet-potion.js"
import { RdDRencontreItemSheet } from "./item/sheet-rencontre.js"
import { RdDServiceItemSheet } from "./item/sheet-service.js"
import { RdDSigneDraconiqueItemSheet } from "./item/sheet-signedraconique.js"
import { RdDTacheItemSheet } from "./item/sheet-tache.js"
import { AppAstrologie } from "./sommeil/app-astrologie.js"
import { AutoAdjustDarkness } from "./time/auto-adjust-darkness.js"
@@ -134,6 +136,7 @@ export class SystemReveDeDragon {
service: RdDItemService,
signedraconique: RdDItemSigneDraconique,
souffle: RdDItemSouffle,
tache: RdDItemTache,
tarot: items.RdDModelTarot,
tete: RdDItemTete,
}
@@ -285,6 +288,7 @@ export class SystemReveDeDragon {
RdDItemSheetV1.register(RdDRencontreItemSheet)
RdDItemSheetV1.register(RdDServiceItemSheet)
RdDItemSheetV1.register(RdDSigneDraconiqueItemSheet)
RdDItemSheetV1.register(RdDTacheItemSheet)
RdDJournalSheet.register()
// préparation des différents modules
+1
View File
@@ -191,6 +191,7 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/item/enum-appreciation-bonmoment.hbs',
'systems/foundryvtt-reve-de-dragon/templates/item/enum-appreciation-carac.hbs',
'systems/foundryvtt-reve-de-dragon/templates/item/enum-appreciation-moral.hbs',
'systems/foundryvtt-reve-de-dragon/templates/item/tache-commune-flag.hbs',
// partial enums
'systems/foundryvtt-reve-de-dragon/templates/enum-aspect-tarot.hbs',
'systems/foundryvtt-reve-de-dragon/templates/enum-base-competence.hbs',
+13 -7
View File
@@ -22,8 +22,8 @@ export class RollPartTache extends RollPartSelect {
refs.forced = selected.forced
refs.all = rollData.active.actor.itemTypes[ITEM_TYPES.tache]
.filter(tache => !selected.forced || tache.id == selected.key)
.filter(tache => tache.system.points_de_tache_courant < tache.system.points_de_tache)
.map(tache => RollPartTache.$extractTache(tache, rollData.active.actor))
.filter(extract => !extract.finished)
refs.taches = refs.all
if (refs.taches.length > 0) {
@@ -34,12 +34,15 @@ export class RollPartTache extends RollPartSelect {
choices(refs) { return refs.taches }
static $extractTache(tache, actor) {
const tacheOuCommune = tache.getTacheOuCommune()
return {
key: tache.id,
label: tache.name,
value: tache.system.difficulte,
tache: tache,
comp: actor.getCompetence(tache.system.competence)
tacheCommune: tache.system.tacheCommune,
value: tacheOuCommune.system.difficulte,
tache: tacheOuCommune,
comp: actor.getCompetence(tacheOuCommune.system.competence),
finished: tacheOuCommune.system.points_de_tache_courant >= tacheOuCommune.system.points_de_tache
}
}
@@ -81,9 +84,12 @@ export class RollPartTache extends RollPartSelect {
}
onCreateUpdateItem(rollDialog, item, options, id) {
if (item.type == ITEM_TYPES.tache && item.parent?.id == rollDialog.rollData.active.actor.id) {
this.loadRefs(rollDialog.rollData)
rollDialog.render()
if (item.type == ITEM_TYPES.tache) {
if (item.parent?.id == rollDialog.rollData.active.actor.id || item.isTacheCommune()) {
// TODO: filtrer davantage
this.loadRefs(rollDialog.rollData)
rollDialog.render()
}
}
}
+2 -3
View File
@@ -22,15 +22,14 @@ export class RollTypeTache extends RollType {
static async $onRollTache(rollData) {
const actor = rollData.active.actor
const tache = rollData.current[PART_TACHE].tache
const tache = rollData.current[PART_TACHE].tache.getTacheOuCommune()
rollData.current[PART_TACHE].tache = await tache.update({
await tache.update({
'system.points_de_tache_courant': tache.system.points_de_tache_courant + rollData.rolled.ptTache,
'system.nb_jet_succes': tache.system.nb_jet_succes + (rollData.rolled.isSuccess ? 1 : 0),
'system.nb_jet_echec': tache.system.nb_jet_echec + (rollData.rolled.isSuccess ? 0 : 1),
'system.difficulte': tache.system.difficulte - (rollData.rolled.isETotal ? 1 : 0),
}, { render: true })
if (ReglesOptionnelles.isUsing("appliquer-fatigue")) {
await actor.santeIncDec("fatigue", tache.system.fatigue)
}