forked from public/foundryvtt-reve-de-dragon
Opposite tests
This commit is contained in:
@ -96,23 +96,33 @@ export class RdDActor extends Actor {
|
||||
|
||||
// Fight management !
|
||||
let defenseMsg;
|
||||
let encaisser = false;
|
||||
let specialStr = "<br>Points de taches : " + rollData.pointsDeTache; // Per default
|
||||
if ( rollData.arme ) { // In case of fight, replace the "tache" per dommages + localization. "tache" indicates if result is OK or not
|
||||
if ( rollData.pointsDeTache > 0 ) {
|
||||
let myroll = new Roll("2d10");
|
||||
myroll.roll();
|
||||
rollData.degats = parseInt(myroll.result) + parseInt(rollData.arme.data.dommages) + parseInt(this.data.data.attributs.plusdom.value);
|
||||
rollData.loc = RdDUtility.getLocalisation();
|
||||
for (let target of game.user.targets) {
|
||||
defenseMsg = RdDutility.buildDefenseChatCard(this, target, rollData );
|
||||
specialStr = "<br><strong>Cible</strong> : " + target.actor.data.name;
|
||||
if ( rollData.attackerRoll) {
|
||||
if ( rollData.pointsDeTache > 0 ) { // Réussite !
|
||||
specialStr = "<br><strong>Attaque parée/esquivée !</strong>";
|
||||
} else {
|
||||
specialStr = "<br><strong>Esquive/Parade échouée, encaissement !</strong>";
|
||||
encaisser = true;
|
||||
}
|
||||
} else {
|
||||
if ( rollData.pointsDeTache > 0 ) {
|
||||
let myroll = new Roll("2d10");
|
||||
myroll.roll();
|
||||
rollData.degats = parseInt(myroll.result) + parseInt(rollData.arme.data.dommages) + parseInt(this.data.data.attributs.plusdom.value);
|
||||
rollData.loc = RdDUtility.getLocalisation();
|
||||
for (let target of game.user.targets) {
|
||||
defenseMsg = RdDUtility.buildDefenseChatCard(this, target, rollData );
|
||||
specialStr = "<br><strong>Cible</strong> : " + target.actor.data.name;
|
||||
}
|
||||
specialStr += "<br>Dommages : " + rollData.degats + "<br>Localisation : " + rollData.loc.label;
|
||||
} else {
|
||||
specialStr = "<br>Echec ! Pas de dommages";
|
||||
}
|
||||
specialStr += "<br>Dommages : " + rollData.degats + "<br>Localisation : " + rollData.loc.label;
|
||||
} else {
|
||||
specialStr = "<br>Echec ! Pas de dommages";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Save it for fight
|
||||
await this.setFlag( "foundryvtt-reve-de-dragon", "rollData", undefined );
|
||||
await this.setFlag( "foundryvtt-reve-de-dragon", "rollData", rollData );
|
||||
@ -125,9 +135,14 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
ChatMessage.create( chatOptions );
|
||||
|
||||
// This an attack, generate the defense message
|
||||
if ( defenseMsg ) { // target hit !
|
||||
ChatMessage.create( defenseMsg );
|
||||
}
|
||||
}
|
||||
// Get damages!
|
||||
if ( encaisser ) {
|
||||
this.encaisserDommages( rollData );
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -265,7 +280,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollCompetence( compName, armeItem )
|
||||
async rollCompetence( compName, armeItem=undefined, attackerRoll=undefined )
|
||||
{
|
||||
console.log("!!!!!!", compName, armeItem);
|
||||
let compItem = RdDUtility.findCompetence( this.data.items, compName);
|
||||
@ -276,6 +291,7 @@ export class RdDActor extends Actor {
|
||||
"bonusmalusTable": CONFIG.RDD.bonusmalus,
|
||||
"etat": this.data.data.compteurs.etat.value,
|
||||
"bmValue": 0,
|
||||
"attackerRoll": attackerRoll,
|
||||
"finalLevel": 0
|
||||
}
|
||||
|
||||
@ -295,10 +311,10 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
encaisserDommages( attackerActor )
|
||||
{
|
||||
let attackerRoll = attackerActor.getFlag("foundryvtt-reve-de-dragon", "rollData");
|
||||
console.log("RollData!", attackerActor, attackerRoll);
|
||||
encaisserDommages( rollData )
|
||||
{
|
||||
let attackerRoll = rollData.attackerRoll;
|
||||
console.log("RollData from attacker!", rollData);
|
||||
let degatsReel = attackerRoll.degats - this.computeArmure(attackerRoll.loc);
|
||||
let result = RdDUtility.computeBlessuresSante(degatsReel);
|
||||
this.santeIncDec("vie", result.vie);
|
||||
@ -317,9 +333,11 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
parerAttaque( attackerActor, armeId )
|
||||
parerAttaque( attackerRoll, armeId )
|
||||
{
|
||||
console.log("Going to PARY !!!!!!!!!");
|
||||
let armeItem = this.getOwnedItem(armeId); // Item.data.data !
|
||||
console.log("Going to PARY !!!!!!!!!", armeItem, attackerRoll.bmValue);
|
||||
this.rollCompetence( armeItem.data.data.competence, armeItem.data, attackerRoll );
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
Reference in New Issue
Block a user