Fix combat.js
This commit is contained in:
parent
8c2d49652c
commit
15e4bfb713
@ -85,48 +85,23 @@ export class RdDCombatManager extends Combat {
|
|||||||
// calculate initiative
|
// calculate initiative
|
||||||
for (let cId = 0; cId < ids.length; cId++) {
|
for (let cId = 0; cId < ids.length; cId++) {
|
||||||
const combatant = this.combatants.get(ids[cId]);
|
const combatant = this.combatants.get(ids[cId]);
|
||||||
<<<<<<< HEAD
|
|
||||||
//if (!c) return results;
|
|
||||||
|
|
||||||
let rollFormula = formula; // Init per default
|
|
||||||
if (!rollFormula) {
|
|
||||||
let armeCombat, competence;
|
|
||||||
if (combatant.actor.system.type == 'creature' || combatant.actor.system.type == 'entite') {
|
|
||||||
for (const competenceItemData of combatant.actor.items) {
|
|
||||||
if (competenceItemData.system.iscombat) {
|
|
||||||
competence = duplicate(competenceItemData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rollFormula = "2+( (" + RdDCombatManager.calculInitiative(competence.system.niveau, competence.system.carac_value) + ")/100)";
|
|
||||||
} else {
|
|
||||||
for (const itemData of combatant.actor.items) {
|
|
||||||
if (itemData.type == "arme" && itemData.data.equipe) {
|
|
||||||
armeCombat = duplicate(itemData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let compName = (armeCombat == undefined) ? "Corps à corps" : armeCombat.system.competence;
|
|
||||||
competence = RdDItemCompetence.findCompetence(combatant.actor.items, compName);
|
|
||||||
let bonusEcaille = (armeCombat && armeCombat.data.magique) ? armeCombat.system.ecaille_efficacite : 0;
|
|
||||||
rollFormula = "2+( (" + RdDCombatManager.calculInitiative(competence.system.niveau, combatant.actor.system.carac[competence.system.defaut_carac].value, bonusEcaille) + ")/100)";
|
|
||||||
=======
|
|
||||||
let rollFormula = formula ?? RdDCombatManager.formuleInitiative(2, 10, 0, 0);
|
let rollFormula = formula ?? RdDCombatManager.formuleInitiative(2, 10, 0, 0);
|
||||||
if (!formula) {
|
if (!formula) {
|
||||||
if (combatant.actor.data.type == 'creature' || combatant.actor.data.type == 'entite') {
|
if (combatant.actor.type == 'creature' || combatant.actor.type == 'entite') {
|
||||||
const competence = combatant.actor.data.items.find(it => it.data.data.iscombat)
|
const competence = combatant.actor.items.find(it => it.system.iscombat)
|
||||||
if (competence) {
|
if (competence) {
|
||||||
rollFormula = RdDCombatManager.formuleInitiative(2, competence.data.carac_value, competence.data.niveau, 0);
|
rollFormula = RdDCombatManager.formuleInitiative(2, competence.system.carac_value, competence.system.niveau, 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const armeCombat = combatant.actor.data.items.find(it => it.type == 'arme' && itemData.data.equipe)
|
const armeCombat = combatant.actor.items.find(it => it.type == 'arme' && itemData.system.equipe)
|
||||||
const compName = (armeCombat == undefined) ? "Corps à corps" : armeCombat.data.competence;
|
const compName = (armeCombat == undefined) ? "Corps à corps" : armeCombat.system.competence;
|
||||||
const competence = RdDItemCompetence.findCompetence(combatant.actor.data.items, compName);
|
const competence = RdDItemCompetence.findCompetence(combatant.actor.items, compName);
|
||||||
if (competence) {
|
if (competence) {
|
||||||
const carac = combatant.actor.data.data.carac[competence.data.defaut_carac].value;
|
const carac = combatant.actor.system.carac[competence.system.defaut_carac].value;
|
||||||
const niveau = competence.data.niveau;
|
const niveau = competence.system.niveau;
|
||||||
const bonusEcaille = (armeCombat?.data.magique) ? armeCombat.data.ecaille_efficacite : 0;
|
const bonusEcaille = (armeCombat?.data.magique) ? armeCombat.system.ecaille_efficacite : 0;
|
||||||
rollFormula = RdDCombatManager.formuleInitiative(2, carac, niveau, bonusEcaille);
|
rollFormula = RdDCombatManager.formuleInitiative(2, carac, niveau, bonusEcaille);
|
||||||
}
|
}
|
||||||
>>>>>>> origin/v1.5
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//console.log("Combatat", c);
|
//console.log("Combatat", c);
|
||||||
@ -180,70 +155,37 @@ export class RdDCombatManager extends Combat {
|
|||||||
// Gestion des armes 1/2 mains
|
// Gestion des armes 1/2 mains
|
||||||
let actionsArme = [];
|
let actionsArme = [];
|
||||||
for (const arme of armes) {
|
for (const arme of armes) {
|
||||||
<<<<<<< HEAD
|
|
||||||
let armeData = duplicate(arme)
|
|
||||||
if (armeData.system.equipe) {
|
|
||||||
let compData = competences.find(c => c.name.toLowerCase() == armeData.system.competence.toLowerCase())
|
|
||||||
|
|
||||||
armesEquipe.push(armeData)
|
|
||||||
armeData.system.dommagesReels = Number(armeData.system.dommages)
|
|
||||||
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.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.system.competence.replace(" 1 main", " 2 mains"); // Replace !
|
|
||||||
const comp = competences.find(c => c.name == comp2m)
|
|
||||||
|
|
||||||
const arme2main = duplicate(armeData)
|
|
||||||
arme2main.system.mainInfo = "(2m)";
|
|
||||||
arme2main.system.niveau = comp.system.niveau;
|
|
||||||
arme2main.system.competence = comp2m;
|
|
||||||
arme2main.system.initiative = RdDCombatManager.calculInitiative(arme2main.niveau, carac[comp.system.defaut_carac].value)
|
|
||||||
armesEquipe.push(arme2main);
|
|
||||||
const containsSlash = armeData.system.dommages.includes("/");
|
|
||||||
if (containsSlash) {
|
|
||||||
const tableauDegats = armeData.system.dommages.split("/");
|
|
||||||
armeData.system.dommagesReels = Number(tableauDegats[0]);
|
|
||||||
arme2main.system.dommagesReels = Number(tableauDegats[1]);
|
|
||||||
=======
|
|
||||||
let action = duplicate(Misc.data(arme));
|
let action = duplicate(Misc.data(arme));
|
||||||
if (action.data.equipe) {
|
if (action.system.equipe) {
|
||||||
let compData = competences.map(c => Misc.data(c)).find(c => c.name == action.data.competence);
|
let compData = competences.find(c => c.name == action.system.competence)
|
||||||
|
|
||||||
actionsArme.push(action);
|
actionsArme.push(action);
|
||||||
action.action = 'attaque';
|
action.action = 'attaque';
|
||||||
action.data.dommagesReels = Number(action.data.dommages);
|
action.system.dommagesReels = Number(action.system.dommages);
|
||||||
action.data.niveau = compData.data.niveau;
|
action.system.niveau = compData.data.niveau;
|
||||||
action.data.initiative = RdDCombatManager.calculInitiative(compData.data.niveau, carac[compData.data.defaut_carac].value);
|
action.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 (action.data.unemain && !action.data.deuxmains) {
|
if (action.system.unemain && !action.system.deuxmains) {
|
||||||
action.data.mainInfo = "(1m)";
|
action.system.mainInfo = "(1m)";
|
||||||
} else if (!action.data.unemain && action.data.deuxmains) {
|
} else if (!action.system.unemain && action.system.deuxmains) {
|
||||||
action.data.mainInfo = "(2m)";
|
action.system.mainInfo = "(2m)";
|
||||||
} else if (action.data.unemain && action.data.deuxmains) {
|
} else if (action.system.unemain && action.system.deuxmains) {
|
||||||
action.data.mainInfo = "(1m)";
|
action.system.mainInfo = "(1m)";
|
||||||
|
|
||||||
const comp2m = action.data.competence.replace(" 1 main", " 2 mains"); // Replace !
|
const comp2m = action.system.competence.replace(" 1 main", " 2 mains"); // Replace !
|
||||||
const comp = Misc.data(competences.find(c => c.name == comp2m));
|
const comp = competences.find(c => c.name == comp2m)
|
||||||
|
|
||||||
const arme2main = duplicate(action);
|
const arme2main = duplicate(action);
|
||||||
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);
|
||||||
actionsArme.push(arme2main);
|
actionsArme.push(arme2main);
|
||||||
const containsSlash = action.data.dommages.includes("/");
|
const containsSlash = action.system.dommages.includes("/");
|
||||||
if (containsSlash) {
|
if (containsSlash) {
|
||||||
const tableauDegats = action.data.dommages.split("/");
|
const tableauDegats = action.system.dommages.split("/");
|
||||||
action.data.dommagesReels = Number(tableauDegats[0]);
|
action.system.dommagesReels = Number(tableauDegats[0]);
|
||||||
arme2main.data.dommagesReels = Number(tableauDegats[1]);
|
arme2main.system.dommagesReels = Number(tableauDegats[1]);
|
||||||
>>>>>>> origin/v1.5
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
ui.notifications.info("Les dommages de l'arme à 1/2 mains " + action.name + " ne sont pas corrects (ie sous la forme X/Y)");
|
ui.notifications.info("Les dommages de l'arme à 1/2 mains " + action.name + " ne sont pas corrects (ie sous la forme X/Y)");
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
"url": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/",
|
"url": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/",
|
||||||
"license": "LICENSE.txt",
|
"license": "LICENSE.txt",
|
||||||
"flags": {},
|
"flags": {},
|
||||||
"version": "10.0.3",
|
"version": "10.0.4",
|
||||||
"scripts": [],
|
"scripts": [],
|
||||||
"esmodules": [
|
"esmodules": [
|
||||||
"module/rdd-main.js"
|
"module/rdd-main.js"
|
||||||
@ -500,7 +500,7 @@
|
|||||||
"relationships": {},
|
"relationships": {},
|
||||||
"socket": true,
|
"socket": true,
|
||||||
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json",
|
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json",
|
||||||
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.0.3.zip",
|
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.0.4.zip",
|
||||||
"protected": false,
|
"protected": false,
|
||||||
"gridDistance": 1,
|
"gridDistance": 1,
|
||||||
"gridUnits": "m",
|
"gridUnits": "m",
|
||||||
|
Loading…
Reference in New Issue
Block a user