diff --git a/module/actor-sheet.js b/module/actor-sheet.js
index 59a151f3..2bb85c07 100644
--- a/module/actor-sheet.js
+++ b/module/actor-sheet.js
@@ -215,7 +215,7 @@ export class RdDActorSheet extends ActorSheet {
let reveValue = event.currentTarget.value;
let reve = duplicate( this.actor.data.data.reve.reve );
reve.value = reveValue;
- this.actor.update("data.reve.reve", reve );
+ this.actor.update( { "data.reve.reve": reve } );
} );
// On competence change
diff --git a/module/actor.js b/module/actor.js
index 84d0ceb2..98b02076 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -265,9 +265,17 @@ export class RdDActor extends Actor {
ChatMessage.create( chatOptions );
// This an attack, generate the defense message
- if ( defenseMsg ) { // target hit !
- ChatMessage.create( defenseMsg );
+ if ( defenseMsg ) {
+ if ( defenseMsg.toSocket) {
+ game.socket.emit("system.foundryvtt-reve-de-dragon", {
+ msg: "msg_defense",
+ data: defenseMsg
+ } );
+ } else {
+ ChatMessage.create( defenseMsg );
+ }
}
+
// Get damages!
if ( encaisser ) {
this.encaisserDommages( rollData.attackerRoll );
diff --git a/module/rdd-utility.js b/module/rdd-utility.js
index f91f222d..eadfd728 100644
--- a/module/rdd-utility.js
+++ b/module/rdd-utility.js
@@ -430,7 +430,10 @@ export class RdDUtility {
let defenseMsg = { title: "Défense en combat",
content: ""+myTarget.name+" doit se défendre :
" +
"Encaisser !",
- whisper: ChatMessage.getWhisperRecipients( myTarget.name ) };
+ whisper: ChatMessage.getWhisperRecipients( myTarget.name ),
+ defenderid: myTarget.data._id,
+ rollMode: true
+ };
if ( rollData.competence.data.categorie == "melee" ) { // Melee attack
let defenderArmes = [];
@@ -459,7 +462,9 @@ export class RdDUtility {
}
defenseMsg.content += "
Esquiver";
}
-
+
+ defenseMsg.toSocket = (!game.user.isGM) ? true : false;
+
return defenseMsg;
}
@@ -470,9 +475,17 @@ export class RdDUtility {
if ( sockmsg.msg == "msg_encaisser" ) {
if ( game.user.isGM ) {
console.log("Encaisser ici !!!");
- defenderActor = game.actors.get( sockmsg.data.defenderid );
+ let defenderActor = game.actors.get( sockmsg.data.defenderid );
defenderActor.encaisserDommages( sockmsg.data );
}
+ } else if (sockmsg.msg == "msg_defense" ) {
+ let defenderActor = game.actors.get( sockmsg.data.defenderid );
+ if ( (game.user.isGM && !defenderActor.isPC) || (defenderActor.isPC && game.user.character.id == defenderActor.id ) ) {
+ sockmsg.data.whisper = [ game.user ];
+ sockmsg.data.blind = true;
+ sockmsg.data.rollMode = "blindroll";
+ ChatMessage.create( sockmsg.data );
+ }
}
}