Gestion des maladresses #68
This commit is contained in:
parent
84b4063789
commit
3627d05599
@ -71,7 +71,7 @@ export class RdDItemArme extends Item {
|
||||
static mainsNues() {
|
||||
const mainsNues = {
|
||||
name: "Mains nues",
|
||||
data: { unemain: true, deuxmains: false, dommages: 0, dommagesReels: 0, mortalite: 'non-mortel', competence: 'Corps à corps' }
|
||||
data: { unemain: true, deuxmains: false, dommages: 0, dommagesReels: 0, mortalite: 'non-mortel', competence: 'Corps à corps', sansArme:true }
|
||||
};
|
||||
return mainsNues
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import { Misc } from "./misc.js";
|
||||
import { RdDBonus } from "./rdd-bonus.js";
|
||||
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
||||
import { RdDRoll } from "./rdd-roll.js";
|
||||
import { RdDRollTables } from "./rdd-rolltables.js";
|
||||
|
||||
export class RdDCombat {
|
||||
|
||||
@ -135,8 +136,10 @@ export class RdDCombat {
|
||||
console.log("RdDCombat.attaque >>>", rollData);
|
||||
|
||||
const dialog = await RdDRoll.create(this.attacker, rollData,
|
||||
{ html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html',
|
||||
options: { height: 540 } }, {
|
||||
{
|
||||
html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html',
|
||||
options: { height: 540 }
|
||||
}, {
|
||||
name: 'jet-attaque',
|
||||
label: 'Attaque: ' + (arme ? arme.name : competence.name),
|
||||
callbacks: [
|
||||
@ -309,11 +312,11 @@ export class RdDCombat {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_onAttaqueEchecTotal(rollData) {
|
||||
async _onAttaqueEchecTotal(rollData) {
|
||||
console.log("RdDCombat.onEchecTotal >>>", rollData);
|
||||
// TODO: proposer un résultat d'échec total
|
||||
let chatOptions = {
|
||||
content: "<strong>Echec total à l'attaque!</strong> "
|
||||
+ await RdDRollTables.getMaladresse({ arme: rollData.arme && !rollData.arme.data.sansArme })
|
||||
}
|
||||
ChatUtility.chatWithRollMode(chatOptions, this.attacker.name)
|
||||
}
|
||||
@ -347,8 +350,10 @@ export class RdDCombat {
|
||||
let rollData = this._prepareParade(attackerRoll, arme);
|
||||
|
||||
const dialog = await RdDRoll.create(this.defender, rollData,
|
||||
{ html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html',
|
||||
options: { height: 540 } }, {
|
||||
{
|
||||
html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html',
|
||||
options: { height: 540 }
|
||||
}, {
|
||||
name: 'jet-parade',
|
||||
label: 'Parade: ' + (arme ? arme.name : rollData.competence.name),
|
||||
callbacks: [
|
||||
@ -442,11 +447,11 @@ export class RdDCombat {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_onParadeEchecTotal(rollData) {
|
||||
async _onParadeEchecTotal(rollData) {
|
||||
console.log("RdDCombat._onParadeEchecTotal >>>", rollData);
|
||||
// TODO: proposer un résultat d'échec total
|
||||
let chatOptions = {
|
||||
content: "<strong>Echec total à la parade!</strong> "
|
||||
+ await RdDRollTables.getMaladresse({ arme: rollData.arme && !rollData.arme.data.sansArme })
|
||||
}
|
||||
ChatUtility.chatWithRollMode(chatOptions, this.defender.name)
|
||||
}
|
||||
@ -536,15 +541,15 @@ export class RdDCombat {
|
||||
+ RdDResolutionTable.explain(rollData.rolled)
|
||||
+ "<br><strong>Attaque esquivée!</strong>"
|
||||
}
|
||||
|
||||
ChatUtility.chatWithRollMode(chatOptions, this.defender.name)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_onEsquiveEchecTotal(rollData) {
|
||||
async _onEsquiveEchecTotal(rollData) {
|
||||
console.log("RdDCombat._onEsquiveEchecTotal >>>", rollData);
|
||||
// TODO: proposer un résultat d'échec total
|
||||
let chatOptions = {
|
||||
content: "<strong>Echec total à l'esquive'!</strong> "
|
||||
+ await RdDRollTables.getMaladresse({ arme: false })
|
||||
}
|
||||
ChatUtility.chatWithRollMode(chatOptions, this.defender.name)
|
||||
}
|
||||
@ -586,7 +591,8 @@ export class RdDCombat {
|
||||
let resistRoll = await RdDResolutionTable.rollData({
|
||||
caracValue: resistance,
|
||||
finalLevel: - dmg,
|
||||
showDice: false});
|
||||
showDice: false
|
||||
});
|
||||
if (resistRoll.isSuccess) { // Perte de résistance
|
||||
msg = "Votre " + rollData.arme.name + " tient le choc de la parade. "
|
||||
} else {
|
||||
@ -604,14 +610,17 @@ export class RdDCombat {
|
||||
let desarme = await RdDResolutionTable.rollData({
|
||||
caracValue: this.defender.data.data.carac.force.value,
|
||||
finalLevel: Misc.toInt(rollData.competence.data.niveau) - dmg,
|
||||
showDice: false});
|
||||
showDice: false
|
||||
});
|
||||
if (desarme.isEchec) {
|
||||
msg += "Vous ne parvenez pas à garder votre arme en main, elle tombe au sol à vos pieds";
|
||||
}
|
||||
}
|
||||
ChatMessage.create( { content: msg,
|
||||
ChatMessage.create({
|
||||
content: msg,
|
||||
user: game.user._id,
|
||||
whisper: [game.user._id, ChatMessage.getWhisperRecipients("GM") ] } );
|
||||
whisper: [game.user._id, ChatMessage.getWhisperRecipients("GM")]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -623,7 +632,8 @@ export class RdDCombat {
|
||||
let recul = await RdDResolutionTable.rollData({
|
||||
caracValue: 10,
|
||||
finalLevel: reculNiveau,
|
||||
showDice: false});
|
||||
showDice: false
|
||||
});
|
||||
|
||||
let msg = "";
|
||||
if (recul.isSuccess) {
|
||||
@ -632,16 +642,19 @@ export class RdDCombat {
|
||||
let chute = await RdDResolutionTable.rollData({
|
||||
caracValue: this.defender.data.data.carac.agilite.value,
|
||||
finalLevel: reculNiveau,
|
||||
showDice: false});
|
||||
showDice: false
|
||||
});
|
||||
if (!chute.isSuccess || recul.isETotal) {
|
||||
msg = "Sous la violence du coup, vous reculez et chutez au sol ! Vous ne pouvez plus attaquer ce round.";
|
||||
} else {
|
||||
msg = "La violence du choc vous fait reculer de quelques mètres ! Vous ne pouvez plus attaquer ce round.";
|
||||
}
|
||||
}
|
||||
ChatMessage.create( {content: msg,
|
||||
ChatMessage.create({
|
||||
content: msg,
|
||||
user: game.user._id,
|
||||
whisper: [game.user._id, ChatMessage.getWhisperRecipients("GM") ] } );
|
||||
whisper: [game.user._id, ChatMessage.getWhisperRecipients("GM")]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ export class RdDRollTables {
|
||||
const table = await pack.getEntity(entry._id);
|
||||
const draw = await table.draw({ displayChat: toChat });
|
||||
console.log("RdDRollTables", tableName, toChat, ":", draw);
|
||||
console.log("RdDRollTables", tableName, toChat, ":", draw.roll, draw.results);
|
||||
return draw;
|
||||
}
|
||||
|
||||
@ -16,9 +15,25 @@ export class RdDRollTables {
|
||||
static async drawItemFromRollTable(tableName, toChat) {
|
||||
const draw = await RdDRollTables.genericGetTableResult(tableName, toChat);
|
||||
const drawnItemRef = draw.results.length > 0 ? draw.results[0] : undefined;
|
||||
if (drawnItemRef.collection) {
|
||||
const pack = game.packs.get(drawnItemRef.collection);
|
||||
return await pack.getEntity(drawnItemRef.resultId);
|
||||
}
|
||||
ui.notifications.warn("le tirage ne correspond pas à une entrée d'un Compendium")
|
||||
return drawnItemRef.text;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async drawTextFromRollTable(tableName, toChat) {
|
||||
const draw = await RdDRollTables.genericGetTableResult(tableName, toChat);
|
||||
const drawnItemRef = draw.results.length > 0 ? draw.results[0] : undefined;
|
||||
if (drawnItemRef.collection) {
|
||||
ui.notifications.warn("le tirage correspond à une entrée d'un Compendium, on attendait un texte")
|
||||
return await pack.getEntity(drawnItemRef.resultId);
|
||||
}
|
||||
return drawnItemRef.text;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async getSouffle(toChat = true) {
|
||||
return await RdDRollTables.drawItemFromRollTable("Souffles de Dragon", toChat);
|
||||
@ -48,4 +63,10 @@ export class RdDRollTables {
|
||||
static async getTarot(toChat = true) {
|
||||
return await RdDRollTables.drawItemFromRollTable("Tarot Draconique", toChat);
|
||||
}
|
||||
|
||||
static async getMaladresse(options = {toChat: false, arme: false}) {
|
||||
return await RdDRollTables.drawTextFromRollTable(
|
||||
options.arme ? "Maladresse armé" : "Maladresses non armé",
|
||||
options.toChat);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user