Suppression des signes draconiques

en cas de descente des TMR, suppression des signes
draconiques éphémères durant seulement 1 round
This commit is contained in:
2025-10-15 00:24:35 +02:00
parent 35f226af5c
commit 3d732e9a8a
7 changed files with 79 additions and 69 deletions

View File

@@ -2109,7 +2109,7 @@ export class RdDActor extends RdDBaseActorSang {
/* -------------------------------------------- */ /* -------------------------------------------- */
_getSignesDraconiques(coord) { _getSignesDraconiques(coord) {
const type = TMRUtility.getTMRType(coord); const type = TMRUtility.getTMRType(coord);
return this.itemTypes["signedraconique"].filter(it => it.system.typesTMR.includes(type)); return this.itemTypes[ITEM_TYPES.signedraconique].filter(it => it.system.typesTMR.includes(type));
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@@ -2406,7 +2406,7 @@ export class RdDActor extends RdDBaseActorSang {
if (this.tmrApp) { if (this.tmrApp) {
ui.notifications.warn("Vous êtes déja dans les TMR....") ui.notifications.warn("Vous êtes déja dans les TMR....")
this.tmrApp.forceTMRDisplay() this.tmrApp.forceTMRDisplay()
return return false
} }
if (mode != 'visu' && this.isDemiReve()) { if (mode != 'visu' && this.isDemiReve()) {
ui.notifications.warn("Le personnage est déjà dans les Terres Médianes, elles s'affichent en visualisation") ui.notifications.warn("Le personnage est déjà dans les Terres Médianes, elles s'affichent en visualisation")
@@ -2414,6 +2414,7 @@ export class RdDActor extends RdDBaseActorSang {
} }
if (mode == 'visu') { if (mode == 'visu') {
await this._doDisplayTMR(mode) await this._doDisplayTMR(mode)
return false
} }
else { else {
const rencontre = this.getRencontreTMREnAttente(); const rencontre = this.getRencontreTMREnAttente();
@@ -2426,6 +2427,7 @@ export class RdDActor extends RdDBaseActorSang {
buttonLabel: 'Monter dans les TMR', buttonLabel: 'Monter dans les TMR',
onAction: async () => await this._doDisplayTMR(mode) onAction: async () => await this._doDisplayTMR(mode)
}) })
return true
} }
} }
@@ -2463,6 +2465,29 @@ export class RdDActor extends RdDBaseActorSang {
await this.tmrApp.onDeplacement() await this.tmrApp.onDeplacement()
} }
async quitterTMR(message, viewOnly, cumulFatigue) {
if (this.tmrApp) {
this.tmrApp = undefined
const appliquerFatigue = ReglesOptionnelles.isUsing("appliquer-fatigue");
await this.santeIncDec(
appliquerFatigue ? "fatigue" : "endurance",
(appliquerFatigue ? 1 : -1) * cumulFatigue)
if (!viewOnly) {
await this.supprimerSignesDraconiques(it => it.system.ephemere && it.system.duree == '1 round', { render: false })
await this.setEffect(STATUSES.StatusDemiReve, false)
ChatUtility.tellToUserAndGM(message)
}
}
}
async supprimerSignesDraconiques(filter = it => true, options = { render: true }) {
const signes = this.itemTypes[ITEM_TYPES.signedraconique].filter(filter)
if (signes.length > 0) {
this.deleteEmbeddedDocuments("Item", signes.map(item => item.id), options)
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollSoins(blesse, blessureId) { async rollSoins(blesse, blessureId) {
const blessure = blesse.blessuresASoigner().find(it => it.id == blessureId); const blessure = blesse.blessuresASoigner().find(it => it.id == blessureId);

View File

@@ -246,10 +246,10 @@ export class RdDBaseActorReve extends RdDBaseActor {
if (this.isEffectAllowed(statusId)) { if (this.isEffectAllowed(statusId)) {
const effect = this.getEffectByStatus(statusId); const effect = this.getEffectByStatus(statusId);
if (!status && effect) { if (!status && effect) {
await this.deleteEmbeddedDocuments('ActiveEffect', [effect.id]); await this.deleteEmbeddedDocuments('ActiveEffect', [effect.id], { render: true})
} }
if (status && !effect) { if (status && !effect) {
await this.createEmbeddedDocuments("ActiveEffect", [StatusEffects.prepareActiveEffect(statusId)]); await this.createEmbeddedDocuments("ActiveEffect", [StatusEffects.prepareActiveEffect(statusId)], { render: true})
} }
} }
} }

View File

@@ -116,6 +116,7 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
blessure: blessure blessure: blessure
}); });
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async santeIncDec(name, inc, isCritique = false) { async santeIncDec(name, inc, isCritique = false) {
if (name == 'fatigue' && !ReglesOptionnelles.isUsing("appliquer-fatigue")) { if (name == 'fatigue' && !ReglesOptionnelles.isUsing("appliquer-fatigue")) {
@@ -179,6 +180,26 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
return Math.max(0, Math.min(maxEndVie, maxEndGraves, maxEndCritiques)); return Math.max(0, Math.min(maxEndVie, maxEndGraves, maxEndCritiques));
} }
async onCreateItem(item, options, id) {
switch (item.type) {
case ITEM_TYPES.blessure:
await this.changeBleedingState()
break
}
}
async onUpdateItem(item, options, id) {
switch (item.type) {
case ITEM_TYPES.blessure:
await this.changeBleedingState()
break
}
}
async changeBleedingState() {
const bleeding = this.itemTypes[ITEM_TYPES.blessure].find(it => it.isBleeding())
await this.setEffect(STATUSES.StatusBleeding, bleeding ? true : false)
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async ajouterBlessure(encaissement, attackerToken = undefined) { async ajouterBlessure(encaissement, attackerToken = undefined) {

View File

@@ -248,28 +248,12 @@ export class RdDBaseActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async onPreUpdateItem(item, change, options, id) { } async onPreUpdateItem(item, change, options, id) { }
async onCreateItem(item, options, id) { async onCreateItem(item, options, id) { }
switch (item.type) {
case ITEM_TYPES.blessure:
await this.changeBleedingState()
break
}
}
async onUpdateItem(item, options, id) { async onUpdateItem(item, options, id) { }
switch (item.type) {
case ITEM_TYPES.blessure:
await this.changeBleedingState()
break
}
}
async changeBleedingState() {
const bleeding = this.itemTypes[ITEM_TYPES.blessure].find(it => it.isBleeding())
await this.setEffect(STATUSES.StatusBleeding, bleeding ? true : false)
}
async onUpdateActor(update, options, actorId) { } async onUpdateActor(update, options, actorId) { }
async onDeleteItem(item, options, id) { async onDeleteItem(item, options, id) {
if (item.isInventaire()) { if (item.isInventaire()) {
await this._removeItemFromConteneur(item) await this._removeItemFromConteneur(item)

View File

@@ -106,6 +106,25 @@ export class ChatUtility {
return await ChatMessage.create(messageData) return await ChatMessage.create(messageData)
} }
static tellToUser(message) {
ChatMessage.create({ content: message, user: game.user.id, whisper: [game.user.id] });
}
static tellToGM(message) {
ChatMessage.create({
user: game.user.id,
content: message,
whisper: ChatUtility.getGMs()
});
}
static tellToUserAndGM(message) {
ChatMessage.create({
user: game.user.id,
content: message,
whisper: ChatUtility.getUserAndGMs()
})
}
static getOwners(document) { static getOwners(document) {
return document ? game.users.filter(it => document.getUserLevel(it) == CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER) : [game.user] return document ? game.users.filter(it => document.getUserLevel(it) == CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER) : [game.user]
} }

View File

@@ -461,12 +461,7 @@ export class RdDCommands {
async supprimerSignesDraconiquesEphemeres() { async supprimerSignesDraconiquesEphemeres() {
if (game.user.isGM) { if (game.user.isGM) {
game.actors.forEach(actor => { game.actors.forEach(actor => actor.supprimerSignesDraconiques(it => it.system.ephemere))
const ephemeres = actor.items.filter(item => item.type = 'signedraconique' && item.system.ephemere);
if (ephemeres.length > 0) {
actor.deleteEmbeddedDocuments("Item", ephemeres.map(item => item.id));
}
});
} }
else { else {
ui.notifications.warn("Seul le MJ est autorisé à utiliser la commande /signe"); ui.notifications.warn("Seul le MJ est autorisé à utiliser la commande /signe");

View File

@@ -82,7 +82,7 @@ export class RdDTMRDialog extends Dialog {
this.subdialog = undefined this.subdialog = undefined
this.displaySize = undefined this.displaySize = undefined
if (!this.viewOnly && !game.user.isGM) { if (!this.viewOnly && !game.user.isGM) {
this.$tellToGM(this.actor.name + " monte dans les terres médianes (" + tmrData.mode + ")"); ChatUtility.tellToGM(this.actor.name + " monte dans les terres médianes (" + tmrData.mode + ")");
} }
this.callbacksOnAnimate = []; this.callbacksOnAnimate = [];
const displaySize = TMR_DISPLAY_SIZE.clamp(game.settings.get(SYSTEM_RDD, TMR_DISPLAY_SIZE.code) ?? TMR_DISPLAY_SIZE.def); const displaySize = TMR_DISPLAY_SIZE.clamp(game.settings.get(SYSTEM_RDD, TMR_DISPLAY_SIZE.code) ?? TMR_DISPLAY_SIZE.def);
@@ -343,19 +343,8 @@ export class RdDTMRDialog extends Dialog {
this.forceTMRContinueAction() this.forceTMRContinueAction()
return false return false
} }
this.descenteTMR = true; this.descenteTMR = true
if (this.actor.tmrApp) { await await this.actor.quitterTMR(message, this.viewOnly, this.cumulFatigue)
this.actor.tmrApp = undefined // Cleanup reference
const appliquerFatigue = ReglesOptionnelles.isUsing("appliquer-fatigue")
await this.actor.santeIncDec(
appliquerFatigue ? "fatigue" : "endurance",
(appliquerFatigue ? 1 : -1) * this.cumulFatigue)
if (!this.viewOnly) {
await this.actor.setEffect(STATUSES.StatusDemiReve, false)
this.$tellToUserAndGM(message)
}
}
this.pixiTMR.close(); this.pixiTMR.close();
this.pixiTMR = undefined this.pixiTMR = undefined
await super.close(); await super.close();
@@ -412,7 +401,7 @@ export class RdDTMRDialog extends Dialog {
async $ignorerRencontre() { async $ignorerRencontre() {
if (this.currentRencontre) { if (this.currentRencontre) {
console.log("-> ignorer", this.currentRencontre); console.log("-> ignorer", this.currentRencontre);
this.$tellToGM(this.actor.name + " a ignoré: " + this.currentRencontre.name); ChatUtility.tellToGM(this.actor.name + " a ignoré: " + this.currentRencontre.name);
await this.$deleteRencontreTMRAtPosition() await this.$deleteRencontreTMRAtPosition()
this.updateTokens(); this.updateTokens();
this.$updateValuesDisplay(); this.$updateValuesDisplay();
@@ -578,29 +567,6 @@ export class RdDTMRDialog extends Dialog {
}, 500); }, 500);
} }
/* -------------------------------------------- */
_tellToUser(message) {
ChatMessage.create({ content: message, user: game.user.id, whisper: [game.user.id] });
}
/* -------------------------------------------- */
$tellToGM(message) {
ChatMessage.create({
user: game.user.id,
content: message,
whisper: ChatUtility.getGMs()
});
}
/* -------------------------------------------- */
$tellToUserAndGM(message) {
ChatMessage.create({
user: game.user.id,
content: message,
whisper: ChatUtility.getUserAndGMs()
})
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async manageRencontre(tmr) { async manageRencontre(tmr) {
if (this.viewOnly) { if (this.viewOnly) {
@@ -680,10 +646,10 @@ export class RdDTMRDialog extends Dialog {
const myRoll = await RdDDice.rollTotal("1dt", { showDice: SHOW_DICE }); const myRoll = await RdDDice.rollTotal("1dt", { showDice: SHOW_DICE });
this.restoreTMRAfterAction() this.restoreTMRAfterAction()
if (myRoll == 7) { if (myRoll == 7) {
this._tellToUser(myRoll + ": Rencontre en " + coordTMR); ChatUtility.tellToUser(myRoll + ": Rencontre en " + coordTMR);
return await game.system.rdd.rencontresTMR.getRencontreAleatoire(tmr, this.actor.isMauvaiseRencontre()) return await game.system.rdd.rencontresTMR.getRencontreAleatoire(tmr, this.actor.isMauvaiseRencontre())
} else { } else {
this._tellToUser(myRoll + ": Pas de rencontre en " + coordTMR); ChatUtility.tellToUser(myRoll + ": Pas de rencontre en " + coordTMR);
return undefined; return undefined;
} }
} }