Fix armes naturelles/corps à corps

This commit is contained in:
sladecraven 2022-11-20 16:08:48 +01:00
parent 5ba86f12df
commit 3543ce60cb
3 changed files with 53 additions and 52 deletions

View File

@ -107,8 +107,8 @@ export class RdDCombatManager extends Combat {
}
//console.log("Combatat", c);
const roll = combatant.getInitiativeRoll(rollFormula);
if ( !roll.total) {
roll.evaluate( {async: false});
if (!roll.total) {
roll.evaluate({ async: false });
}
if (roll.total <= 0) roll.total = 0.00;
console.log("Compute init for", rollFormula, roll.total, combatant);
@ -156,12 +156,14 @@ export class RdDCombatManager extends Combat {
let actions = [];
for (const arme of armes) {
if (arme.system.equipe) {
const dommages = arme.system.dommages;
const tableauDommages = dommages.includes("/") ? dommages.split("/") : [dommages, dommages] ;
const dommages = arme.system.dommages.toString();
const tableauDommages = dommages.includes("/") ? dommages.split("/") : [dommages, dommages];
if (arme.system.unemain && arme.system.deuxmains && !dommages.includes("/")) {
ui.notifications.info("Les dommages de l'arme à 1/2 mains " + arme.name + " ne sont pas corrects (ie sous la forme X/Y)");
}
if (arme.system.unemain && arme.system.competence) {
console.log(">>>>", arme)
if ((arme.system.unemain && arme.system.competence) ||
(arme.system.competence.toLowerCase().includes("corps à corps"))) {
actions.push(RdDCombatManager.$prepareAttaqueArme({
arme: arme,
infoMain: "(1 main)",
@ -224,8 +226,7 @@ export class RdDCombatManager extends Combat {
}
static listActionsPossessions(actor) {
return RdDCombatManager._indexActions(actor.getPossessions().map(p =>
{
return RdDCombatManager._indexActions(actor.getPossessions().map(p => {
return {
name: p.name,
action: 'conjurer',
@ -241,7 +242,7 @@ export class RdDCombatManager extends Combat {
static listActionsCombat(combatant) {
const actor = combatant.actor;
let actions = RdDCombatManager.listActionsPossessions(actor);
if (actions.length>0) {
if (actions.length > 0) {
return actions;
}
if (actor.isCreature()) {
@ -394,7 +395,7 @@ export class RdDCombatManager extends Combat {
static displayInitiativeMenu(html, combatantId) {
console.log("Combatant ; ", combatantId);
const combatant = game.combat.combatants.get(combatantId);
if (! (combatant?.actor) ) {
if (!(combatant?.actor)) {
ui.notifications.warn(`Le combatant ${combatant.name ?? combatantId} n'est pas associé à un acteur, impossible de déterminer ses actions de combat!`)
return;
}
@ -479,7 +480,7 @@ export class RdDCombat {
else {
const defender = target?.actor;
const defenderTokenId = target?.id;
if ( defender.type == 'entite' && defender.system.definition.typeentite == ENTITE_NONINCARNE) {
if (defender.type == 'entite' && defender.system.definition.typeentite == ENTITE_NONINCARNE) {
ui.notifications.warn("Vous ne pouvez pas cibler une entité non incarnée !!!!");
} else {
return this.create(attacker, defender, defenderTokenId, target)
@ -589,7 +590,7 @@ export class RdDCombat {
async onEvent(button, event) {
const chatMessage = ChatUtility.getChatMessage(event);
const defenderRoll = ChatUtility.getMessageData(chatMessage, 'defender-roll');
const attackerRoll = defenderRoll?.attackerRoll ?? ChatUtility.getMessageData(chatMessage, 'attacker-roll') ;
const attackerRoll = defenderRoll?.attackerRoll ?? ChatUtility.getMessageData(chatMessage, 'attacker-roll');
console.log('RdDCombat', attackerRoll, defenderRoll);
const defenderTokenId = event.currentTarget.attributes['data-defenderTokenId']?.value;
@ -709,12 +710,13 @@ export class RdDCombat {
}
/* -------------------------------------------- */
async proposerAjustementTirLancer( rollData ) {
async proposerAjustementTirLancer(rollData) {
if (['tir', 'lancer'].includes(rollData.competence.system.categorie)) {
if (this.defender.isEntite([ENTITE_BLURETTE])){
ChatMessage.create( {
if (this.defender.isEntite([ENTITE_BLURETTE])) {
ChatMessage.create({
content: `<strong>La cible est une blurette, l'arme à distance sera perdue dans le blurêve`,
whisper: ChatMessage.getWhisperRecipients("GM")})
whisper: ChatMessage.getWhisperRecipients("GM")
})
}
else {
const defenderToken = canvas.tokens.get(this.defenderTokenId);
@ -723,7 +725,7 @@ export class RdDCombat {
const portee = this._ajustementPortee(dist, rollData.arme)
const taille = this._ajustementTaille(this.defender)
const activite = this._ajustementMouvement(this.defender)
const total = [portee, taille, activite].map(it=>it.diff).filter(d => !Number.isNaN(d)).reduce(Misc.sum(), 0)
const total = [portee, taille, activite].map(it => it.diff).filter(d => !Number.isNaN(d)).reduce(Misc.sum(), 0)
ChatMessage.create({
content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-info-distance.html', {
rollData: rollData,
@ -751,26 +753,26 @@ export class RdDCombat {
}
_ajustementPortee(dist, arme) {
if (dist <= arme.system.portee_courte) return {msg:"courte", diff:0};
if (dist <= arme.system.portee_moyenne) return {msg: "moyenne" , diff: -3};
if (dist <= arme.system.portee_extreme) return {msg: "extrême", diff:-5};
return {msg: "inatteignable", diff: -10};
if (dist <= arme.system.portee_courte) return { msg: "courte", diff: 0 };
if (dist <= arme.system.portee_moyenne) return { msg: "moyenne", diff: -3 };
if (dist <= arme.system.portee_extreme) return { msg: "extrême", diff: -5 };
return { msg: "inatteignable", diff: -10 };
}
_ajustementTaille(actor) {
if (actor.isVehicule()) return {msg: "véhicule", diff: 0}
if (actor.isVehicule()) return { msg: "véhicule", diff: 0 }
const taille = actor.getCaracByName('TAILLE')?.value ?? 1;
if (taille <= 1) return {msg: "souris", diff: -8};
if (taille <= 3) return {msg: "chat", diff: -4};
if (taille <= 5) return {msg: "chien", diff: -2};
if (taille <= 15) return {msg: "humanoïde", diff: 0};
if (taille <= 20) return {msg: "ogre", diff: 2};
return {msg: "gigantesque", diff: 4};
if (taille <= 1) return { msg: "souris", diff: -8 };
if (taille <= 3) return { msg: "chat", diff: -4 };
if (taille <= 5) return { msg: "chien", diff: -2 };
if (taille <= 15) return { msg: "humanoïde", diff: 0 };
if (taille <= 20) return { msg: "ogre", diff: 2 };
return { msg: "gigantesque", diff: 4 };
}
_ajustementMouvement(defender) {
if (defender.getSurprise(true)) return {msg: "immobile (surprise)", diff: 0};
if (game.combat?.combatants.find(it => it.actorId == defender.id)) return {msg: "en mouvement (combat)", diff: -4};
return {msg: "à déterminer (0 immobile, -3 actif, -4 en mouvement, -5 en zig-zag)", diff: -3};
if (defender.getSurprise(true)) return { msg: "immobile (surprise)", diff: 0 };
if (game.combat?.combatants.find(it => it.actorId == defender.id)) return { msg: "en mouvement (combat)", diff: -4 };
return { msg: "à déterminer (0 immobile, -3 actif, -4 en mouvement, -5 en zig-zag)", diff: -3 };
}
/* -------------------------------------------- */
@ -914,7 +916,7 @@ export class RdDCombat {
}
/* -------------------------------------------- */
isPossession( attackerRoll) {
isPossession(attackerRoll) {
return attackerRoll.selectedCarac.label.toLowerCase() == 'possession';
}
@ -1057,9 +1059,8 @@ export class RdDCombat {
const arme = this.defender.getArmeParade(armeParadeId);
console.log("RdDCombat.parade >>>", attackerRoll, armeParadeId, arme);
const competence = arme?.system?.competence;
if (competence == undefined)
{
console.error("Pas de compétence de parade associée à ", arme?.name, armeParadeId) ;
if (competence == undefined) {
console.error("Pas de compétence de parade associée à ", arme?.name, armeParadeId);
return;
}

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,8 @@
{
"id": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon",
"version": "10.2.5",
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.2.5.zip",
"version": "10.2.6",
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.2.6.zip",
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json",
"compatibility": {
"minimum": "10",