Autoformat
This commit is contained in:
parent
372eb6d334
commit
57ec6403bb
@ -33,7 +33,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
/* -------------------------------------------- */
|
||||
getData() {
|
||||
let data = super.getData();
|
||||
if ( data.actor.type == 'creature' || data.actor.type == 'humanoide') return data; // Shortcut
|
||||
if (data.actor.type == 'creature' || data.actor.type == 'humanoide') return data; // Shortcut
|
||||
|
||||
data.data.editCaracComp = this.options.editCaracComp;
|
||||
data.data.showCompNiveauBase = this.options.showCompNiveauBase;
|
||||
@ -50,9 +50,9 @@ export class RdDActorSheet extends ActorSheet {
|
||||
item => {
|
||||
let archetypeKey = (item.data.niveau_archetype < 0) ? 0 : item.data.niveau_archetype;
|
||||
if (data.data.comptageArchetype[archetypeKey] == undefined) {
|
||||
data.data.comptageArchetype[archetypeKey] = { "niveau": archetypeKey, "nombreMax": 0, "nombre": 0};
|
||||
data.data.comptageArchetype[archetypeKey] = { "niveau": archetypeKey, "nombreMax": 0, "nombre": 0 };
|
||||
}
|
||||
data.data.comptageArchetype[archetypeKey].nombre = (data.data.comptageArchetype[archetypeKey]?.nombre??0) + 1; //Comptage archetype
|
||||
data.data.comptageArchetype[archetypeKey].nombre = (data.data.comptageArchetype[archetypeKey]?.nombre ?? 0) + 1; //Comptage archetype
|
||||
item.data.xpNext = RdDItemCompetence.getCompetenceNextXp(item.data.niveau);
|
||||
item.data.isLevelUp = item.data.xp >= item.data.xpNext; // Flag de niveau à MAJ
|
||||
//this.actor.checkCompetenceXP(item.name); // Petite vérification experience
|
||||
@ -68,7 +68,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
for (let caracName in data.data.carac) {
|
||||
let currentCarac = data.data.carac[caracName];
|
||||
if (!currentCarac.derivee) {
|
||||
sum += parseInt(currentCarac.value);
|
||||
sum += parseInt(currentCarac.value);
|
||||
}
|
||||
currentCarac.xpNext = RdDUtility.getCaracNextXp(currentCarac.value);
|
||||
currentCarac.isLevelUp = (currentCarac.xp >= currentCarac.xpNext);
|
||||
@ -98,7 +98,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
data.data.combat = duplicate(RdDUtility.checkNull(data.itemsByType['arme']));
|
||||
data.data.combat = RdDCombatManager.finalizeArmeList(data.data.combat, data.itemsByType.competence, data.data.carac);
|
||||
|
||||
data.esquive = { name: "Esquive", niveau: data.competenceByCategory?.melee.find(it => it.name == 'Esquive')?.data.niveau ?? -6};
|
||||
data.esquive = { name: "Esquive", niveau: data.competenceByCategory?.melee.find(it => it.name == 'Esquive')?.data.niveau ?? -6 };
|
||||
let corpsACorps = data.competenceByCategory?.melee.find(it => it.name == 'Corps à corps');
|
||||
if (corpsACorps) {
|
||||
let cc_init = RdDCombatManager.calculInitiative(corpsACorps.data.niveau, data.data.carac['melee'].value);
|
||||
@ -113,7 +113,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
// Mise à jour de l'encombrement total et du prix de l'équipement
|
||||
this.actor.computeEncombrementTotalEtMalusArmure();
|
||||
this.actor.computePrixTotalEquipement();
|
||||
|
||||
|
||||
// Common data
|
||||
data.data.competenceByCategory = data.competenceByCategory;
|
||||
data.data.encTotal = this.actor.encTotal;
|
||||
@ -131,20 +131,20 @@ export class RdDActorSheet extends ActorSheet {
|
||||
|
||||
RdDUtility.filterItemsPerTypeForSheet(data);
|
||||
data.data.sortReserve = data.data.reve.reserve.list;
|
||||
data.data.rencontres = duplicate(data.data.reve.rencontre.list);
|
||||
data.data.rencontres = duplicate(data.data.reve.rencontre.list);
|
||||
data.data.caseSpeciales = data.itemsByType['casetmr'];
|
||||
RdDUtility.buildArbreDeConteneur(this, data);
|
||||
data.data.surEncombrementMessage = (data.data.compteurs.surenc.value < 0) ? "Sur-Encombrement!" : "";
|
||||
data.data.vehiculesList = this.actor.buildVehiculesList();
|
||||
data.data.monturesList = this.actor.buildMonturesList();
|
||||
data.data.suivantsList = this.actor.buildSuivantsList();
|
||||
data.data.monturesList = this.actor.buildMonturesList();
|
||||
data.data.suivantsList = this.actor.buildSuivantsList();
|
||||
return data;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _onDrop(event) {
|
||||
let toSuper = await RdDUtility.processItemDropEvent(this, event);
|
||||
if ( toSuper) {
|
||||
if (toSuper) {
|
||||
super._onDrop(event);
|
||||
}
|
||||
}
|
||||
@ -213,12 +213,12 @@ export class RdDActorSheet extends ActorSheet {
|
||||
html.find('.item-delete').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
RdDUtility.confirmerSuppression(this, li);
|
||||
});
|
||||
});
|
||||
html.find('.subacteur-delete').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
RdDUtility.confirmerSuppressionSubacteur(this, li);
|
||||
});
|
||||
|
||||
|
||||
html.find('#encaisser-direct').click(ev => {
|
||||
this.actor.encaisser();
|
||||
});
|
||||
@ -335,12 +335,12 @@ export class RdDActorSheet extends ActorSheet {
|
||||
html.find('.subacteur-label a').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
let actorId = li.data('actor-id');
|
||||
let actor = game.actors.get( actorId) ;
|
||||
if ( actor ) {
|
||||
let actor = game.actors.get(actorId);
|
||||
if (actor) {
|
||||
actor.sheet.render(true);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Points de reve actuel
|
||||
html.find('.ptreve-actuel a').click((event) => {
|
||||
this.actor.rollCarac('reve-actuel');
|
||||
|
103
module/actor.js
103
module/actor.js
@ -113,12 +113,12 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
setRollWindowsOpened( flag ) {
|
||||
setRollWindowsOpened(flag) {
|
||||
this.rollWindowsOpened = flag;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
isRollWindowsOpened( ) {
|
||||
isRollWindowsOpened() {
|
||||
return this.rollWindowsOpened;
|
||||
}
|
||||
|
||||
@ -315,11 +315,11 @@ export class RdDActor extends Actor {
|
||||
let reserve = duplicate(this.data.data.reve.reserve);
|
||||
let tmr = TMRUtility.getTMR(sortReserve.coord);
|
||||
let index = reserve.list.findIndex(tmr.type == 'fleuve'
|
||||
? sort => (TMRUtility.getTMR(sort.coord).type == 'fleuve' && sort.sort.name == sortReserve.sort.name)
|
||||
: sort => (sort.coord == sortReserve.coord && sort.sort.name == sortReserve.sort.name)
|
||||
? sort => (TMRUtility.getTMR(sort.coord).type == 'fleuve' && sort.sort.name == sortReserve.sort.name)
|
||||
: sort => (sort.coord == sortReserve.coord && sort.sort.name == sortReserve.sort.name)
|
||||
);
|
||||
if (index >=0 ) {
|
||||
reserve.list.splice(index,1);
|
||||
if (index >= 0) {
|
||||
reserve.list.splice(index, 1);
|
||||
await this.update({ "data.reve.reserve": reserve });
|
||||
}
|
||||
}
|
||||
@ -356,7 +356,7 @@ export class RdDActor extends Actor {
|
||||
|
||||
// On ne récupère un point de chance que si aucun appel à la chance dans la journée
|
||||
let utilisationChance = duplicate(this.getFlag('foundryvtt-reve-de-dragon', 'utilisationChance') ?? false);
|
||||
if ( !utilisationChance ) {
|
||||
if (!utilisationChance) {
|
||||
await this.chanceActuelleIncDec(1);
|
||||
}
|
||||
await this.unsetFlag('foundryvtt-reve-de-dragon', 'utilisationChance'); // Nouveau jour, suppression du flag
|
||||
@ -489,7 +489,7 @@ export class RdDActor extends Actor {
|
||||
async dormir(heures = 1) {
|
||||
let message = {
|
||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name),
|
||||
content: `${this.name}: Vous dormez ${heures == 1 ? 'une': heures} heure${heures == 1 ? '': 's'}.`
|
||||
content: `${this.name}: Vous dormez ${heures == 1 ? 'une' : heures} heure${heures == 1 ? '' : 's'}.`
|
||||
};
|
||||
await this.recupereEndurance(message);
|
||||
for (let i = 0; i < heures; i++) {
|
||||
@ -1121,7 +1121,7 @@ export class RdDActor extends Actor {
|
||||
queue = await RdDRollTables.getOmbre();
|
||||
let myReve = duplicate(this.data.data.reve.reve);
|
||||
myReve.thanatosused = false;
|
||||
await this.update({ "data.reve.reve": myReve } );
|
||||
await this.update({ "data.reve.reve": myReve });
|
||||
}
|
||||
else {
|
||||
queue = await RdDRollTables.getQueue();
|
||||
@ -1143,7 +1143,7 @@ export class RdDActor extends Actor {
|
||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name)
|
||||
});
|
||||
const innaccessible = this.buildTMRInnaccessible();
|
||||
let tmr = TMRUtility.getTMRAleatoire(tmr => !innaccessible.includes(tmr.coord) );
|
||||
let tmr = TMRUtility.getTMRAleatoire(tmr => !innaccessible.includes(tmr.coord));
|
||||
this.updateCoordTMR(tmr.coord);
|
||||
return tmr;
|
||||
}
|
||||
@ -1218,8 +1218,8 @@ export class RdDActor extends Actor {
|
||||
let list = duplicate(this.data.data.reve.rencontre.list);
|
||||
let newList = [];
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
if ( i != rencontreKey)
|
||||
newList.push( list[i]);
|
||||
if (i != rencontreKey)
|
||||
newList.push(list[i]);
|
||||
}
|
||||
await this.update({ "data.reve.rencontre.list": newList });
|
||||
}
|
||||
@ -1270,13 +1270,13 @@ export class RdDActor extends Actor {
|
||||
getSonneRound() {
|
||||
return !this.isEntiteCauchemar() && (this.data.data.sante.sonne?.round ?? false);
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async verifierSonneRound( round ) {
|
||||
if ( this.getSonne() ) {
|
||||
if ( round >= this.getSonneRound() + 1) {
|
||||
await this.setSonne( false, -1 ); // Nettoyer l'état sonné
|
||||
ChatMessage.create( { content: `${this.name} n'est plus sonné ce round !`} );
|
||||
async verifierSonneRound(round) {
|
||||
if (this.getSonne()) {
|
||||
if (round >= this.getSonneRound() + 1) {
|
||||
await this.setSonne(false, -1); // Nettoyer l'état sonné
|
||||
ChatMessage.create({ content: `${this.name} n'est plus sonné ce round !` });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1322,10 +1322,10 @@ export class RdDActor extends Actor {
|
||||
if (roll.total == 1) {
|
||||
let xp = Misc.toInt(this.data.data.carac.constitution.xp) + 1;
|
||||
this.update({ "data.carac.constitution.xp": xp }); // +1 XP !
|
||||
ChatMessage.create( { content: `${this.name} a obenu 1 sur son Jet d'Endurance et a gagné 1 point d'Expérience en Constitution. Ce point d'XP a été ajouté automatiquement).`});
|
||||
ChatMessage.create({ content: `${this.name} a obenu 1 sur son Jet d'Endurance et a gagné 1 point d'Expérience en Constitution. Ce point d'XP a été ajouté automatiquement).` });
|
||||
}
|
||||
if (result.sonne) {
|
||||
|
||||
|
||||
await this.setSonne();
|
||||
sante.sonne.value = true;
|
||||
}
|
||||
@ -1700,7 +1700,7 @@ export class RdDActor extends Actor {
|
||||
action: r => this._appliquerAjoutExperience(r, game.settings.get("core", "rollMode") != 'blindroll')
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
createCallbackAppelAuMoral() { /* Si l'appel au moral est utilisé, on l'affiche dans le chat et on diminue éventuellement le moral */
|
||||
return {
|
||||
@ -1708,7 +1708,7 @@ export class RdDActor extends Actor {
|
||||
action: r => { this.displayAppelAuMoral ; this._appliquerAppelMoral(r, game.settings.get("core", "rollMode") != 'blindroll') }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async checkCaracXP(caracName) {
|
||||
let carac = this.data.data.carac[caracName];
|
||||
@ -1778,8 +1778,8 @@ export class RdDActor extends Actor {
|
||||
if (xpResult && xpResult.xpCarac > 0 && rollData.selectedCarac) {
|
||||
this.checkCaracXP(rollData.selectedCarac.name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _appliquerAppelMoral(rollData, display = true) {
|
||||
if (!this.isPersonnage()) return;
|
||||
@ -1956,7 +1956,7 @@ export class RdDActor extends Actor {
|
||||
if (rollData.isSortReserve) {
|
||||
rollData.depenseReve++;
|
||||
}
|
||||
if ( rollData.competence.name.includes('Thanatos')) { // Si Thanatos
|
||||
if (rollData.competence.name.includes('Thanatos')) { // Si Thanatos
|
||||
myReve.thanatosused = true;
|
||||
}
|
||||
if (myReve.value > rollData.depenseReve) {
|
||||
@ -2128,7 +2128,7 @@ export class RdDActor extends Actor {
|
||||
selectedCarac: duplicate(this.data.data.carac[selected])
|
||||
});
|
||||
artData.competence.data.defaut_carac = selected;
|
||||
if ( !artData.forceCarac ) {
|
||||
if (!artData.forceCarac) {
|
||||
artData.forceCarac = {};
|
||||
artData.forceCarac[selected] = duplicate(this.data.data.carac[selected]);
|
||||
}
|
||||
@ -2168,17 +2168,17 @@ export class RdDActor extends Actor {
|
||||
const artData = { art: 'danse', verbe: 'Danser', forceCarac: {} };
|
||||
const oeuvre = duplicate(this.getOeuvre(id, artData.art));
|
||||
const selectedCarac = this._getCaracDanse(oeuvre);
|
||||
if ( oeuvre.data.agilite) {
|
||||
artData.forceCarac['agilite'] = duplicate(this.data.data.carac.agilite );
|
||||
if (oeuvre.data.agilite) {
|
||||
artData.forceCarac['agilite'] = duplicate(this.data.data.carac.agilite);
|
||||
}
|
||||
if ( oeuvre.data.apparence) {
|
||||
artData.forceCarac['apparence'] = duplicate(this.data.data.carac.apparence );
|
||||
if (oeuvre.data.apparence) {
|
||||
artData.forceCarac['apparence'] = duplicate(this.data.data.carac.apparence);
|
||||
}
|
||||
await this._rollArt(artData, selectedCarac, oeuvre);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_getCaracDanse(oeuvre) {
|
||||
_getCaracDanse(oeuvre) {
|
||||
if (oeuvre.data.agilite) { return "agilite"; }
|
||||
else if (oeuvre.data.apparence) { return "apparence"; }
|
||||
const competence = this.getCompetence(oeuvre.data.competence);
|
||||
@ -2289,7 +2289,7 @@ export class RdDActor extends Actor {
|
||||
async rollAppelChance(onSuccess = () => { }, onEchec = () => { }) {
|
||||
// Stocke si utilisation de la chance
|
||||
await this.unsetFlag('foundryvtt-reve-de-dragon', 'utilisationChance');
|
||||
await this.setFlag('foundryvtt-reve-de-dragon', 'utilisationChance', true );
|
||||
await this.setFlag('foundryvtt-reve-de-dragon', 'utilisationChance', true);
|
||||
|
||||
let rollData = { selectedCarac: this.getCaracByName('chance-actuelle'), surprise: '' };
|
||||
const dialog = await RdDRoll.create(this, rollData,
|
||||
@ -2556,10 +2556,12 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
verifierForceMin( item ) {
|
||||
if ( item.type == 'arme' && item.data.force > this.data.data.carac.force.value ) {
|
||||
ChatMessage.create( { content: `<strong>${this.name} s'est équipé(e) de l'arme ${item.name}, mais n'a pas une force suffisante pour l'utiliser normalement </strong>
|
||||
(${item.data.force} nécessaire pour une Force de ${this.data.data.carac.force.value})` } );
|
||||
verifierForceMin(item) {
|
||||
if (item.type == 'arme' && item.data.force > this.data.data.carac.force.value) {
|
||||
ChatMessage.create({
|
||||
content: `<strong>${this.name} s'est équipé(e) de l'arme ${item.name}, mais n'a pas une force suffisante pour l'utiliser normalement </strong>
|
||||
(${item.data.force} nécessaire pour une Force de ${this.data.data.carac.force.value})`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -2571,8 +2573,8 @@ export class RdDActor extends Actor {
|
||||
await this.updateEmbeddedEntity("OwnedItem", update);
|
||||
this.computeEncombrementTotalEtMalusArmure(); // Mise à jour encombrement
|
||||
this.computePrixTotalEquipement(); // Mis à jour du prix total de l'équipement
|
||||
if ( item.data.data.equipe )
|
||||
this.verifierForceMin( item.data );
|
||||
if (item.data.data.equipe)
|
||||
this.verifierForceMin(item.data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2593,10 +2595,10 @@ export class RdDActor extends Actor {
|
||||
protection = Math.max(protection - penetration, 0);
|
||||
protection += this.getProtectionNaturelle();
|
||||
// Gestion des cas particuliers sur la fenêtre d'encaissement
|
||||
if ( attackerRoll.dmg.encaisserSpecial && attackerRoll.dmg.encaisserSpecial == "noarmure") {
|
||||
if (attackerRoll.dmg.encaisserSpecial && attackerRoll.dmg.encaisserSpecial == "noarmure") {
|
||||
protection = 0;
|
||||
}
|
||||
if ( attackerRoll.dmg.encaisserSpecial && attackerRoll.dmg.encaisserSpecial == "chute" && Number(protection) > 2) {
|
||||
if (attackerRoll.dmg.encaisserSpecial && attackerRoll.dmg.encaisserSpecial == "chute" && Number(protection) > 2) {
|
||||
protection = 2;
|
||||
}
|
||||
console.log("Final protect", protection, attackerRoll);
|
||||
@ -2693,7 +2695,7 @@ export class RdDActor extends Actor {
|
||||
let encaissement = RdDUtility.selectEncaissement(jetTotal, rollData.dmg.mortalite)
|
||||
let over20 = Math.max(jetTotal - 20, 0);
|
||||
encaissement.dmg = rollData.dmg;
|
||||
encaissement.dmg.loc = rollData.dmg.loc ?? RdDUtility.getLocalisation( this.data.type );
|
||||
encaissement.dmg.loc = rollData.dmg.loc ?? RdDUtility.getLocalisation(this.data.type);
|
||||
encaissement.dmg.loc.label = encaissement.dmg.loc.label ?? 'Corps;'
|
||||
encaissement.roll = roll;
|
||||
encaissement.armure = armure;
|
||||
@ -2782,26 +2784,26 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async resetItemUse( ) {
|
||||
async resetItemUse() {
|
||||
await this.unsetFlag('foundryvtt-reve-de-dragon', 'itemUse');
|
||||
await this.setFlag('foundryvtt-reve-de-dragon', 'itemUse', {} );
|
||||
await this.setFlag('foundryvtt-reve-de-dragon', 'itemUse', {});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async incDecItemUse( itemId, inc = 1 ) {
|
||||
async incDecItemUse(itemId, inc = 1) {
|
||||
let itemUse = duplicate(this.getFlag('foundryvtt-reve-de-dragon', 'itemUse') ?? {});
|
||||
itemUse[itemId] = (itemUse[itemId] ?? 0) + inc;
|
||||
await this.setFlag( 'foundryvtt-reve-de-dragon', 'itemUse', itemUse);
|
||||
await this.setFlag('foundryvtt-reve-de-dragon', 'itemUse', itemUse);
|
||||
console.log("ITEM USE INC", inc, itemUse);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getItemUse( itemId ) {
|
||||
getItemUse(itemId) {
|
||||
let itemUse = this.getFlag('foundryvtt-reve-de-dragon', 'itemUse') ?? {};
|
||||
console.log("ITEM USE GET", itemUse);
|
||||
return itemUse[itemId] ?? 0;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* -- entites -- */
|
||||
/* retourne true si on peut continuer, false si on ne peut pas continuer */
|
||||
@ -3210,10 +3212,11 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
}
|
||||
|
||||
notifyGestionTeteSouffleQueue(item, manualMessage=true){
|
||||
notifyGestionTeteSouffleQueue(item, manualMessage = true) {
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
content: `${this.name} a reçu un/une ${item.type}: ${item.name}, qui ${manualMessage ? "n'est pas" : "est" } géré automatiquement. ${manualMessage ?? ''}`
|
||||
content: `${this.name} a reçu un/une ${item.type}: ${item.name}, qui ${manualMessage ? "n'est pas" : "est"} géré automatiquement. ${manualMessage ?? ''}`
|
||||
});
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user