Sync combat

This commit is contained in:
sladecraven 2020-07-28 09:20:01 +02:00
parent 0efaac8d68
commit d215629c9b
3 changed files with 27 additions and 6 deletions

View File

@ -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

View File

@ -265,9 +265,17 @@ export class RdDActor extends Actor {
ChatMessage.create( chatOptions );
// This an attack, generate the defense message
if ( defenseMsg ) { // target hit !
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 );

View File

@ -430,7 +430,10 @@ export class RdDUtility {
let defenseMsg = { title: "Défense en combat",
content: "<strong>"+myTarget.name+"</strong> doit se défendre : <br><span class='chat-card-button-area'>" +
"<a class='chat-card-button' id='encaisser-button' data-attackerid='"+attacker.data._id + "' data-defenderid='" + myTarget.data._id + "'>Encaisser !</a></span>",
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 = [];
@ -460,6 +463,8 @@ export class RdDUtility {
defenseMsg.content += "<br><a class='chat-card-button' id='esquiver-button' data-attackerid='"+attacker.data._id + "' data-defenderid='" + myTarget.data._id + "'>Esquiver</a></span>";
}
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 );
}
}
}