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
+3
View File
@@ -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
+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) {
+21 -9
View File
@@ -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)))
+1 -1
View File
@@ -711,8 +711,8 @@ export class RdDBaseActor extends Actor {
}
}
}
}
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',
+11 -5
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,11 +84,14 @@ export class RollPartTache extends RollPartSelect {
}
onCreateUpdateItem(rollDialog, item, options, id) {
if (item.type == ITEM_TYPES.tache && item.parent?.id == rollDialog.rollData.active.actor.id) {
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()
}
}
}
impactOtherPart(part, rollData) {
if (this.visible(rollData)) {
+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)
}
+2 -1
View File
@@ -947,7 +947,8 @@
"nb_jet_echec": 0,
"nb_jet_succes": 0,
"cacher_points_de_tache": false,
"itemId": ""
"itemId": "",
"tacheCommuneId": ""
},
"sort": {
"templates": ["description"],
+6 -1
View File
@@ -4,10 +4,15 @@
{{#unless (eq tache.system.competence 'Chirurgie')}}
<li class="item flexrow list-item" data-item-id="{{tache._id}}" data-tooltip="Tâche: {{tache.name}}" >
<img class="sheet-competence-img" src="{{tache.img}}"/>
<span class="list-item-label"><a class="action-tache">{{tache.name}}
<span class="list-item-label"><a class="action-tache">
{{> 'systems/foundryvtt-reve-de-dragon/templates/item/tache-commune-flag.hbs' tache}}
{{tache.name}}
({{tache.system.points_de_tache_courant}}{{#if
(or @root.options.isGM (not tache.system.cacher_points_de_tache))
}}/{{tache.system.points_de_tache}}{{/if}})</a></span>
{{#if tache.system.tacheCommuneId}}
{{/if}}
{{>'systems/foundryvtt-reve-de-dragon/templates/actor/item-action-controls.hbs' item=tache options=@root.options}}
</li>
{{/unless}}
+4
View File
@@ -1,5 +1,9 @@
{{#each @root.competences as |competence key|}}
{{#if (or (not ../categorie) (eq competence.system.categorie ../categorie))}}
{{#if competence.id}}
<option value="{{competence.name}}">{{competence.name}}</option>
{{else}}
<option value="">{{competence.name}}</option>
{{/if}}
{{/if}}
{{/each}}
+4
View File
@@ -0,0 +1,4 @@
{{#if system.tacheCommuneId}}
<i class="fa-solid fa-people-group"
data-tooltip="Tâche commune partagée entre plusieurs personnages"></i>
{{/if}}
+32 -4
View File
@@ -2,9 +2,27 @@
{{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-header.hbs"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
{{#if options.isOwned}}
{{#if system.tacheCommuneId}}
<div class="form-group">
<label>
{{> 'systems/foundryvtt-reve-de-dragon/templates/item/tache-commune-flag.hbs' this}}
Tâche à plusieurs
</label>
</div>
{{/if}}
{{else}}
<div class="form-group" data-tooltip="Une tâche à plusieurs ajoutée à des personnages sera partagée entre tous ces personnages">
<label>
{{> 'systems/foundryvtt-reve-de-dragon/templates/item/tache-commune-flag.hbs' this}}
Tâche à plusieurs
</label>
<input name="is-tache-partagee" class="attribute-value" type="checkbox" {{#if system.tacheCommuneId}}checked{{/if}}/>
</div>
{{/if}}
<div class="form-group">
<label for="system.carac">Caractéristique</label>
<select name="system.carac" data-dtype="String">
<select name="system.carac" data-dtype="String" {{#if disabled}}disabled{{/if}} >
{{#select system.carac}}
{{#each caracList as |carac key|}}
<option value="{{key}}">{{carac.label}}</option>
@@ -14,9 +32,8 @@
</div>
<div class="form-group">
<label for="system.competence">Compétence</label>
<select name="system.competence" data-dtype="String">
<select name="system.competence" data-dtype="String" {{#if disabled}}disabled{{/if}}>
{{#select system.competence}}
<option value="">Sans compétence</option>
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-competence.hbs"}}
{{/select}}
</select>
@@ -24,27 +41,33 @@
<div class="form-group">
<label for="system.difficulte">Difficulté</label>
<input name="system.difficulte" value="{{system.difficulte}}" min="-10" max="10"
{{#if disabled}}disabled{{/if}}
class="attribute-value" type="number" data-dtype="Number"/>
</div>
<div class="form-group">
<label for="system.periodicite">Périodicité</label>
<input name="system.periodicite" value="{{system.periodicite}}"
{{#if disabled}}disabled{{/if}}
class="attribute-value" type="text" data-dtype="String"/>
</div>
<div class="form-group">
<label for="system.fatigue">Fatigue</label>
<input name="system.fatigue" value="{{system.fatigue}}" min="0" max="10"
{{#if disabled}}disabled{{/if}}
class="attribute-value" type="number" data-dtype="Number"/>
</div>
{{#if options.isGM}}
<div class="form-group">
<label for="system.cacher_points_de_tache">Cacher les Points de Tâches nécessaires au joueur</label>
<input name="system.cacher_points_de_tache"
{{#if disabled}}disabled{{/if}}
class="attribute-value" type="checkbox" {{checked system.cacher_points_de_tache}}/>
</div>
<div class="form-group">
<label for="system.points_de_tache">Points de tâches nécessaires (MJ)</label>
<input name="system.points_de_tache" value="{{system.points_de_tache}}" min="1"
{{#if disabled}}disabled{{/if}}
class="attribute-value" type="number" data-dtype="Number"/>
</div>
{{else}}
@@ -53,7 +76,9 @@
<label for="system.points_de_tache">Points de tâches nécessaires inconnus</label>
{{else}}
<label for="system.points_de_tache">Points de tâches nécessaires</label>
<input class="attribute-value" type="text" name="system.points_de_tache" value="{{system.points_de_tache}}" data-dtype="Number"/>
<input class="attribute-value" name="system.points_de_tache" value="{{system.points_de_tache}}"
{{#if disabled}}disabled{{/if}}
type="number" data-dtype="Number"/>
{{/if}}
</div>
{{/if}}
@@ -61,16 +86,19 @@
<div class="form-group">
<label for="system.points_de_tache_courant">Points de tâches obtenus</label>
<input name="system.points_de_tache_courant" value="{{system.points_de_tache_courant}}" min="-4" max="{{system.points_de_tache}}"
{{#if disabled}}disabled{{/if}}
class="attribute-value" type="number" data-dtype="Number"/>
</div>
<div class="form-group">
<label for="system.nb_jet_succes">Nombre de Succès</label>
<input name="system.nb_jet_succes" value="{{system.nb_jet_succes}}" min="0"
{{#if disabled}}disabled{{/if}}
class="attribute-value" type="number" data-dtype="Number" {{#if options.isGM}}{{else}}disabled{{/if}}/>
</div>
<div class="form-group">
<label for="system.nb_jet_echec">Nombre d'Echecs</label>
<input name="system.nb_jet_echec" value="{{system.nb_jet_echec}}" min="0"
{{#if disabled}}disabled{{/if}}
class="attribute-value" type="number" data-dtype="Number" {{#if options.isGM}}{{else}}disabled{{/if}}/>
</div>
+1 -1
View File
@@ -2,7 +2,7 @@
<div class="form-group">
<label for="roll-text">Compétence</label>
<select name="roll-text" class="roll-text" data-dtype="String">
{{#select ''}}<option value="">Sans compétence</option>
{{#select ''}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-competence.hbs"}}
{{/select}}
</select>
+1
View File
@@ -16,6 +16,7 @@
</subline>
{{#if refs.taches.length}}
<subline>
{{> 'systems/foundryvtt-reve-de-dragon/templates/item/tache-commune-flag.hbs' current.tache}}
Points de tâche: {{current.tache.system.points_de_tache_courant}} /
{{#if current.tache.system.cacher_points_de_tache}}
(inconnus)