Fix combat.js
This commit is contained in:
parent
8c2d49652c
commit
15e4bfb713
@ -85,48 +85,23 @@ export class RdDCombatManager extends Combat {
|
||||
// calculate initiative
|
||||
for (let cId = 0; cId < ids.length; 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);
|
||||
if (!formula) {
|
||||
if (combatant.actor.data.type == 'creature' || combatant.actor.data.type == 'entite') {
|
||||
const competence = combatant.actor.data.items.find(it => it.data.data.iscombat)
|
||||
if (combatant.actor.type == 'creature' || combatant.actor.type == 'entite') {
|
||||
const competence = combatant.actor.items.find(it => it.system.iscombat)
|
||||
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 {
|
||||
const armeCombat = combatant.actor.data.items.find(it => it.type == 'arme' && itemData.data.equipe)
|
||||
const compName = (armeCombat == undefined) ? "Corps à corps" : armeCombat.data.competence;
|
||||
const competence = RdDItemCompetence.findCompetence(combatant.actor.data.items, compName);
|
||||
const armeCombat = combatant.actor.items.find(it => it.type == 'arme' && itemData.system.equipe)
|
||||
const compName = (armeCombat == undefined) ? "Corps à corps" : armeCombat.system.competence;
|
||||
const competence = RdDItemCompetence.findCompetence(combatant.actor.items, compName);
|
||||
if (competence) {
|
||||
const carac = combatant.actor.data.data.carac[competence.data.defaut_carac].value;
|
||||
const niveau = competence.data.niveau;
|
||||
const bonusEcaille = (armeCombat?.data.magique) ? armeCombat.data.ecaille_efficacite : 0;
|
||||
const carac = combatant.actor.system.carac[competence.system.defaut_carac].value;
|
||||
const niveau = competence.system.niveau;
|
||||
const bonusEcaille = (armeCombat?.data.magique) ? armeCombat.system.ecaille_efficacite : 0;
|
||||
rollFormula = RdDCombatManager.formuleInitiative(2, carac, niveau, bonusEcaille);
|
||||
}
|
||||
>>>>>>> origin/v1.5
|
||||
}
|
||||
}
|
||||
//console.log("Combatat", c);
|
||||
@ -180,70 +155,37 @@ export class RdDCombatManager extends Combat {
|
||||
// Gestion des armes 1/2 mains
|
||||
let actionsArme = [];
|
||||
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));
|
||||
if (action.data.equipe) {
|
||||
let compData = competences.map(c => Misc.data(c)).find(c => c.name == action.data.competence);
|
||||
if (action.system.equipe) {
|
||||
let compData = competences.find(c => c.name == action.system.competence)
|
||||
|
||||
actionsArme.push(action);
|
||||
action.action = 'attaque';
|
||||
action.data.dommagesReels = Number(action.data.dommages);
|
||||
action.data.niveau = compData.data.niveau;
|
||||
action.data.initiative = RdDCombatManager.calculInitiative(compData.data.niveau, carac[compData.data.defaut_carac].value);
|
||||
action.system.dommagesReels = Number(action.system.dommages);
|
||||
action.system.niveau = compData.data.niveau;
|
||||
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
|
||||
if (action.data.unemain && !action.data.deuxmains) {
|
||||
action.data.mainInfo = "(1m)";
|
||||
} else if (!action.data.unemain && action.data.deuxmains) {
|
||||
action.data.mainInfo = "(2m)";
|
||||
} else if (action.data.unemain && action.data.deuxmains) {
|
||||
action.data.mainInfo = "(1m)";
|
||||
if (action.system.unemain && !action.system.deuxmains) {
|
||||
action.system.mainInfo = "(1m)";
|
||||
} else if (!action.system.unemain && action.system.deuxmains) {
|
||||
action.system.mainInfo = "(2m)";
|
||||
} else if (action.system.unemain && action.system.deuxmains) {
|
||||
action.system.mainInfo = "(1m)";
|
||||
|
||||
const comp2m = action.data.competence.replace(" 1 main", " 2 mains"); // Replace !
|
||||
const comp = Misc.data(competences.find(c => c.name == comp2m));
|
||||
const comp2m = action.system.competence.replace(" 1 main", " 2 mains"); // Replace !
|
||||
const comp = competences.find(c => c.name == comp2m)
|
||||
|
||||
const arme2main = duplicate(action);
|
||||
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);
|
||||
actionsArme.push(arme2main);
|
||||
const containsSlash = action.data.dommages.includes("/");
|
||||
const containsSlash = action.system.dommages.includes("/");
|
||||
if (containsSlash) {
|
||||
const tableauDegats = action.data.dommages.split("/");
|
||||
action.data.dommagesReels = Number(tableauDegats[0]);
|
||||
arme2main.data.dommagesReels = Number(tableauDegats[1]);
|
||||
>>>>>>> origin/v1.5
|
||||
const tableauDegats = action.system.dommages.split("/");
|
||||
action.system.dommagesReels = Number(tableauDegats[0]);
|
||||
arme2main.system.dommagesReels = Number(tableauDegats[1]);
|
||||
}
|
||||
else{
|
||||
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/",
|
||||
"license": "LICENSE.txt",
|
||||
"flags": {},
|
||||
"version": "10.0.3",
|
||||
"version": "10.0.4",
|
||||
"scripts": [],
|
||||
"esmodules": [
|
||||
"module/rdd-main.js"
|
||||
@ -500,7 +500,7 @@
|
||||
"relationships": {},
|
||||
"socket": true,
|
||||
"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,
|
||||
"gridDistance": 1,
|
||||
"gridUnits": "m",
|
||||
|
Loading…
Reference in New Issue
Block a user