2020-05-22 22:37:02 +02:00
|
|
|
import { RdDUtility } from "./rdd-utility.js";
|
2020-12-06 18:41:54 +01:00
|
|
|
import { HtmlUtility } from "./html-utility.js";
|
2021-01-04 00:17:22 +01:00
|
|
|
import { RdDItemArme } from "./item-arme.js";
|
2021-01-08 22:23:50 +01:00
|
|
|
import { RdDItemCompetence } from "./item-competence.js";
|
2021-01-13 03:42:13 +01:00
|
|
|
import { RdDBonus } from "./rdd-bonus.js";
|
2021-02-05 01:38:40 +01:00
|
|
|
import { Misc } from "./misc.js";
|
2021-02-25 02:13:39 +01:00
|
|
|
import { RdDCombatManager } from "./rdd-combat.js";
|
2021-03-17 01:21:37 +01:00
|
|
|
import { RdDCarac } from "./rdd-carac.js";
|
2021-04-13 00:58:05 +02:00
|
|
|
import { DialogSplitItem } from "./dialog-split-item.js";
|
2023-06-20 23:43:24 +02:00
|
|
|
import { ReglesOptionnelles } from "./settings/regles-optionnelles.js";
|
2021-12-05 01:48:26 +01:00
|
|
|
import { RdDSheetUtility } from "./rdd-sheet-utility.js";
|
2022-11-06 21:39:03 +01:00
|
|
|
import { STATUSES } from "./settings/status-effects.js";
|
2022-12-14 20:00:35 +01:00
|
|
|
import { MAINS_DIRECTRICES } from "./actor.js";
|
2023-11-04 03:42:39 +01:00
|
|
|
import { RdDBaseActorReveSheet } from "./actor/base-actor-reve-sheet.js";
|
2022-12-28 23:36:48 +01:00
|
|
|
import { RdDItem } from "./item.js";
|
2023-03-10 22:41:11 +01:00
|
|
|
import { RdDItemBlessure } from "./item/blessure.js";
|
2023-04-21 18:18:20 +02:00
|
|
|
import { RdDEmpoignade } from "./rdd-empoignade.js";
|
2023-11-24 02:17:20 +01:00
|
|
|
import { RdDBaseActorSangSheet } from "./actor/base-actor-sang-sheet.js";
|
2023-11-21 21:07:37 +01:00
|
|
|
import { RdDCoeur } from "./coeur/rdd-coeur.js";
|
2024-10-02 00:46:11 +02:00
|
|
|
import { AppPersonnageAleatoire } from "./actor/random/app-personnage-aleatoire.js";
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2020-09-20 21:45:46 +02:00
|
|
|
/* -------------------------------------------- */
|
2022-11-05 18:06:30 +01:00
|
|
|
/**
|
|
|
|
* Extend the basic ActorSheet with some very simple modifications
|
|
|
|
* @extends {ActorSheet}
|
|
|
|
*/
|
2023-11-26 19:58:32 +01:00
|
|
|
export class RdDActorSheet extends RdDBaseActorSangSheet {
|
2020-05-21 21:48:20 +02:00
|
|
|
|
|
|
|
/** @override */
|
2021-01-08 22:23:50 +01:00
|
|
|
static get defaultOptions() {
|
2024-05-01 09:13:21 +02:00
|
|
|
return foundry.utils.mergeObject(RdDBaseActorReveSheet.defaultOptions, {
|
2021-01-08 22:23:50 +01:00
|
|
|
template: "systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html",
|
2022-11-28 14:36:25 +01:00
|
|
|
width: 550,
|
2021-01-08 22:23:50 +01:00
|
|
|
showCompNiveauBase: false,
|
2023-06-20 02:58:51 +02:00
|
|
|
vueArchetype: false,
|
2024-06-01 01:53:14 +02:00
|
|
|
}, { inplace: false });
|
2020-05-21 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
2021-03-17 01:21:37 +01:00
|
|
|
async getData() {
|
2022-12-28 23:36:48 +01:00
|
|
|
let formData = await super.getData();
|
2024-06-01 01:53:14 +02:00
|
|
|
foundry.utils.mergeObject(formData, {
|
|
|
|
editable: this.isEditable,
|
|
|
|
cssClass: this.isEditable ? "editable" : "locked",
|
|
|
|
limited: this.actor.limited,
|
|
|
|
owner: this.actor.isOwner,
|
|
|
|
biographie: await TextEditor.enrichHTML(this.actor.system.biographie, { async: true }),
|
|
|
|
notes: await TextEditor.enrichHTML(this.actor.system.notes, { async: true }),
|
|
|
|
});
|
2024-05-01 09:13:21 +02:00
|
|
|
foundry.utils.mergeObject(formData.calc, {
|
2022-12-28 23:36:48 +01:00
|
|
|
surenc: this.actor.computeMalusSurEncombrement(),
|
|
|
|
surprise: RdDBonus.find(this.actor.getSurprise(false)).descr,
|
|
|
|
resumeBlessures: this.actor.computeResumeBlessure(this.actor.system.blessures),
|
|
|
|
caracTotal: RdDCarac.computeTotal(this.actor.system.carac, this.actor.system.beaute),
|
2023-11-04 03:42:39 +01:00
|
|
|
surEncombrementMessage: this.actor.isSurenc() ? "Sur-Encombrement!" : "",
|
2023-07-11 02:34:05 +02:00
|
|
|
malusArmure: this.actor.getMalusArmure()
|
2022-12-28 23:36:48 +01:00
|
|
|
})
|
2022-10-05 19:29:16 +02:00
|
|
|
|
2022-12-28 23:36:48 +01:00
|
|
|
this.timerRecherche = undefined;
|
2021-03-17 01:21:37 +01:00
|
|
|
|
2022-10-05 19:29:16 +02:00
|
|
|
if (formData.type == 'personnage') {
|
2022-12-14 20:00:16 +01:00
|
|
|
formData.options.mainsDirectrices = MAINS_DIRECTRICES;
|
2022-10-05 19:29:16 +02:00
|
|
|
formData.byCateg = Misc.classify(formData.competences, it => it.system.categorie)
|
2022-12-14 20:00:35 +01:00
|
|
|
formData.calc.comptageArchetype = RdDItemCompetence.computeResumeArchetype(formData.competences);
|
|
|
|
formData.calc.competenceXPTotal = RdDItemCompetence.computeTotalXP(formData.competences);
|
|
|
|
formData.calc.fatigue = RdDUtility.calculFatigueHtml(formData.system.sante.fatigue.value, formData.system.sante.endurance.max);
|
2022-10-05 19:29:16 +02:00
|
|
|
|
|
|
|
formData.competences.forEach(item => {
|
2023-02-05 20:26:44 +01:00
|
|
|
item.system.isHidden = this.options.recherche
|
|
|
|
? !item.isNomLike(this.options.recherche.text)
|
|
|
|
: (this.options.showCompNiveauBase && RdDItemCompetence.isNiveauBase(item));
|
2022-10-05 19:29:16 +02:00
|
|
|
RdDItemCompetence.levelUp(item, formData.system.compteurs.experience.value);
|
|
|
|
});
|
2020-08-13 22:28:56 +02:00
|
|
|
|
2022-10-05 19:29:16 +02:00
|
|
|
Object.values(formData.system.carac).forEach(c => {
|
|
|
|
RdDCarac.levelUp(c);
|
|
|
|
});
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2022-10-05 19:29:16 +02:00
|
|
|
// toujours avoir une liste d'armes (pour mettre esquive et corps à corps)
|
2023-10-23 23:40:03 +02:00
|
|
|
const actor = this.actor;
|
2024-05-02 14:08:02 +02:00
|
|
|
formData.combat = foundry.utils.duplicate(formData.armes);
|
2022-10-05 19:29:16 +02:00
|
|
|
RdDItemArme.computeNiveauArmes(formData.combat, formData.competences);
|
2024-11-26 23:23:34 +01:00
|
|
|
formData.combat.push(RdDItemArme.corpsACorps(actor));
|
2023-10-23 23:40:03 +02:00
|
|
|
formData.combat.push(RdDItemArme.empoignade(actor));
|
2023-11-06 23:02:22 +01:00
|
|
|
|
2022-10-05 19:29:16 +02:00
|
|
|
formData.esquives = this.actor.getCompetences("Esquive");
|
|
|
|
formData.combat = RdDCombatManager.listActionsArmes(formData.combat, formData.competences, formData.system.carac);
|
2023-04-21 22:28:51 +02:00
|
|
|
formData.empoignades = this.actor.getEmpoignades();
|
2021-03-15 00:05:56 +01:00
|
|
|
|
2022-10-05 19:29:16 +02:00
|
|
|
this.armesList = formData.combat;
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2022-10-05 19:29:16 +02:00
|
|
|
// Common data
|
|
|
|
formData.ajustementsConditions = CONFIG.RDD.ajustementsConditions;
|
|
|
|
formData.difficultesLibres = CONFIG.RDD.difficultesLibres;
|
2021-03-18 23:55:26 +01:00
|
|
|
|
2022-10-05 19:29:16 +02:00
|
|
|
formData.hautreve = {
|
|
|
|
isDemiReve: this.actor.getEffect(STATUSES.StatusDemiReve),
|
|
|
|
cacheTMR: this.actor.isTMRCache()
|
|
|
|
}
|
2021-05-07 01:47:51 +02:00
|
|
|
|
2022-10-05 19:29:16 +02:00
|
|
|
formData.subacteurs = {
|
|
|
|
vehicules: this.actor.listeVehicules(),
|
|
|
|
montures: this.actor.listeMontures(),
|
|
|
|
suivants: this.actor.listeSuivants()
|
|
|
|
}
|
|
|
|
if (this.actor.getBestDraconic().system.niveau > -11 && !this.actor.isHautRevant()) {
|
|
|
|
ui.notifications.error(`${this.actor.name} a des compétences draconiques, mais pas le don de Haut-Rêve!
|
|
|
|
<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`);
|
|
|
|
}
|
2021-04-04 00:16:49 +02:00
|
|
|
}
|
2021-03-16 22:56:57 +01:00
|
|
|
return formData;
|
2020-05-22 19:28:01 +02:00
|
|
|
}
|
2020-12-27 22:21:08 +01:00
|
|
|
|
2023-11-04 03:42:39 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
/** @override */
|
2021-01-08 22:23:50 +01:00
|
|
|
activateListeners(html) {
|
2020-05-21 21:48:20 +02:00
|
|
|
super.activateListeners(html);
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2023-06-20 23:43:24 +02:00
|
|
|
HtmlUtility.showControlWhen(this.html.find(".appliquerFatigue"), ReglesOptionnelles.isUsing("appliquer-fatigue"));
|
2020-12-01 01:17:18 +01:00
|
|
|
|
2023-12-02 14:34:31 +01:00
|
|
|
this.html.find('.subacteur-open').click(async event => {
|
|
|
|
const subActorId = RdDSheetUtility.getEventItemData(event, 'subactor-id');
|
|
|
|
this.openSubActeur(subActorId);
|
|
|
|
})
|
|
|
|
|
|
|
|
this.html.find('.show-hide-competences').click(async event => {
|
|
|
|
this.options.showCompNiveauBase = !this.options.showCompNiveauBase;
|
|
|
|
this.render(true);
|
|
|
|
});
|
|
|
|
|
2024-10-11 00:15:15 +02:00
|
|
|
this.html.find('.button-tmr-visu').click(async event => this.actor.displayTMR("visu"))
|
2023-12-02 14:34:31 +01:00
|
|
|
|
2020-05-21 21:48:20 +02:00
|
|
|
// Everything below here is only needed if the sheet is editable
|
|
|
|
if (!this.options.editable) return;
|
|
|
|
|
2023-11-04 03:42:39 +01:00
|
|
|
this.html.find('.sheet-possession-attack').click(async event => {
|
|
|
|
const poss = RdDSheetUtility.getItem(event, this.actor)
|
|
|
|
this.actor.conjurerPossession(poss)
|
|
|
|
})
|
2022-12-28 23:36:48 +01:00
|
|
|
|
2023-11-21 16:03:26 +01:00
|
|
|
this.html.find('.subacteur-coeur-toggle a').click(async event => {
|
2023-11-21 21:07:37 +01:00
|
|
|
const subActorIdactorId = RdDSheetUtility.getEventItemData(event, 'subactor-id')
|
2023-11-27 23:45:33 +01:00
|
|
|
const coeurNombre = $(event.currentTarget).data('numero-coeur')
|
2023-11-21 21:07:37 +01:00
|
|
|
RdDCoeur.toggleSubActeurCoeur(this.actor.id, subActorIdactorId, coeurNombre)
|
|
|
|
})
|
|
|
|
this.html.find('.subacteur-tendre-moment').click(async event => {
|
|
|
|
const subActorId = RdDSheetUtility.getEventItemData(event, 'subactor-id')
|
|
|
|
RdDCoeur.startSubActeurTendreMoment(this.actor.id, subActorId)
|
2023-11-21 16:03:26 +01:00
|
|
|
})
|
2022-12-09 02:00:31 +01:00
|
|
|
this.html.find('.subacteur-delete').click(async event => {
|
2021-12-05 01:48:26 +01:00
|
|
|
const li = RdDSheetUtility.getEventElement(event);
|
2023-11-21 16:03:26 +01:00
|
|
|
const subActorId = li.data("subactor-id");
|
|
|
|
this.deleteSubActeur(subActorId, li);
|
|
|
|
})
|
2023-05-28 21:59:11 +02:00
|
|
|
this.html.find("input.derivee-value[name='system.compteurs.stress.value']").change(async event => {
|
|
|
|
this.actor.updateCompteurValue("stress", parseInt(event.target.value));
|
|
|
|
});
|
|
|
|
this.html.find("input.derivee-value[name='system.compteurs.experience.value']").change(async event => {
|
|
|
|
this.actor.updateCompteurValue("experience", parseInt(event.target.value));
|
|
|
|
});
|
|
|
|
|
2023-11-24 02:17:20 +01:00
|
|
|
this.html.find('.creer-tache').click(async event => this.createEmptyTache());
|
|
|
|
this.html.find('.creer-une-oeuvre').click(async event => this.selectTypeOeuvreToCreate());
|
2023-03-15 00:46:08 +01:00
|
|
|
this.html.find('.creer-tache-blessure-legere').click(async event => RdDItemBlessure.createTacheSoinBlessure(this.actor, 2));
|
|
|
|
this.html.find('.creer-tache-blessure-grave').click(async event => RdDItemBlessure.createTacheSoinBlessure(this.actor, 4));
|
|
|
|
this.html.find('.creer-tache-blessure-critique').click(async event => RdDItemBlessure.createTacheSoinBlessure(this.actor, 6));
|
2021-01-08 22:23:50 +01:00
|
|
|
|
2023-03-10 22:41:11 +01:00
|
|
|
this.html.find('.blessure-premierssoins-done').change(async event => {
|
|
|
|
const blessure = this.getBlessure(event);
|
|
|
|
await blessure?.setSoinsBlessure({ premierssoins: { done: event.currentTarget.checked } });
|
|
|
|
});
|
|
|
|
this.html.find('.blessure-soinscomplets-done').change(async event => {
|
|
|
|
const blessure = this.getBlessure(event);
|
|
|
|
await blessure?.setSoinsBlessure({ soinscomplets: { done: event.currentTarget.checked } })
|
|
|
|
});
|
|
|
|
this.html.find('.blessure-premierssoins-bonus').change(async event => {
|
|
|
|
const blessure = this.getBlessure(event);
|
|
|
|
await blessure?.setSoinsBlessure({ premierssoins: { bonus: Number(event.currentTarget.value) } })
|
|
|
|
});
|
|
|
|
this.html.find('.blessure-soinscomplets-bonus').change(async event => {
|
|
|
|
const blessure = this.getBlessure(event);
|
|
|
|
await blessure?.setSoinsBlessure({ soinscomplets: { bonus: Number(event.currentTarget.value) } })
|
|
|
|
});
|
|
|
|
|
2020-06-23 23:34:12 +02:00
|
|
|
// Equip Inventory Item
|
2023-11-24 02:17:20 +01:00
|
|
|
this.html.find('.item-equip').click(async event => this.actor.equiperObjet(RdDSheetUtility.getItemId(event)))
|
|
|
|
this.html.find('.chance-actuelle').click(async event => this.actor.rollCarac('chance-actuelle'))
|
|
|
|
|
2024-10-11 00:15:15 +02:00
|
|
|
this.html.find('.button-appel-chance').click(async event => this.actor.rollAppelChance())
|
2023-11-24 02:17:20 +01:00
|
|
|
|
|
|
|
this.html.find('[name="jet-astrologie"]').click(async event => this.actor.astrologieNombresAstraux())
|
|
|
|
this.html.find('.tache-label a').click(async event => this.actor.rollTache(RdDSheetUtility.getItemId(event)))
|
|
|
|
this.html.find('.meditation-label a').click(async event => this.actor.rollMeditation(RdDSheetUtility.getItemId(event)))
|
|
|
|
|
|
|
|
this.html.find('.chant-label a').click(async event => this.actor.rollChant(RdDSheetUtility.getItemId(event)))
|
|
|
|
this.html.find('.danse-label a').click(async event => this.actor.rollDanse(RdDSheetUtility.getItemId(event)))
|
|
|
|
this.html.find('.musique-label a').click(async event => this.actor.rollMusique(RdDSheetUtility.getItemId(event)))
|
|
|
|
this.html.find('.oeuvre-label a').click(async event => this.actor.rollOeuvre(RdDSheetUtility.getItemId(event)))
|
|
|
|
this.html.find('.jeu-label a').click(async event => this.actor.rollJeu(RdDSheetUtility.getItemId(event)))
|
|
|
|
this.html.find('.recettecuisine-label a').click(async event => this.actor.rollRecetteCuisine(RdDSheetUtility.getItemId(event)))
|
|
|
|
|
2024-10-02 00:46:11 +02:00
|
|
|
this.html.find('.description-aleatoire').click(async event => new AppPersonnageAleatoire(this.actor).render(true))
|
2023-11-24 02:17:20 +01:00
|
|
|
if (game.user.isGM) {
|
2023-12-02 14:34:31 +01:00
|
|
|
// experience log
|
|
|
|
this.html.find('.experiencelog-delete').click(async event => {
|
|
|
|
const li = this.html.find(event.currentTarget)?.parents(".experiencelog");
|
|
|
|
const key = Number(li.data("key") ?? -1);
|
|
|
|
await this.actor.deleteExperienceLog(key, 1);
|
|
|
|
});
|
|
|
|
this.html.find('.experiencelog-delete-previous').click(async event => {
|
|
|
|
const li = this.html.find(event.currentTarget)?.parents(".experiencelog");
|
|
|
|
const key = Number(li.data("key") ?? -1);
|
|
|
|
await this.actor.deleteExperienceLog(0, key + 1);
|
|
|
|
});
|
2024-06-01 01:53:14 +02:00
|
|
|
// Boutons spéciaux MJs
|
2023-11-24 02:17:20 +01:00
|
|
|
this.html.find('.forcer-tmr-aleatoire').click(async event => this.actor.reinsertionAleatoire("Action MJ"))
|
|
|
|
this.html.find('.afficher-tmr').click(async event => this.actor.changeTMRVisible())
|
|
|
|
}
|
2021-05-24 22:12:37 +02:00
|
|
|
|
2020-11-15 12:26:19 +01:00
|
|
|
// Points de reve actuel
|
2024-10-05 15:13:29 +02:00
|
|
|
this.html.find('.roll-reve-actuel').click(async event => this.actor.rollCarac('reve-actuel', true))
|
2023-11-24 02:17:20 +01:00
|
|
|
this.html.find('.empoignade-label a').click(async event => RdDEmpoignade.onAttaqueEmpoignadeFromItem(RdDSheetUtility.getItem(event, this.actor)))
|
2024-10-25 23:28:09 +02:00
|
|
|
|
|
|
|
this.html.find('.roll-arme').click(async event => this.actor.rollArme(foundry.utils.duplicate(this._getEventArmeCombat(event)), 'competence'))
|
2020-12-06 21:56:59 +01:00
|
|
|
|
2020-12-05 21:24:31 +01:00
|
|
|
// Initiative pour l'arme
|
2024-10-27 00:01:33 +02:00
|
|
|
this.html.find('.roll-init-arme').click(async event => {
|
2024-10-25 23:28:09 +02:00
|
|
|
let combatant = game.combat.combatants.find(c => c.actor.id == this.actor.id)
|
2021-01-08 22:23:50 +01:00
|
|
|
if (combatant) {
|
2024-10-25 23:28:09 +02:00
|
|
|
RdDCombatManager.rollInitiativeAction(combatant._id, this._getEventArmeCombat(event));
|
2020-12-05 21:24:31 +01:00
|
|
|
} else {
|
|
|
|
ui.notifications.info("Impossible de lancer l'initiative sans être dans un combat.");
|
|
|
|
}
|
2024-10-25 23:28:09 +02:00
|
|
|
})
|
2023-11-04 03:42:39 +01:00
|
|
|
// Display TMR
|
2023-11-24 02:17:20 +01:00
|
|
|
|
2024-10-11 00:15:15 +02:00
|
|
|
this.html.find('.button-tmr').click(async event => this.actor.displayTMR("normal"))
|
|
|
|
this.html.find('.button-tmr-rapide').click(async event => this.actor.displayTMR("rapide"))
|
2023-11-24 02:17:20 +01:00
|
|
|
|
2024-10-11 00:15:15 +02:00
|
|
|
this.html.find('.button-repos').click(async event => await this.actor.repos())
|
2023-11-24 02:17:20 +01:00
|
|
|
|
|
|
|
this.html.find('.carac-xp-augmenter').click(async event => this.actor.updateCaracXPAuto(event.currentTarget.name.replace("augmenter.", "")))
|
|
|
|
this.html.find('.competence-xp-augmenter').click(async event => this.actor.updateCompetenceXPAuto(RdDSheetUtility.getItemId(event)))
|
|
|
|
this.html.find('.competence-stress-augmenter').click(async event => this.actor.updateCompetenceStress(RdDSheetUtility.getItemId(event)))
|
2021-11-23 02:04:00 +01:00
|
|
|
|
2022-09-27 22:38:49 +02:00
|
|
|
if (this.options.vueDetaillee) {
|
2020-11-20 12:06:54 +01:00
|
|
|
// On carac change
|
2022-12-09 02:00:31 +01:00
|
|
|
this.html.find('input.carac-xp').change(async event => {
|
2022-09-07 09:01:23 +02:00
|
|
|
let caracName = event.currentTarget.name.replace(".xp", "").replace("system.carac.", "");
|
2022-06-12 08:17:59 +02:00
|
|
|
this.actor.updateCaracXP(caracName, parseInt(event.target.value));
|
2021-01-08 22:23:50 +01:00
|
|
|
});
|
2020-11-20 12:06:54 +01:00
|
|
|
// On competence xp change
|
2022-12-09 02:00:31 +01:00
|
|
|
this.html.find('input.competence-xp').change(async event => {
|
2020-11-20 12:06:54 +01:00
|
|
|
let compName = event.currentTarget.attributes.compname.value;
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.updateCompetenceXP(compName, parseInt(event.target.value));
|
|
|
|
});
|
2022-12-09 02:00:31 +01:00
|
|
|
this.html.find('input.competence-xp-sort').change(async event => {
|
2021-02-03 23:27:55 +01:00
|
|
|
let compName = event.currentTarget.attributes.compname.value;
|
|
|
|
this.actor.updateCompetenceXPSort(compName, parseInt(event.target.value));
|
|
|
|
});
|
2023-11-04 03:42:39 +01:00
|
|
|
|
2023-06-20 02:58:51 +02:00
|
|
|
this.html.find('.toggle-archetype').click(async event => {
|
|
|
|
this.options.vueArchetype = !this.options.vueArchetype;
|
|
|
|
this.render(true);
|
|
|
|
});
|
2021-01-03 19:19:02 +01:00
|
|
|
// On competence archetype change
|
2022-12-09 02:00:31 +01:00
|
|
|
this.html.find('.competence-archetype').change(async event => {
|
2021-01-03 19:19:02 +01:00
|
|
|
let compName = event.currentTarget.attributes.compname.value;
|
2021-01-08 22:23:50 +01:00
|
|
|
this.actor.updateCompetenceArchetype(compName, parseInt(event.target.value));
|
|
|
|
});
|
2023-11-24 02:17:20 +01:00
|
|
|
this.html.find('.nouvelle-incarnation').click(async event => this.actor.nouvelleIncarnation())
|
2020-11-20 12:06:54 +01:00
|
|
|
}
|
2023-11-24 02:17:20 +01:00
|
|
|
|
2020-07-14 22:19:29 +02:00
|
|
|
// On pts de reve change
|
2023-11-24 02:17:20 +01:00
|
|
|
this.html.find('.pointsreve-value').change(async event => this.actor.update({ "system.reve.reve.value": event.currentTarget.value }))
|
|
|
|
this.html.find('.seuil-reve-value').change(async event => this.actor.setPointsDeSeuil(event.currentTarget.value))
|
|
|
|
|
|
|
|
this.html.find('.stress-test').click(async event => this.actor.transformerStress())
|
|
|
|
this.html.find('.moral-malheureux').click(async event => this.actor.jetDeMoral('malheureuse'))
|
|
|
|
this.html.find('.moral-neutre').click(async event => this.actor.jetDeMoral('neutre'))
|
|
|
|
this.html.find('.moral-heureux').click(async event => this.actor.jetDeMoral('heureuse'))
|
2024-10-11 00:15:15 +02:00
|
|
|
this.html.find('.button-ethylisme').click(async event => this.actor.jetEthylisme())
|
2023-11-24 02:17:20 +01:00
|
|
|
|
|
|
|
this.html.find('.ptreve-actuel-plus').click(async event => this.actor.reveActuelIncDec(1))
|
|
|
|
this.html.find('.ptreve-actuel-moins').click(async event => this.actor.reveActuelIncDec(-1))
|
|
|
|
this.html.find('.fatigue-plus').click(async event => this.actor.santeIncDec("fatigue", 1))
|
|
|
|
this.html.find('.fatigue-moins').click(async event => this.actor.santeIncDec("fatigue", -1))
|
2023-11-04 17:48:50 +01:00
|
|
|
}
|
|
|
|
|
2023-03-10 22:41:11 +01:00
|
|
|
getBlessure(event) {
|
2023-11-21 16:03:26 +01:00
|
|
|
const blessureId = this.html.find(event.currentTarget).parents(".item-blessure").data('item-id');
|
|
|
|
return this.actor.getItem(blessureId, 'blessure');
|
2023-03-10 22:41:11 +01:00
|
|
|
}
|
|
|
|
|
2022-12-09 02:00:31 +01:00
|
|
|
isCompetenceAffichable(competence) {
|
|
|
|
return !this.options.showCompNiveauBase || !RdDItemCompetence.isNiveauBase(competence);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
async _onDropActor(event, dragData) {
|
|
|
|
const dropActor = fromUuidSync(dragData.uuid);
|
|
|
|
this.actor.addSubActeur(dropActor);
|
|
|
|
super._onDropActor(event, dragData);
|
|
|
|
}
|
|
|
|
|
2023-11-21 16:03:26 +01:00
|
|
|
openSubActeur(actorId) {
|
2023-11-21 21:07:37 +01:00
|
|
|
game.actors.get(actorId)?.sheet.render(true)
|
2023-11-21 16:03:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
deleteSubActeur(actorId, li) {
|
|
|
|
if (actorId) {
|
|
|
|
const subActor = game.actors.get(actorId);
|
|
|
|
RdDUtility.confirmSubActeurDelete(this, subActor, li, () => {
|
|
|
|
console.log('Delete : ', subActor.id);
|
2023-11-21 21:07:37 +01:00
|
|
|
this.actor.deleteSubActeur(subActor.id);
|
2023-11-21 16:03:26 +01:00
|
|
|
RdDUtility.slideOnDelete(this, li);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-09 02:00:31 +01:00
|
|
|
/* -------------------------------------------- */
|
2022-12-28 23:36:48 +01:00
|
|
|
async selectTypeOeuvreToCreate() {
|
2023-06-05 20:17:19 +02:00
|
|
|
let types = RdDItem.getTypesOeuvres();
|
2022-12-28 23:36:48 +01:00
|
|
|
let content = `<span class="competence-label">Selectionnez le type d'oeuvre</span><select class="item-type">`;
|
2023-06-05 20:17:19 +02:00
|
|
|
for (let typeName of types) {
|
2022-12-28 23:36:48 +01:00
|
|
|
content += `<option value="${typeName}">${Misc.typeName('Item', typeName)}</option>`
|
2022-12-09 02:00:31 +01:00
|
|
|
}
|
2022-12-28 23:36:48 +01:00
|
|
|
content += '</select>';
|
|
|
|
let dialog = new Dialog({
|
|
|
|
title: "Créer une oeuvre",
|
|
|
|
content: content,
|
|
|
|
buttons: {
|
|
|
|
create: {
|
|
|
|
icon: '<i class="fas fa-check"></i>',
|
|
|
|
label: "Créer l'oeuvre",
|
|
|
|
callback: () => this.actor.createItem($(".item-type").val())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
dialog.render(true);
|
2022-12-09 02:00:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
async createEmptyTache() {
|
2022-12-28 23:36:48 +01:00
|
|
|
await this.actor.createItem('tache', 'Nouvelle tache');
|
2022-12-09 02:00:31 +01:00
|
|
|
}
|
2022-08-26 22:21:25 +02:00
|
|
|
|
2021-11-23 02:04:00 +01:00
|
|
|
_getEventArmeCombat(event) {
|
2022-12-09 02:00:31 +01:00
|
|
|
const li = this.html.find(event.currentTarget)?.parents(".item");
|
2022-06-12 08:17:59 +02:00
|
|
|
let armeName = li.data("arme-name");
|
|
|
|
let compName = li.data('competence-name');
|
2022-06-12 09:46:58 +02:00
|
|
|
const arme = this.armesList.find(a => a.name == armeName && a.system.competence == compName);
|
2021-11-20 01:19:29 +01:00
|
|
|
if (!arme) {
|
2022-06-12 09:46:58 +02:00
|
|
|
return { name: armeName, system: { competence: compName } };
|
2021-11-20 01:19:29 +01:00
|
|
|
}
|
2022-06-12 08:17:59 +02:00
|
|
|
return arme;
|
2021-11-20 01:19:29 +01:00
|
|
|
}
|
|
|
|
|
2020-05-21 21:48:20 +02:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
/** @override */
|
2021-01-08 22:23:50 +01:00
|
|
|
setPosition(options = {}) {
|
2020-05-21 21:48:20 +02:00
|
|
|
const position = super.setPosition(options);
|
2021-05-09 18:16:01 +02:00
|
|
|
const sheetHeader = this.element.find(".sheet-header");
|
|
|
|
const sheetTabs = this.element.find(".sheet-tabs");
|
2020-05-21 21:48:20 +02:00
|
|
|
const sheetBody = this.element.find(".sheet-body");
|
2022-10-05 19:29:16 +02:00
|
|
|
let bodyHeight = position.height - sheetHeader[0].clientHeight;
|
2022-12-14 20:00:35 +01:00
|
|
|
if (sheetTabs.length > 0) {
|
|
|
|
bodyHeight -= sheetTabs[0].clientHeight;
|
2022-10-05 19:29:16 +02:00
|
|
|
}
|
2020-05-21 21:48:20 +02:00
|
|
|
sheetBody.css("height", bodyHeight);
|
|
|
|
return position;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/** @override */
|
|
|
|
_updateObject(event, formData) {
|
|
|
|
// Update the Actor
|
2022-09-07 18:47:56 +02:00
|
|
|
return this.actor.update(formData);
|
2020-05-21 21:48:20 +02:00
|
|
|
}
|
2021-04-13 00:58:05 +02:00
|
|
|
|
|
|
|
async splitItem(item) {
|
|
|
|
const dialog = await DialogSplitItem.create(item, (item, split) => this._onSplitItem(item, split));
|
|
|
|
dialog.render(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
async _onSplitItem(item, split) {
|
2022-09-07 00:09:17 +02:00
|
|
|
if (split >= 1 && split < item.system.quantite) {
|
2022-06-12 08:17:59 +02:00
|
|
|
await item.diminuerQuantite(split);
|
2024-05-02 14:08:02 +02:00
|
|
|
const splitItem = foundry.utils.duplicate(item);
|
2022-09-07 18:47:56 +02:00
|
|
|
splitItem.system.quantite = split;
|
|
|
|
await this.actor.createEmbeddedDocuments('Item', [splitItem])
|
2021-04-13 00:58:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-21 21:48:20 +02:00
|
|
|
}
|