Gestion du rollMode
affecte tous les jets d'un actor sur la table de résolution
This commit is contained in:
parent
136c7594d4
commit
8f9b1f1e76
@ -12,6 +12,7 @@ import { Misc } from "./misc.js";
|
||||
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
||||
import { RdDDice } from "./rdd-dice.js";
|
||||
import { RdDRollTables } from "./rdd-rolltables.js";
|
||||
import { ChatUtility } from "./chat-utility.js";
|
||||
|
||||
export class RdDActor extends Actor {
|
||||
|
||||
@ -232,11 +233,10 @@ export class RdDActor extends Actor {
|
||||
+ "<br>Difficultés <strong>libre : " + rollData.diffLibre + "</strong> / conditions : " + Misc.toSignedString(rollData.diffConditions) +" / état : " + rollData.etat
|
||||
+ RdDResolutionTable.explain(rolled)
|
||||
+ "<br><strong>" + quality + "</strong>"
|
||||
+ explications + xpmsg,
|
||||
user: game.user._id,
|
||||
title: "Résultat du test"
|
||||
+ explications + xpmsg
|
||||
}
|
||||
ChatMessage.create(chatOptions);
|
||||
|
||||
ChatUtility.chatWithRollMode(chatOptions, this.name)
|
||||
|
||||
// This an attack, generate the defense message
|
||||
if (defenseMsg) {
|
||||
|
70
module/chat-utility.js
Normal file
70
module/chat-utility.js
Normal file
@ -0,0 +1,70 @@
|
||||
|
||||
/**
|
||||
* Class providing helper methods to get the list of users, and
|
||||
*/
|
||||
export class ChatUtility {
|
||||
|
||||
static chatWithRollMode(chatOptions, name) {
|
||||
let rollMode = game.settings.get("core", "rollMode");
|
||||
chatOptions.user = game.user._id;
|
||||
|
||||
switch (rollMode) {
|
||||
case "blindroll": {//GM only
|
||||
if (!game.user.isGM) {
|
||||
ChatUtility.blindMessageToGM(chatOptions);
|
||||
|
||||
chatOptions = {
|
||||
user: game.user._id,
|
||||
whisper: [game.user._id],
|
||||
content: "Message envoyé en aveugle au Gardien"
|
||||
}
|
||||
}
|
||||
else {
|
||||
chatOptions.whisper = ChatUtility.getUsers(user => user.isGM);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "gmroll": //GM + rolling player
|
||||
chatOptions.user = game.user._id;
|
||||
chatOptions.whisper = ChatUtility.getWhisperRecipientsAndGMs(name);
|
||||
break;
|
||||
case "selfroll": // only the user
|
||||
chatOptions.user = game.user._id;
|
||||
chatOptions.whisper = [game.user._id];
|
||||
break;
|
||||
default:
|
||||
case "roll": //everybody
|
||||
chatOptions.whisper = undefined;
|
||||
break;
|
||||
}
|
||||
|
||||
console.log("roll message", chatOptions);
|
||||
ChatMessage.create(chatOptions);
|
||||
}
|
||||
|
||||
static getWhisperRecipientsAndGMs(name) {
|
||||
return ChatMessage.getWhisperRecipients(name)
|
||||
.concat(this.getUsers(user => user.isGM));
|
||||
}
|
||||
|
||||
static getUsers(filter) {
|
||||
return game.users.filter(filter).map(user => user.data._id);
|
||||
}
|
||||
|
||||
static blindMessageToGM(chatOptions) {
|
||||
let chatGM = duplicate(chatOptions);
|
||||
chatGM.whisper = ChatUtility.getUsers(user => user.isGM);
|
||||
chatGM.content = "Message aveugle de " + game.user.name + "<br>" + chatOptions.content;
|
||||
console.log("blindMessageToGM", chatGM);
|
||||
game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_gm_chat_message", data: chatGM });
|
||||
}
|
||||
|
||||
static handleGMChatMessage(data) {
|
||||
console.log("blindMessageToGM", data);
|
||||
if (game.user.isGM) { // message privé pour GM only
|
||||
data.user = game.user._id;
|
||||
ChatMessage.create(data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
import { ChatUtility } from "./chat-utility.js";
|
||||
|
||||
export class RdDDice {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -9,32 +11,30 @@ export class RdDDice {
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async show(roll, rollMode = "roll") {
|
||||
static async show(roll, rollMode = undefined) {
|
||||
if (roll.showDice || game.settings.get("foundryvtt-reve-de-dragon", "dice-so-nice") == true) {
|
||||
await this.showDiceSoNice(roll, rollMode);
|
||||
}
|
||||
return roll;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async showDiceSoNice(roll, rollMode = "roll") {
|
||||
static async showDiceSoNice(roll, rollMode = undefined) {
|
||||
if (game.modules.get("dice-so-nice") && game.modules.get("dice-so-nice").active) {
|
||||
let whisper = null;
|
||||
let blind = false;
|
||||
rollMode = rollMode == undefined ? game.settings.get("core", "rollMode") : rollMode;
|
||||
switch (rollMode) {
|
||||
case "blindroll": //GM only
|
||||
blind = true;
|
||||
case "gmroll": //GM + rolling player
|
||||
let gmList = game.users.filter(user => user.isGM);
|
||||
let gmIDList = [];
|
||||
gmList.forEach(gm => gmIDList.push(gm.data._id));
|
||||
whisper = gmIDList;
|
||||
whisper = ChatUtility.getUsersIds(user => user.isGM);
|
||||
break;
|
||||
case "roll": //everybody
|
||||
let userList = game.users.filter(user => user.active);
|
||||
let userIDList = [];
|
||||
userList.forEach(user => userIDList.push(user.data._id));
|
||||
whisper = userIDList;
|
||||
whisper = ChatUtility.getUsersIds(user => user.active);
|
||||
break;
|
||||
case "selfroll":
|
||||
whisper = [game.user._id];
|
||||
break;
|
||||
}
|
||||
await game.dice3d.showForRoll(roll, game.user, true, whisper, blind);
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
import { TMRUtility } from "./tmr-utility.js";
|
||||
import { RdDRollTables } from "./rdd-rolltables.js";
|
||||
import { ChatUtility } from "./chat-utility.js";
|
||||
|
||||
const level_category = {
|
||||
"generale": "-4",
|
||||
@ -601,27 +602,38 @@ export class RdDUtility {
|
||||
static performSocketMesssage( sockmsg )
|
||||
{
|
||||
console.log(">>>>> MSG RECV", sockmsg);
|
||||
if ( sockmsg.msg == "msg_encaisser" ) {
|
||||
if ( game.user.isGM ) { // Seul le GM effectue l'encaissement sur la fiche
|
||||
let rollData = game.system.rdd.rollDataHandler[sockmsg.data.attackerid]; // Retrieve the rolldata from the store
|
||||
let defenderActor = game.actors.get( sockmsg.data.defenderid );
|
||||
defenderActor.encaisserDommages( rollData );
|
||||
}
|
||||
} else if (sockmsg.msg == "msg_defense" ) {
|
||||
let defenderActor = game.actors.get( sockmsg.data.defenderid );
|
||||
if ( defenderActor ) {
|
||||
if ( (game.user.isGM && !defenderActor.hasPlayerOwner) || (defenderActor.hasPlayerOwner && (game.user.character.id == defenderActor.id) ) ) {
|
||||
console.log("User is pushing message...", game.user.name);
|
||||
game.system.rdd.rollDataHandler[sockmsg.data.attackerid] = duplicate(sockmsg.data.rollData);
|
||||
sockmsg.data.whisper = [ game.user ];
|
||||
sockmsg.data.blind = true;
|
||||
sockmsg.data.rollMode = "blindroll";
|
||||
ChatMessage.create( sockmsg.data );
|
||||
}
|
||||
switch(sockmsg.msg) {
|
||||
case "msg_encaisser":
|
||||
return RdDUtility._handleMsgEncaisser(sockmsg.data);
|
||||
case "msg_defense" :
|
||||
return RdDUtility._handleMsgDefense(sockmsg.data);
|
||||
case "msg_gm_chat_message":
|
||||
return ChatUtility.handleGMChatMessage(sockmsg.data);
|
||||
}
|
||||
}
|
||||
|
||||
static _handleMsgDefense(data) {
|
||||
let defenderActor = game.actors.get(data.defenderid);
|
||||
if (defenderActor) {
|
||||
if ((game.user.isGM && !defenderActor.hasPlayerOwner) || (defenderActor.hasPlayerOwner && (game.user.character.id == defenderActor.id))) {
|
||||
console.log("User is pushing message...", game.user.name);
|
||||
game.system.rdd.rollDataHandler[data.attackerid] = duplicate(data.rollData);
|
||||
data.whisper = [game.user];
|
||||
data.blind = true;
|
||||
data.rollMode = "blindroll";
|
||||
ChatMessage.create(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static _handleMsgEncaisser(data) {
|
||||
if (game.user.isGM) { // Seul le GM effectue l'encaissement sur la fiche
|
||||
let rollData = game.system.rdd.rollDataHandler[data.attackerid]; // Retrieve the rolldata from the store
|
||||
let defenderActor = game.actors.get(data.defenderid);
|
||||
defenderActor.encaisserDommages(rollData);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async chatListeners( html )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user