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