#42 Tchat message attaque
This commit is contained in:
parent
be90e0c032
commit
cd36331702
@ -15,6 +15,7 @@ import { RdDEncaisser } from "./rdd-roll-encaisser.js";
|
||||
import { RdDCombat } from "./rdd-combat.js";
|
||||
import { DeDraconique } from "./de-draconique.js";
|
||||
import { RdDAudio } from "./rdd-audio.js";
|
||||
import { RdDItemCompetence } from "./item-competence.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/**
|
||||
@ -1556,14 +1557,13 @@ export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async rollCompetence( name ) {
|
||||
let rollData = {
|
||||
competence: duplicate(this.getCompetence(name)),
|
||||
competence: this.getCompetence(name),
|
||||
needSignificative : !this.isEntiteCauchemar() && this.data.data.sante.sonne.value
|
||||
}
|
||||
|
||||
if (rollData.competence.type == 'competencecreature') {
|
||||
// Fake competence pour créature
|
||||
rollData.competence.data = { defaut_carac: "carac_creature", categorie: "creature" };
|
||||
rollData.carac = { carac_creature: { label: competence.name, value: competence.data.carac_value } };
|
||||
RdDItemCompetence.setRollDataCreature(rollData);
|
||||
}
|
||||
else {
|
||||
rollData.carac = this.data.data.carac;
|
||||
@ -1889,7 +1889,7 @@ export class RdDActor extends Actor {
|
||||
RdDCombat.createUsingTarget(this).attaque(competence, armeItem);
|
||||
}
|
||||
else {
|
||||
this.rollCompetence(name);
|
||||
this.rollCompetence(competence.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,24 @@
|
||||
export class RdDItemArme extends Item {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getArmeData(item) {
|
||||
switch (item ? item.data.type : '') {
|
||||
case 'arme': return item.data;
|
||||
case 'competencecreature':
|
||||
return RdDItemArme._getArmeCompetenceCreature(item);
|
||||
}
|
||||
return RdDItemArme.mainsNues();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static _getArmeCompetenceCreature(competenceCreature) {
|
||||
let armeData = duplicate(competenceCreature.data);
|
||||
armeData.data.resistance = 100;
|
||||
armeData.data.competence = armeData.name;
|
||||
armeData.data.dommagesReels = armeData.data.dommagesReels || armeData.data.dommages;
|
||||
return armeData;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getCategorieParade(arme) {
|
||||
if (arme.data.categorie_parade) {
|
||||
@ -38,6 +56,11 @@ export class RdDItemArme extends Item {
|
||||
return 'sans-armes';
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static isArmeParade(arme) {
|
||||
return RdDItemArme.getCategorieParade(arme);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static needParadeSignificative(armeAttaque, armeParade) {
|
||||
let attCategory = RdDItemArme.getCategorieParade(armeAttaque);
|
||||
|
@ -11,4 +11,12 @@ export class RdDItemCompetence extends Item {
|
||||
static isMalusEncombrementTotal(competence) {
|
||||
return competence && competence.name.toLowerCase().match(/(natation|acrobatie)/);
|
||||
}
|
||||
|
||||
static setRollDataCreature(rollData) {
|
||||
rollData.carac = { "carac_creature": { label: rollData.competence.name, value: rollData.competence.data.carac_value } };
|
||||
rollData.competence = duplicate(rollData.competence);
|
||||
rollData.competence.data.defaut_carac = "carac_creature";
|
||||
rollData.competence.data.categorie = "creature";
|
||||
rollData.selectedCarac = rollData.carac.carac_creature
|
||||
}
|
||||
}
|
@ -192,7 +192,7 @@ export class RdDCombat {
|
||||
};
|
||||
|
||||
if (this.attacker.isCreature()) {
|
||||
this._modifieRollDataCreature(rollData, competence);
|
||||
RdDItemCompetence.setRollDataCreature(rollData);
|
||||
}
|
||||
else if (arme) {
|
||||
// Usual competence
|
||||
@ -205,22 +205,6 @@ export class RdDCombat {
|
||||
return rollData;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_modifieRollDataCreature(rollData, competence) {
|
||||
competence = duplicate(competence);
|
||||
competence.data.defaut_carac = "carac_creature";
|
||||
competence.data.categorie = "creature";
|
||||
|
||||
rollData.competence = competence;
|
||||
rollData.carac = { "carac_creature": { label: competence.name, value: competence.data.carac_value } };
|
||||
rollData.arme = {
|
||||
name: competence.name, data: {
|
||||
dommages: competence.data.dommages,
|
||||
dommagesReels: competence.data.dommages
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_onAttaqueParticuliere(rollData) {
|
||||
console.log("RdDCombat.onAttaqueParticuliere >>>", rollData);
|
||||
@ -243,31 +227,12 @@ export class RdDCombat {
|
||||
/* -------------------------------------------- */
|
||||
async _onAttaqueNormale(rollData) {
|
||||
console.log("RdDCombat.onAttaqueNormale >>>", rollData);
|
||||
let explications = "";
|
||||
|
||||
rollData.dmg = RdDBonus.dmg(rollData, this.attacker.getBonusDegat(), this.defender.isEntiteCauchemar());
|
||||
|
||||
if (this.target) {
|
||||
explications += "<br><strong>Cible</strong> : " + this.defender.data.name;
|
||||
}
|
||||
explications += "<br>Encaissement à " + Misc.toSignedString(rollData.dmg.total) + " (" + rollData.dmg.loc.label + ")";
|
||||
|
||||
// Save rollData for defender
|
||||
game.system.rdd.rollDataHandler[this.attackerId] = duplicate(rollData);
|
||||
|
||||
// Message spécial pour la rapidité, qui reste difficile à gérer automatiquement
|
||||
if (rollData.particuliereAttaque == 'rapidite') {
|
||||
explications += "<br>Vous avez attaqué en Rapidité. Vous pourrez faire une deuxième attaque, ou utiliser votre arme pour vous défendre.";
|
||||
}
|
||||
|
||||
// Final chat message
|
||||
let chatOptions = {
|
||||
content: "<strong>Test : " + rollData.selectedCarac.label + " / " + rollData.competence.name + "</strong>"
|
||||
+ RdDResolutionTable.explainRollData(rollData)
|
||||
+ explications
|
||||
}
|
||||
ChatUtility.chatWithRollMode(chatOptions, this.attacker.name)
|
||||
|
||||
rollData.show = {
|
||||
cible: this.target ? this.defender.data.name : 'la cible',
|
||||
isRecul: (rollData.particuliereAttaque == 'force' || rollData.tactique == 'charge')
|
||||
@ -306,7 +271,7 @@ export class RdDCombat {
|
||||
message += "<br><a class='chat-card-button' id='parer-button' data-attackerId='" + this.attackerId + "' data-defenderTokenId='" + this.defenderTokenId + "' data-armeid='" + arme._id + "'>Parer avec " + arme.name + "</a>";
|
||||
}
|
||||
// corps à corps
|
||||
if (rollData.dmg.mortalite != 'mortel') {
|
||||
if (rollData.dmg.mortalite != 'mortel' && this.defender.getCompetence("Corps à corps")) {
|
||||
message += "<br><a class='chat-card-button' id='parer-button' data-attackerId='" + this.attackerId + "' data-defenderTokenId='" + this.defenderTokenId + "'>Parer à mains nues</a>";
|
||||
}
|
||||
// esquive
|
||||
@ -327,20 +292,9 @@ export class RdDCombat {
|
||||
switch (categorie) {
|
||||
case 'tir':
|
||||
case 'lancer':
|
||||
return items.filter(item =>
|
||||
item.type == 'arme' &&
|
||||
item.data.competence.toLowerCase().match("bouclier"));
|
||||
return items.filter(item => RdDItemArme.getCategorieParade(item) == 'boucliers')
|
||||
default:
|
||||
return items.filter(item => {
|
||||
if (item.type == 'competencecreature') {
|
||||
return item.data.isparade;
|
||||
}
|
||||
if (item.type == 'arme') {
|
||||
const comp = this.defender.getCompetence(item.data.competence);
|
||||
return comp && comp.data.categorie == 'melee';
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return items.filter(item => RdDItemArme.getCategorieParade(item));
|
||||
}
|
||||
}
|
||||
|
||||
@ -349,7 +303,7 @@ export class RdDCombat {
|
||||
console.log("RdDCombat.onEchecTotal >>>", rollData);
|
||||
let chatOptions = {
|
||||
content: "<strong>Echec total à l'attaque!</strong> "
|
||||
+ await RdDRollTables.getMaladresse({ arme: rollData.arme && !rollData.arme.data.sansArme })
|
||||
+ await RdDRollTables.getMaladresse({ arme: rollData.arme && rollData.arme.data.categorie_parade != 'sans-armes' })
|
||||
}
|
||||
ChatUtility.chatWithRollMode(chatOptions, this.attacker.name)
|
||||
}
|
||||
@ -400,17 +354,12 @@ export class RdDCombat {
|
||||
}
|
||||
|
||||
_findArmeParade(armeParadeId) {
|
||||
if (armeParadeId) {
|
||||
const armeItem = this.defender.getOwnedItem(armeParadeId);
|
||||
return armeItem.data;
|
||||
|
||||
}
|
||||
return RdDItemArme.mainsNues()
|
||||
return RdDItemArme.getArmeData(armeParadeId ? this.defender.getOwnedItem(armeParadeId) : null);
|
||||
}
|
||||
|
||||
_prepareParade(attackerRoll, armeParade) {
|
||||
const isCreature = this.defender.isCreature();
|
||||
const compName = isCreature ? armeParade.name : armeParade.data.competence;
|
||||
const compName = armeParade.data.competence;
|
||||
const competence = this.defender.getCompetence(compName);
|
||||
const armeAttaque = attackerRoll.arme;
|
||||
|
||||
@ -432,7 +381,7 @@ export class RdDCombat {
|
||||
carac: this.defender.data.data.carac
|
||||
};
|
||||
if (isCreature) {
|
||||
this._modifieRollDataCreature(rollData, competence);
|
||||
RdDItemCompetence.setRollDataCreature(rollData);
|
||||
}
|
||||
return rollData;
|
||||
}
|
||||
@ -444,11 +393,11 @@ export class RdDCombat {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_needResist(armeAttaque, armeParade) {
|
||||
// Manage weapon categories when parrying (cf. page 115 )
|
||||
let attCategory = RdDItemArme.getCategorieArme(armeAttaque);
|
||||
let defCategory = RdDItemArme.getCategorieArme(armeParade);
|
||||
// Epées parant une arme de bois (cf. page 115 ), une résistance est nécessaire
|
||||
let attCategory = RdDItemArme.getCategorieParade(armeAttaque);
|
||||
let defCategory = RdDItemArme.getCategorieParade(armeParade);
|
||||
|
||||
return (attCategory.match("epee") && (defCategory == "hache" || defCategory == "lance"));
|
||||
return attCategory.match(/epees-/) && defCategory.match(/(haches|lances)/);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -482,7 +431,7 @@ export class RdDCombat {
|
||||
console.log("RdDCombat._onParadeEchecTotal >>>", rollData);
|
||||
let chatOptions = {
|
||||
content: "<strong>Echec total à la parade!</strong> "
|
||||
+ await RdDRollTables.getMaladresse({ arme: rollData.arme && !rollData.arme.data.sansArme })
|
||||
+ await RdDRollTables.getMaladresse({ arme: rollData.arme && rollData.arme.data.categorie_parade != 'sans-armes' })
|
||||
}
|
||||
ChatUtility.chatWithRollMode(chatOptions, this.defender.name)
|
||||
}
|
||||
@ -550,7 +499,7 @@ export class RdDCombat {
|
||||
};
|
||||
|
||||
if (this.defender.isCreature()) {
|
||||
this._modifieRollDataCreature(rollData, competence);
|
||||
RdDItemCompetence.setRollDataCreature(rollData);
|
||||
}
|
||||
return rollData;
|
||||
}
|
||||
|
@ -197,8 +197,14 @@ export class RdDUtility {
|
||||
// HUD
|
||||
'systems/foundryvtt-reve-de-dragon/templates/hud-actor-init.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/hud-actor-attaque.html',
|
||||
// POST
|
||||
'systems/foundryvtt-reve-de-dragon/templates/post-item.html'
|
||||
// messages tchat
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-appelchance.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-attaque.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-competence.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-general.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-tache.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-sort.html',
|
||||
|
||||
];
|
||||
|
||||
return loadTemplates(templatePaths);
|
||||
|
@ -813,6 +813,10 @@ ul, li {
|
||||
background: rgba(220,220,210,0.75);
|
||||
border: 2px solid #545469;
|
||||
}
|
||||
.chat-message .chat-icon {
|
||||
border: 0;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#sidebar-tabs {
|
||||
flex: 0 0 32px;
|
||||
|
@ -23,24 +23,24 @@
|
||||
{{#if tactique}}
|
||||
<div>
|
||||
{{#if (eq tactique 'charge')}}
|
||||
<img style="float: left; border: 0;" src="icons/svg/thrust.svg" alt="charge" height="32" width="32" />
|
||||
C'est une charge, vos parades auront un
|
||||
-4 et vous ne pouvez pas esquiver!
|
||||
<img class="chat-icon" src="icons/svg/thrust.svg" alt="charge" height="32" width="32" />
|
||||
C'est une charge, vos parades auront un -4 et vous ne pouvez pas esquiver!
|
||||
{{ else if (eq tactique 'feinte')}}
|
||||
<img class="chat-icon" src="systems/foundryvtt-reve-de-dragon/icons/heures/hd06.svg" alt="feinte" height="32" width="32" />
|
||||
Votre feinte peut faire mouche!
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
<div>
|
||||
<span><strong>{{show.cible}}</strong> doit se défendre, ou encaisser à
|
||||
<span><strong>{{show.cible}}</strong> doit se défendre à <strong>{{diffLibre}}</strong>, ou encaisser à
|
||||
{{~#if (eq dmg.mortalite 'non-mortel')}}
|
||||
<span class="rdd-roll-norm">({{numberFormat dmg.total decimals=0 sign=true}})</span> (dommages non-mortel)
|
||||
{{else if (eq dmg.mortalite 'mortel')}}
|
||||
<span class="rdd-need-echec">{{numberFormat dmg.total decimals=0 sign=true}}</span>.
|
||||
<span class="rdd-roll-echec">{{numberFormat dmg.total decimals=0 sign=true}}</span>.
|
||||
{{else}}
|
||||
<span class="rdd-roll-etotal">{{numberFormat dmg.total decimals=0 sign=true}}</span> (entités de cauchemar)
|
||||
{{~/if}}.
|
||||
{{#if show.isRecul}}Si votre adversaire ne fait pas une esquive, il devra reculer sous le choc!{{/if}}
|
||||
{{#if show.isRecul}}Si votre adversaire n'esquive pas, il devra résister à l'impact ou reculer sous le choc!{{/if}}
|
||||
Le coup vise: {{dmg.loc.label}}.
|
||||
</span>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user