diff --git a/changelog.md b/changelog.md
index 62424126..161f70c4 100644
--- a/changelog.md
+++ b/changelog.md
@@ -2,6 +2,9 @@
## 13.0.48 - Les vagabondages d'Illisys
+- Gestion des tâches à plusieurs
+ - Les tâches du monde peuvent être configurées pour être effectuées à plusieurs
+ - Une tâche à plusieurs ajoutée à un personnage permet au personnage de contribuer à la tâche commune
- suppression du type de TMR "Inconnu" des feuilles de création de signes draconiques (ce type sert uniquement pour le cas où une case saisie à la main est incorrecte)
- les jets de dés /rdd utilisent le mode de visibilité sélectionné
- Voies de Draconic
diff --git a/module/actor-sheet.js b/module/actor-sheet.js
index bd7dbacf..eac455b3 100644
--- a/module/actor-sheet.js
+++ b/module/actor-sheet.js
@@ -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 {
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) {
diff --git a/module/actor.js b/module/actor.js
index 1609ecab..37128cc6 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -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
})
}
}
diff --git a/module/actor/base-actor.js b/module/actor/base-actor.js
index 892ce17d..e68e11a4 100644
--- a/module/actor/base-actor.js
+++ b/module/actor/base-actor.js
@@ -711,8 +711,8 @@ export class RdDBaseActor extends Actor {
}
}
}
+ await this.computeEncTotal()
}
- await this.computeEncTotal()
return result;
}
diff --git a/module/item-sheet.js b/module/item-sheet.js
index 35773655..4c95f5b3 100644
--- a/module/item-sheet.js
+++ b/module/item-sheet.js
@@ -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)
}
diff --git a/module/item.js b/module/item.js
index 735b6647..5732c81c 100644
--- a/module/item.js
+++ b/module/item.js
@@ -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",
diff --git a/module/item/sheet-tache.js b/module/item/sheet-tache.js
new file mode 100644
index 00000000..b2de8174
--- /dev/null
+++ b/module/item/sheet-tache.js
@@ -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 })
+ }
+ }
+
+}
diff --git a/module/item/tache.js b/module/item/tache.js
new file mode 100644
index 00000000..5718c687
--- /dev/null
+++ b/module/item/tache.js
@@ -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
+ }
+}
diff --git a/module/misc.js b/module/misc.js
index 16075dd7..9a55fa0e 100644
--- a/module/misc.js
+++ b/module/misc.js
@@ -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
}
}
diff --git a/module/rdd-main.js b/module/rdd-main.js
index a410e9f9..27fee8a2 100644
--- a/module/rdd-main.js
+++ b/module/rdd-main.js
@@ -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
diff --git a/module/rdd-utility.js b/module/rdd-utility.js
index 955f7126..281516ac 100644
--- a/module/rdd-utility.js
+++ b/module/rdd-utility.js
@@ -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',
diff --git a/module/roll/roll-part-tache.mjs b/module/roll/roll-part-tache.mjs
index bd8fcd97..915e7e4e 100644
--- a/module/roll/roll-part-tache.mjs
+++ b/module/roll/roll-part-tache.mjs
@@ -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()
+ }
}
}
diff --git a/module/roll/roll-type-tache.mjs b/module/roll/roll-type-tache.mjs
index c0ab5f3e..bc2750c5 100644
--- a/module/roll/roll-type-tache.mjs
+++ b/module/roll/roll-type-tache.mjs
@@ -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)
}
diff --git a/template.json b/template.json
index 47e1652b..3a672be3 100644
--- a/template.json
+++ b/template.json
@@ -947,7 +947,8 @@
"nb_jet_echec": 0,
"nb_jet_succes": 0,
"cacher_points_de_tache": false,
- "itemId": ""
+ "itemId": "",
+ "tacheCommuneId": ""
},
"sort": {
"templates": ["description"],
diff --git a/templates/actor/taches.hbs b/templates/actor/taches.hbs
index cb88bc04..01fd6026 100644
--- a/templates/actor/taches.hbs
+++ b/templates/actor/taches.hbs
@@ -4,10 +4,15 @@
{{#unless (eq tache.system.competence 'Chirurgie')}}