Gestion des signes draconiques #455

Closed
vincent.vandeme wants to merge 233 commits from v1.4-signes-draconiques into master
4 changed files with 18 additions and 27 deletions
Showing only changes of commit 036456e5df - Show all commits

View File

@ -2542,8 +2542,8 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async equiperObjet(itemID) { async equiperObjet(itemID) {
let item = this.getEmbeddedDocument('Item', itemID); let item = this.getEmbeddedDocument('Item', itemID);
if (item?.data?.data) { let itemData = Misc.data(item);
let itemData = Misc.itemData(item); if (itemData?.data) {
const isEquipe = !itemData.data.equipe; const isEquipe = !itemData.data.equipe;
let update = { _id: item._id, "data.equipe": isEquipe }; let update = { _id: item._id, "data.equipe": isEquipe };
await this.updateEmbeddedDocuments('Item', [update]); await this.updateEmbeddedDocuments('Item', [update]);

View File

@ -97,19 +97,8 @@ export class Misc {
return [...new Set(array)]; return [...new Set(array)];
} }
static actorData(actor) {
return Misc.data(actor);
}
static itemData(item) {
return Misc.data(item);
}
static data(it) { static data(it) {
if (it instanceof Item) { if (it instanceof Actor || it instanceof Item || it instanceof Combatant) {
return it.data;
}
if (it instanceof Actor) {
return it.data; return it.data;
} }
return it; return it;

View File

@ -143,18 +143,20 @@ export class RdDCombatManager extends Combat {
// Gestion des armes 1/2 mains // Gestion des armes 1/2 mains
let armesEquipe = []; let armesEquipe = [];
for (const arme of armes) { for (const arme of armes) {
if (arme.data.equipe) { let armeData = Misc.data(arme);
armesEquipe.push(arme); if (armeData.data.equipe) {
let comp = competences.find(c => c.name == arme.data.competence); let compData = competences.map(c => Misc.data(c)).find(c => c.name == armeData.data.competence);
arme.data.initiative = RdDCombatManager.calculInitiative(arme.data.niveau, carac[comp.data.defaut_carac].value);
armesEquipe.push(armeData);
armeData.data.initiative = RdDCombatManager.calculInitiative(armeData.data.niveau, carac[compData.data.defaut_carac].value);
// Dupliquer les armes pouvant être à 1 main et 2 mains en patchant la compétence // Dupliquer les armes pouvant être à 1 main et 2 mains en patchant la compétence
if (arme.data.unemain && !arme.data.deuxmains) { if (armeData.data.unemain && !armeData.data.deuxmains) {
arme.data.mainInfo = "(1m)"; armeData.data.mainInfo = "(1m)";
} else if (!arme.data.unemain && arme.data.deuxmains) { } else if (!armeData.data.unemain && armeData.data.deuxmains) {
arme.data.mainInfo = "(2m)"; armeData.data.mainInfo = "(2m)";
} else if (arme.data.unemain && arme.data.deuxmains) { } else if (armeData.data.unemain && armeData.data.deuxmains) {
arme.data.mainInfo = "(1m)"; armeData.data.mainInfo = "(1m)";
let arme2main = duplicate(arme); let arme2main = duplicate(armeData);
arme2main.data.mainInfo = "(2m)"; arme2main.data.mainInfo = "(2m)";
arme2main.data.dommages = arme2main.data.dommages.split("/")[1]; // Existence temporaire uniquement dans la liste des armes, donc OK arme2main.data.dommages = arme2main.data.dommages.split("/")[1]; // Existence temporaire uniquement dans la liste des armes, donc OK
arme2main.data.competence = arme2main.data.competence.replace(" 1 main", " 2 mains"); // Replace ! arme2main.data.competence = arme2main.data.competence.replace(" 1 main", " 2 mains"); // Replace !
@ -182,7 +184,6 @@ export class RdDCombatManager extends Combat {
} else { } else {
// Recupération des items 'arme' // Recupération des items 'arme'
let armes = items.filter(it => RdDItemArme.isArmeUtilisable(it)) let armes = items.filter(it => RdDItemArme.isArmeUtilisable(it))
.map(arme => duplicate(arme)) /* pas de changements aux armes d'origine */
.concat(RdDItemArme.mainsNues()); .concat(RdDItemArme.mainsNues());
let competences = items.filter(it => it.type == 'competence'); let competences = items.filter(it => it.type == 'competence');

View File

@ -1,5 +1,6 @@
/* -------------------------------------------- */ /* -------------------------------------------- */
import { HtmlUtility } from "./html-utility.js"; import { HtmlUtility } from "./html-utility.js";
import { Misc } from "./misc.js";
import { RdDCombatManager } from "./rdd-combat.js"; import { RdDCombatManager } from "./rdd-combat.js";
import { RdDUtility } from "./rdd-utility.js"; import { RdDUtility } from "./rdd-utility.js";
@ -24,7 +25,7 @@ export class RdDTokenHud {
let token = canvas.tokens.get(tokenId); let token = canvas.tokens.get(tokenId);
let actor = token.actor; let actor = token.actor;
let combatant = game.combat.data.combatants.find(c => c.tokenId == token.data._id); let combatant = game.combat.combatants.find(c => Misc.data(c).tokenId == tokenId);
app.hasExtension = true; app.hasExtension = true;
let armesList = RdDCombatManager.buildListeActionsCombat(combatant) ; let armesList = RdDCombatManager.buildListeActionsCombat(combatant) ;