Various fixes - WIP
This commit is contained in:
parent
5214b036d3
commit
580fdb996b
@ -35,10 +35,10 @@ export class RdDActorEntiteSheet extends ActorSheet {
|
||||
const objectData = Misc.data(this.object);
|
||||
let formData = {
|
||||
title: this.title,
|
||||
id: objectData.id,
|
||||
type: objectData.type,
|
||||
img: objectData.img,
|
||||
name: objectData.name,
|
||||
id: this.object.id,
|
||||
type: this.object.type,
|
||||
img: this.object.img,
|
||||
name: this.object.name,
|
||||
// actor: this.object,
|
||||
editable: this.isEditable,
|
||||
cssClass: this.isEditable ? "editable" : "locked",
|
||||
|
@ -91,9 +91,9 @@ export class RdDActorSheet extends ActorSheet {
|
||||
|
||||
|
||||
// toujours avoir une liste d'armes (pour mettre esquive et corps à corps)
|
||||
formData.combat = duplicate(formData.armes ?? []);
|
||||
RdDItemArme.computeNiveauArmes(formData.combat, formData.competences);
|
||||
RdDItemArme.ajoutCorpsACorps(formData.combat, formData.competences, formData.data.carac);
|
||||
formData.combat = duplicate(formData.armes ?? [])
|
||||
RdDItemArme.computeNiveauArmes(formData.combat, formData.competences)
|
||||
/* TODO TODO RdDItemArme.ajoutCorpsACorps(formData.combat, formData.competences, formData.data.carac)*/
|
||||
formData.esquives = this.actor.getCompetences("Esquive").map(i => foundry.utils.deepClone(i.system))
|
||||
formData.combat = RdDCombatManager.finalizeArmeList(formData.combat, formData.competences, formData.data.carac)
|
||||
|
||||
@ -253,7 +253,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
|
||||
// Equip Inventory Item
|
||||
html.find('.item-equip').click(async event => {
|
||||
this.actor.equiperObjet(RdDSheetUtility.getItemId(event));
|
||||
this.actor.equiperObjet(RdDSheetUtility.getItemId(event))
|
||||
});
|
||||
|
||||
// Roll Carac
|
||||
@ -512,15 +512,16 @@ export class RdDActorSheet extends ActorSheet {
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_getEventArmeCombat(event) {
|
||||
const li = $(event.currentTarget)?.parents(".item");
|
||||
let armeName = li.data("arme-name");
|
||||
let compName = li.data('competence-name');
|
||||
const arme = this.armesList.find(a => a.name == armeName && a.data.competence == compName);
|
||||
const li = $(event.currentTarget)?.parents(".item")
|
||||
let armeName = li.data("arme-name")
|
||||
let compName = li.data('competence-name')
|
||||
const arme = this.armesList.find(a => a.name == armeName && a.system.competence == compName)
|
||||
if (!arme) {
|
||||
return { name: armeName, data: { competence: compName } };
|
||||
return { name: armeName, data: { competence: compName } }
|
||||
}
|
||||
return arme;
|
||||
return arme
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -3188,6 +3188,7 @@ export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
rollArme(arme) {
|
||||
let itemData = arme.system && arme.system || arme.data
|
||||
console.log("ARME", arme, itemData)
|
||||
let competence = this.getCompetence( itemData.competence )
|
||||
if (arme || (competence.type == 'competencecreature' && competence.system.iscombat)) {
|
||||
if (competence.system.ispossession) {
|
||||
@ -3218,26 +3219,25 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
verifierForceMin(itemData) {
|
||||
if (itemData.type == 'arme' && itemData.data.force > this.system.carac.force.value) {
|
||||
if (itemData.type == 'arme' && itemData.system.force > this.system.carac.force.value) {
|
||||
ChatMessage.create({
|
||||
content: `<strong>${this.name} s'est équipé(e) de l'arme ${itemData.name}, mais n'a pas une force suffisante pour l'utiliser normalement </strong>
|
||||
(${itemData.data.force} nécessaire pour une Force de ${this.system.carac.force.value})`
|
||||
(${itemData.system.force} nécessaire pour une Force de ${this.system.carac.force.value})`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async equiperObjet(itemID) {
|
||||
let item = this.getEmbeddedDocument('Item', itemID);
|
||||
let itemData = Misc.data(item);
|
||||
if (itemData?.data) {
|
||||
const isEquipe = !itemData.data.equipe;
|
||||
let item = this.getEmbeddedDocument('Item', itemID)
|
||||
if (item.system) {
|
||||
const isEquipe = !item.system.equipe
|
||||
let update = { _id: item.id, "data.equipe": isEquipe };
|
||||
await this.updateEmbeddedDocuments('Item', [update]);
|
||||
this.computeEncombrementTotalEtMalusArmure(); // Mise à jour encombrement
|
||||
this.computePrixTotalEquipement(); // Mis à jour du prix total de l'équipement
|
||||
if (isEquipe)
|
||||
this.verifierForceMin(itemData);
|
||||
this.verifierForceMin(item)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,9 +168,9 @@ export class RdDItemArme extends Item {
|
||||
}
|
||||
|
||||
static ajoutCorpsACorps(armes, competences, carac) {
|
||||
let corpsACorps = competences.find(it => it.name == 'Corps à corps') ?? { data: { niveau: -6 } };
|
||||
let init = RdDCombatManager.calculInitiative(corpsACorps.data.niveau, carac['melee'].value);
|
||||
armes.push(RdDItemArme.mainsNues({ niveau: corpsACorps.data.niveau, initiative: init }));
|
||||
let corpsACorps = competences.find(it => it.name == 'Corps à corps') ?? { data: { niveau: -6 } }
|
||||
let init = RdDCombatManager.calculInitiative(corpsACorps.system.niveau, carac['melee'].value)
|
||||
armes.push(RdDItemArme.mainsNues({ niveau: corpsACorps.system.niveau, initiative: init }))
|
||||
//armes.push(RdDItemArme.empoignade({ niveau: corpsACorps.data.niveau, initiative: init }));
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ export class RdDItemArme extends Item {
|
||||
const corpsACorps = {
|
||||
name: 'Corps à corps',
|
||||
img: 'systems/foundryvtt-reve-de-dragon/icons/competence_corps_a_corps.webp',
|
||||
data: {
|
||||
system: {
|
||||
equipe: true,
|
||||
rapide: true,
|
||||
force: 0,
|
||||
@ -189,24 +189,24 @@ export class RdDItemArme extends Item {
|
||||
categorie_parade: 'sans-armes'
|
||||
}
|
||||
};
|
||||
mergeObject(corpsACorps.data, actorData ??{}, { overwrite: false });
|
||||
mergeObject(corpsACorps.system, actorData ??{}, { overwrite: false });
|
||||
return corpsACorps;
|
||||
}
|
||||
|
||||
static mainsNues(actorData) {
|
||||
const mainsNues = RdDItemArme.corpsACorps(actorData);
|
||||
mainsNues.name = 'Mains nues';
|
||||
mainsNues.data.cac = 'pugilat';
|
||||
mainsNues.data.baseInit = 4;
|
||||
mainsNues.system.cac = 'pugilat';
|
||||
mainsNues.system.baseInit = 4;
|
||||
return mainsNues;
|
||||
}
|
||||
|
||||
static empoignade(actorData) {
|
||||
const empoignade = RdDItemArme.corpsACorps(actorData);
|
||||
empoignade.name = 'Empoignade';
|
||||
empoignade.data.cac = 'empoignade';
|
||||
empoignade.data.baseInit = 3;
|
||||
empoignade.data.mortalite = 'empoignade';
|
||||
empoignade.system.cac = 'empoignade';
|
||||
empoignade.system.baseInit = 3;
|
||||
empoignade.system.mortalite = 'empoignade';
|
||||
return empoignade;
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ export class RdDItemCompetence extends Item {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static isCompetenceArme(competence) {
|
||||
switch (competence.categorie) {
|
||||
switch (competence.system.categorie) {
|
||||
case 'melee':
|
||||
return competence.name != 'Esquive';
|
||||
case 'tir':
|
||||
|
@ -26,7 +26,7 @@ const monnaiesData = [
|
||||
export class Monnaie {
|
||||
|
||||
static isSystemMonnaie(item) {
|
||||
let present = monnaiesData.find(monnaie => monnaie.data.valeur_deniers == Misc.data(item)?.data?.valeur_deniers);
|
||||
let present = monnaiesData.find(monnaie => monnaie.system.valeur_deniers == item.system?.valeur_deniers);
|
||||
return present;
|
||||
}
|
||||
|
||||
@ -41,14 +41,14 @@ export class Monnaie {
|
||||
static monnaiesManquantes(items) {
|
||||
const valeurs = Monnaie.filtrerMonnaies(items)
|
||||
.map(it => Misc.templateData(it).valeur_deniers);
|
||||
const manquantes = monnaiesData.filter(monnaie => !valeurs.find(v => v != Misc.templateData(monnaie).valeur_deniers));
|
||||
const manquantes = monnaiesData.filter(monnaie => !valeurs.find(v => v != monnaie.system.valeur_deniers));
|
||||
//const manquantes = monnaiesData.filter(monnaie => !valeurs.find(v => v != Misc.templateData(monnaie).valeur_deniers) );
|
||||
//console.log("Valeurs : ", valeurs, manquantes);
|
||||
return []; //manquantes;
|
||||
}
|
||||
|
||||
static deValeur(monnaie, v) {
|
||||
return v != monnaie.data.valeur_deniers;
|
||||
return v != monnaie.system.valeur_deniers
|
||||
}
|
||||
|
||||
static arrondiDeniers(sols) {
|
||||
@ -56,6 +56,6 @@ export class Monnaie {
|
||||
}
|
||||
|
||||
static triValeurDenier() {
|
||||
return Misc.ascending(item => Misc.data(item).data.valeur_deniers);
|
||||
return Misc.ascending(item => item.system.valeur_deniers)
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ export class RdDCombatManager extends Combat {
|
||||
|
||||
/************************************************************************************/
|
||||
async rollInitiative(ids, formula = undefined, messageOptions = {}) {
|
||||
console.log(`${game.data.system.data.title} | Combat.rollInitiative()`, ids, formula, messageOptions);
|
||||
console.log(`${game.data.system.title} | Combat.rollInitiative()`, ids, formula, messageOptions);
|
||||
// Structure input data
|
||||
ids = typeof ids === "string" ? [ids] : ids;
|
||||
const currentId = this.combatant._id;
|
||||
@ -89,23 +89,23 @@ export class RdDCombatManager extends Combat {
|
||||
let rollFormula = formula; // Init per default
|
||||
if (!rollFormula) {
|
||||
let armeCombat, competence;
|
||||
if (combatant.actor.data.type == 'creature' || combatant.actor.data.type == 'entite') {
|
||||
for (const competenceItemData of combatant.actor.data.items) {
|
||||
if (competenceItemData.data.data.iscombat) {
|
||||
competence = duplicate(competenceItemData);
|
||||
if (combatant.actor.type == 'creature' || combatant.actor.type == 'entite') {
|
||||
for (const competenceItemData of combatant.actor.items) {
|
||||
if (competenceItemData.system.iscombat) {
|
||||
competence = duplicate(competenceItemData)
|
||||
}
|
||||
}
|
||||
rollFormula = "2+( (" + RdDCombatManager.calculInitiative(competence.data.niveau, competence.data.carac_value) + ")/100)";
|
||||
rollFormula = "2+( (" + RdDCombatManager.calculInitiative(competence.system.niveau, competence.system.carac_value) + ")/100)";
|
||||
} else {
|
||||
for (const itemData of combatant.actor.data.items) {
|
||||
if (itemData.type == "arme" && itemData.data.equipe) {
|
||||
armeCombat = duplicate(itemData);
|
||||
for (const itemData of combatant.actor.items) {
|
||||
if (itemData.type == "arme" && itemData.system.equipe) {
|
||||
armeCombat = duplicate(itemData)
|
||||
}
|
||||
}
|
||||
let compName = (armeCombat == undefined) ? "Corps à corps" : armeCombat.data.competence;
|
||||
competence = RdDItemCompetence.findCompetence(combatant.actor.data.items, compName);
|
||||
let bonusEcaille = (armeCombat && armeCombat.data.magique) ? armeCombat.data.ecaille_efficacite : 0;
|
||||
rollFormula = "2+( (" + RdDCombatManager.calculInitiative(competence.data.niveau, Misc.data(combatant.actor).data.carac[competence.data.defaut_carac].value, bonusEcaille) + ")/100)";
|
||||
let compName = (armeCombat == undefined) ? "Corps à corps" : armeCombat.system.competence;
|
||||
competence = RdDItemCompetence.findCompetence(combatant.actor.items, compName);
|
||||
let bonusEcaille = (armeCombat && armeCombat.system.magique) ? armeCombat.system.ecaille_efficacite : 0;
|
||||
rollFormula = "2+( (" + RdDCombatManager.calculInitiative(competence.system.niveau, combatant.actor.system.carac[competence.system.defaut_carac].value, bonusEcaille) + ")/100)";
|
||||
}
|
||||
}
|
||||
//console.log("Combatat", c);
|
||||
@ -154,38 +154,39 @@ export class RdDCombatManager extends Combat {
|
||||
static finalizeArmeList(armes, competences, carac) {
|
||||
// Gestion des armes 1/2 mains
|
||||
let armesEquipe = []
|
||||
for (const arme of armes) {
|
||||
console.log("ARMES", armes)
|
||||
for (const arme of armes) {
|
||||
let armeData = duplicate(arme)
|
||||
if (armeData.data.equipe) {
|
||||
let compData = competences.map(c => Misc.data(c)).find(c => c.name == armeData.data.competence);
|
||||
if (armeData.system.equipe) {
|
||||
let compData = competences.map(c => c).find(c => c.name == armeData.system.competence)
|
||||
|
||||
armesEquipe.push(armeData)
|
||||
armeData.data.dommagesReels = Number(armeData.data.dommages);
|
||||
armeData.system.dommagesReels = Number(armeData.system.dommages)
|
||||
console.log("ARME", armeData, compData)
|
||||
armeData.data.niveau = compData.data.niveau;
|
||||
armeData.data.initiative = RdDCombatManager.calculInitiative(compData.data.niveau, carac[compData.data.defaut_carac].value);
|
||||
armeData.system.niveau = compData.system.niveau
|
||||
armeData.system.initiative = RdDCombatManager.calculInitiative(compData.system.niveau, carac[compData.system.defaut_carac].value);
|
||||
// Dupliquer les armes pouvant être à 1 main et 2 mains en patchant la compétence
|
||||
if (armeData.data.unemain && !armeData.data.deuxmains) {
|
||||
armeData.data.mainInfo = "(1m)";
|
||||
} else if (!armeData.data.unemain && armeData.data.deuxmains) {
|
||||
armeData.data.mainInfo = "(2m)";
|
||||
} else if (armeData.data.unemain && armeData.data.deuxmains) {
|
||||
armeData.data.mainInfo = "(1m)";
|
||||
if (armeData.system.unemain && !armeData.system.deuxmains) {
|
||||
armeData.system.mainInfo = "(1m)";
|
||||
} else if (!armeData.system.unemain && armeData.system.deuxmains) {
|
||||
armeData.system.mainInfo = "(2m)";
|
||||
} else if (armeData.system.unemain && armeData.system.deuxmains) {
|
||||
armeData.system.mainInfo = "(1m)";
|
||||
|
||||
const comp2m = armeData.data.competence.replace(" 1 main", " 2 mains"); // Replace !
|
||||
const comp2m = armeData.system.competence.replace(" 1 main", " 2 mains"); // Replace !
|
||||
const comp = Misc.data(competences.find(c => c.name == comp2m));
|
||||
|
||||
const arme2main = duplicate(armeData);
|
||||
arme2main.data.mainInfo = "(2m)";
|
||||
arme2main.data.niveau = comp.data.niveau;
|
||||
arme2main.data.competence = comp2m;
|
||||
arme2main.data.initiative = RdDCombatManager.calculInitiative(arme2main.data.niveau, carac[comp.data.defaut_carac].value);
|
||||
arme2main.system.mainInfo = "(2m)";
|
||||
arme2main.system.niveau = comp.system.niveau;
|
||||
arme2main.system.competence = comp2m;
|
||||
arme2main.system.initiative = RdDCombatManager.calculInitiative(arme2main.system.niveau, carac[comp.system.defaut_carac].value);
|
||||
armesEquipe.push(arme2main);
|
||||
const containsSlash = armeData.data.dommages.includes("/");
|
||||
const containsSlash = armeData.system.dommages.includes("/");
|
||||
if (containsSlash) {
|
||||
const tableauDegats = armeData.data.dommages.split("/");
|
||||
armeData.data.dommagesReels = Number(tableauDegats[0]);
|
||||
arme2main.data.dommagesReels = Number(tableauDegats[1]);
|
||||
const tableauDegats = armeData.system.dommages.split("/");
|
||||
armeData.system.dommagesReels = Number(tableauDegats[0]);
|
||||
arme2main.system.dommagesReels = Number(tableauDegats[1]);
|
||||
}
|
||||
else{
|
||||
ui.notifications.info("Les dommages de l'arme à 1/2 mains " + armeData.name + " ne sont pas corrects (ie sous la forme X/Y)");
|
||||
@ -193,7 +194,7 @@ export class RdDCombatManager extends Combat {
|
||||
}
|
||||
}
|
||||
}
|
||||
return armesEquipe.sort(Misc.ascending(armeData => armeData.name + (armeData.data.mainInfo ?? '')));
|
||||
return armesEquipe.sort(Misc.ascending(armeData => armeData.name + (armeData.system.mainInfo ?? '')));
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -21,7 +21,7 @@ export class RdDSheetUtility {
|
||||
}
|
||||
|
||||
static prepareItemDropParameters(destItemId, actorId, dragData, objetVersConteneur) {
|
||||
const itemId = dragData.id || dragData.data._id;
|
||||
const itemId = dragData.id || dragData._id
|
||||
return {
|
||||
destId: destItemId,
|
||||
targetActorId: actorId,
|
||||
|
Loading…
Reference in New Issue
Block a user