forked from public/foundryvtt-reve-de-dragon
Nouvelle fenêtre de jets de dés
This commit is contained in:
@@ -8,7 +8,7 @@ import { RdDUtility } from "../rdd-utility.js";
|
||||
import { ReglesOptionnelles } from "../settings/regles-optionnelles.js";
|
||||
import { RdDBaseActor } from "./base-actor.js";
|
||||
import { ITEM_TYPES } from "../constants.js";
|
||||
import { StatusEffects } from "../settings/status-effects.js";
|
||||
import { StatusEffects, STATUSES } from "../settings/status-effects.js";
|
||||
import { Targets } from "../targets.js";
|
||||
import { RdDConfirm } from "../rdd-confirm.js";
|
||||
import { RdDCarac } from "../rdd-carac.js";
|
||||
@@ -172,8 +172,11 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
||||
idOrName, options)
|
||||
}
|
||||
|
||||
getCompetences(name, options = { onMessage: message => { } }) {
|
||||
return RdDItemCompetence.findCompetences(this.items, name, options)
|
||||
getCompetences(name = undefined, options = { onMessage: message => { } }) {
|
||||
if (name == undefined) {
|
||||
return this.itemTypes[ITEM_TYPES.competence]
|
||||
}
|
||||
return RdDItemCompetence.findCompetences(this.itemTypes[ITEM_TYPES.competence], name, options)
|
||||
}
|
||||
|
||||
getCompetenceCorpsACorps(options = { onMessage: message => { } }) {
|
||||
@@ -223,27 +226,24 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
||||
return this.getEmbeddedCollection("ActiveEffect").filter(filter);
|
||||
}
|
||||
|
||||
getEffect(effectId) {
|
||||
return this.getEmbeddedCollection("ActiveEffect").find(it => it.statuses?.has(effectId));
|
||||
getEffectByStatus(statusId) {
|
||||
return this.getEffects().find(it => it.statuses.has(statusId));
|
||||
}
|
||||
|
||||
async setEffect(effectId, status) {
|
||||
if (this.isEffectAllowed(effectId)) {
|
||||
const effect = this.getEffect(effectId);
|
||||
async setEffect(statusId, status) {
|
||||
if (this.isEffectAllowed(statusId)) {
|
||||
const effect = this.getEffectByStatus(statusId);
|
||||
if (!status && effect) {
|
||||
await this.deleteEmbeddedDocuments('ActiveEffect', [effect.id]);
|
||||
}
|
||||
if (status && !effect) {
|
||||
await this.createEmbeddedDocuments("ActiveEffect", [StatusEffects.prepareActiveEffect(effectId)]);
|
||||
await this.createEmbeddedDocuments("ActiveEffect", [StatusEffects.prepareActiveEffect(statusId)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async removeEffect(id) {
|
||||
const effect = this.getEmbeddedCollection("ActiveEffect").find(it => it.id == id);
|
||||
if (effect) {
|
||||
await this.deleteEmbeddedDocuments('ActiveEffect', [id]);
|
||||
}
|
||||
this.removeEffects(it => it.id == id)
|
||||
}
|
||||
|
||||
async removeEffects(filter = e => true) {
|
||||
@@ -254,17 +254,16 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
isDemiReve() {
|
||||
return this.getEffectByStatus(STATUSES.StatusDemiReve) != undefined
|
||||
}
|
||||
|
||||
getSurprise(isCombat = undefined) {
|
||||
let niveauSurprise = this.getEffects()
|
||||
.map(effect => StatusEffects.valeurSurprise(effect, isCombat))
|
||||
.reduce(Misc.sum(), 0);
|
||||
if (niveauSurprise > 1) {
|
||||
return 'totale';
|
||||
}
|
||||
if (niveauSurprise == 1) {
|
||||
return 'demi';
|
||||
}
|
||||
return '';
|
||||
return StatusEffects.typeSurprise(
|
||||
this.getEffects()
|
||||
.map(it => StatusEffects.niveauSurprise(it, isCombat))
|
||||
.reduce(Misc.sum(), 0)
|
||||
)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -282,8 +281,20 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
||||
return dialog
|
||||
}
|
||||
|
||||
createCallbackExperience() { return { action: r => { } } }
|
||||
createCallbackAppelAuMoral() { return { action: r => { } } }
|
||||
|
||||
/* -------------------------------------------- */
|
||||
createCallbackExperience() {
|
||||
return { action: r => this.appliquerAjoutExperience(r) }
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
createCallbackAppelAuMoral() {
|
||||
/* Si l'appel au moral est utilisé, on l'affiche dans le chat et on diminue éventuellement le moral */
|
||||
return { action: r => this.appliquerAppelMoral(r) }
|
||||
}
|
||||
|
||||
async appliquerAjoutExperience(rollData, hideChatMessage = 'show') { }
|
||||
async appliquerAppelMoral(rollData) { }
|
||||
|
||||
async _onCloseRollDialog(html) { }
|
||||
|
||||
|
@@ -292,7 +292,7 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
|
||||
}
|
||||
|
||||
isSonne() {
|
||||
return this.getEffect(STATUSES.StatusStunned)
|
||||
return this.getEffectByStatus(STATUSES.StatusStunned)
|
||||
}
|
||||
|
||||
isEffectAllowed(effectId) { return true }
|
||||
|
@@ -27,6 +27,7 @@ export class RdDBaseActor extends Actor {
|
||||
}
|
||||
return entry && entry.length > 0 ? carac[entry[0]] : undefined;
|
||||
}
|
||||
|
||||
static getDefaultValue(actorType, path) {
|
||||
if (path.includes('.')) {
|
||||
path = path.split('.')
|
||||
@@ -743,6 +744,7 @@ export class RdDBaseActor extends Actor {
|
||||
ui.notifications.info(`${this.getAlias()} ne peut pas faire cette action: ${action}`)
|
||||
}
|
||||
|
||||
isAlcoolise() { return false }
|
||||
async jetEthylisme() { this.actionImpossible("jet d'éthylisme") }
|
||||
async rollAppelChance() { this.actionImpossible("appel à la chance") }
|
||||
async jetDeMoral() { this.actionImpossible("jet de moral") }
|
||||
|
@@ -256,8 +256,8 @@ export class Mapping {
|
||||
static descriptionSort(sort) {
|
||||
const ptSeuil = Array(sort.system.coutseuil).map(it => '*')
|
||||
const caseTMR = sort.system.caseTMRspeciale.length > 0 ? Mapping.toVar(sort.system.caseTMRspeciale) : Misc.upperFirst(TMRType[sort.system.caseTMR].name)
|
||||
const coutReve = 'r' + RdDItemSort.addSpaceToNonNumeric(sort.system.ptreve)
|
||||
const diff = 'R' + RdDItemSort.addSpaceToNonNumeric(sort.system.difficulte)
|
||||
const coutReve =RdDItemSort.coutReve(sort)
|
||||
const diff = RdDItemSort.diffReve(sort)
|
||||
return `${sort.name}${ptSeuil} (${caseTMR}) ${diff} ${coutReve}`
|
||||
}
|
||||
static toVar(caseSpeciale) {
|
||||
|
Reference in New Issue
Block a user