Gestion initiative améliorée
This commit is contained in:
commit
40e2d665df
@ -12,6 +12,7 @@ import { Misc } from "./misc.js";
|
|||||||
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
||||||
import { RdDDice } from "./rdd-dice.js";
|
import { RdDDice } from "./rdd-dice.js";
|
||||||
import { RdDRollTables } from "./rdd-rolltables.js";
|
import { RdDRollTables } from "./rdd-rolltables.js";
|
||||||
|
import { ChatUtility } from "./chat-utility.js";
|
||||||
|
|
||||||
export class RdDActor extends Actor {
|
export class RdDActor extends Actor {
|
||||||
|
|
||||||
@ -197,7 +198,7 @@ export class RdDActor extends Actor {
|
|||||||
if (rolled.isSuccess) {
|
if (rolled.isSuccess) {
|
||||||
// Message spécial pour la rapidité, qui reste difficile à gérer automatiquement
|
// Message spécial pour la rapidité, qui reste difficile à gérer automatiquement
|
||||||
if ( rollData.particuliereAttaque == 'rapidite') {
|
if ( rollData.particuliereAttaque == 'rapidite') {
|
||||||
ChatMessage.create( { contet: "Vous avez attaqué en Rapidité. Ce cas n'est pas géré autmatiquement, donc suivez les directives de votre MJ pour gérer ce cas.",
|
ChatMessage.create( { content: "Vous avez attaqué en Rapidité. Ce cas n'est pas géré autmatiquement, donc suivez les directives de votre MJ pour gérer ce cas.",
|
||||||
whisper: ChatMessage.getWhisperRecipients( this.name ) } );
|
whisper: ChatMessage.getWhisperRecipients( this.name ) } );
|
||||||
}
|
}
|
||||||
rollData.domArmePlusDom = this._calculBonusDommages(rollData.selectedCarac, rollData.arme, rollData.particuliereAttaque == 'force' );
|
rollData.domArmePlusDom = this._calculBonusDommages(rollData.selectedCarac, rollData.arme, rollData.particuliereAttaque == 'force' );
|
||||||
@ -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
|
+ "<br>Difficultés <strong>libre : " + rollData.diffLibre + "</strong> / conditions : " + Misc.toSignedString(rollData.diffConditions) +" / état : " + rollData.etat
|
||||||
+ RdDResolutionTable.explain(rolled)
|
+ RdDResolutionTable.explain(rolled)
|
||||||
+ "<br><strong>" + quality + "</strong>"
|
+ "<br><strong>" + quality + "</strong>"
|
||||||
+ explications + xpmsg,
|
+ explications + xpmsg
|
||||||
user: game.user._id,
|
|
||||||
title: "Résultat du test"
|
|
||||||
}
|
}
|
||||||
ChatMessage.create(chatOptions);
|
|
||||||
|
ChatUtility.chatWithRollMode(chatOptions, this.name)
|
||||||
|
|
||||||
// This an attack, generate the defense message
|
// This an attack, generate the defense message
|
||||||
if (defenseMsg) {
|
if (defenseMsg) {
|
||||||
@ -322,7 +322,7 @@ export class RdDActor extends Actor {
|
|||||||
await this.update({ "data.reve.reve": myReve });
|
await this.update({ "data.reve.reve": myReve });
|
||||||
|
|
||||||
if (myReve.value == 0) { // 0 points de reve
|
if (myReve.value == 0) { // 0 points de reve
|
||||||
ChatMessage.create({ title: "Zero Points de Reve !", content: this.name + " est réduit à 0 Points de Rêve, et tombe endormi !" });
|
ChatMessage.create({ content: this.name + " est réduit à 0 Points de Rêve, et tombe endormi !" });
|
||||||
closeTMR = true;
|
closeTMR = true;
|
||||||
}
|
}
|
||||||
if (closeTMR) {
|
if (closeTMR) {
|
||||||
@ -333,7 +333,10 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async dormir(heures=1) {
|
async dormir(heures=1) {
|
||||||
let message = { title : "Récupération", content :"Vous dormez " + heures + " heure" + (heures > 1 ? "s": "") };
|
let message = {
|
||||||
|
whisper: ChatUtility.getWhisperRecipientsAndGMs( this.name ),
|
||||||
|
content : "Vous dormez " + heures + " heure" + (heures > 1 ? "s": "")
|
||||||
|
};
|
||||||
await this.recupereEndurance(message);
|
await this.recupereEndurance(message);
|
||||||
for (let i=0; i<heures; i++) {
|
for (let i=0; i<heures; i++) {
|
||||||
await this.recupererFatigue(message);
|
await this.recupererFatigue(message);
|
||||||
@ -389,6 +392,7 @@ export class RdDActor extends Actor {
|
|||||||
};
|
};
|
||||||
return cumul;
|
return cumul;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async recuperationReve(message) {
|
async recuperationReve(message) {
|
||||||
const seuil = this.data.data.reve.seuil.value;
|
const seuil = this.data.data.reve.seuil.value;
|
||||||
@ -397,7 +401,7 @@ export class RdDActor extends Actor {
|
|||||||
message.content += "<br>Vous avez suffisament rêvé (seuil " + seuil + ", rêve actuel "+reve+")";
|
message.content += "<br>Vous avez suffisament rêvé (seuil " + seuil + ", rêve actuel "+reve+")";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let deRecuperation = RdDDice.deDraconique();
|
let deRecuperation = await RdDDice.deDraconique();
|
||||||
console.log("recuperationReve", deRecuperation);
|
console.log("recuperationReve", deRecuperation);
|
||||||
if (deRecuperation>=7)
|
if (deRecuperation>=7)
|
||||||
{
|
{
|
||||||
@ -670,7 +674,6 @@ export class RdDActor extends Actor {
|
|||||||
this.createOwnedItem(queue);
|
this.createOwnedItem(queue);
|
||||||
|
|
||||||
ChatMessage.create({
|
ChatMessage.create({
|
||||||
title: "Queue de Dragon",
|
|
||||||
content: this.name + " subit un Queue de Dragon : " + queue.name
|
content: this.name + " subit un Queue de Dragon : " + queue.name
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -910,7 +913,7 @@ export class RdDActor extends Actor {
|
|||||||
compteurs.stress.value = Math.max(compteurs.stress.value - convertion - 1, 0);
|
compteurs.stress.value = Math.max(compteurs.stress.value - convertion - 1, 0);
|
||||||
|
|
||||||
ChatMessage.create({
|
ChatMessage.create({
|
||||||
title: "Jet de Stress", content: "Vous avez transformé " + convertion + " points de Stress en Expérience" + stressRoll.comment,
|
content: "Vous avez transformé " + convertion + " points de Stress en Expérience" + stressRoll.comment,
|
||||||
whisper: ChatMessage.getWhisperRecipients(game.user.name)
|
whisper: ChatMessage.getWhisperRecipients(game.user.name)
|
||||||
});
|
});
|
||||||
await this.update({ "data.compteurs": compteurs });
|
await this.update({ "data.compteurs": compteurs });
|
||||||
@ -1009,8 +1012,9 @@ export class RdDActor extends Actor {
|
|||||||
{
|
{
|
||||||
let minReveValue = (isRapide) ? 3 : 2;
|
let minReveValue = (isRapide) ? 3 : 2;
|
||||||
if (this.getReveActuel() < minReveValue ) {
|
if (this.getReveActuel() < minReveValue ) {
|
||||||
ChatMessage.create( { title: "Montée impossible !", content: "Vous n'avez plus assez de Points de Reve pour monter dans les Terres Médianes",
|
ChatMessage.create( {
|
||||||
whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
|
content: "Vous n'avez plus assez de Points de Reve pour monter dans les Terres Médianes",
|
||||||
|
whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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 {
|
export class RdDDice {
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -9,7 +11,7 @@ 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) {
|
if (roll.showDice || game.settings.get("foundryvtt-reve-de-dragon", "dice-so-nice") == true) {
|
||||||
await this.showDiceSoNice(roll, rollMode);
|
await this.showDiceSoNice(roll, rollMode);
|
||||||
}
|
}
|
||||||
@ -17,24 +19,22 @@ export class RdDDice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
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) {
|
if (game.modules.get("dice-so-nice") && game.modules.get("dice-so-nice").active) {
|
||||||
let whisper = null;
|
let whisper = null;
|
||||||
let blind = false;
|
let blind = false;
|
||||||
|
rollMode = rollMode == undefined ? game.settings.get("core", "rollMode") : rollMode;
|
||||||
switch (rollMode) {
|
switch (rollMode) {
|
||||||
case "blindroll": //GM only
|
case "blindroll": //GM only
|
||||||
blind = true;
|
blind = true;
|
||||||
case "gmroll": //GM + rolling player
|
case "gmroll": //GM + rolling player
|
||||||
let gmList = game.users.filter(user => user.isGM);
|
whisper = ChatUtility.getUsersIds(user => user.isGM);
|
||||||
let gmIDList = [];
|
|
||||||
gmList.forEach(gm => gmIDList.push(gm.data._id));
|
|
||||||
whisper = gmIDList;
|
|
||||||
break;
|
break;
|
||||||
case "roll": //everybody
|
case "roll": //everybody
|
||||||
let userList = game.users.filter(user => user.active);
|
whisper = ChatUtility.getUsersIds(user => user.active);
|
||||||
let userIDList = [];
|
break;
|
||||||
userList.forEach(user => userIDList.push(user.data._id));
|
case "selfroll":
|
||||||
whisper = userIDList;
|
whisper = [game.user._id];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
await game.dice3d.showForRoll(roll, game.user, true, whisper, blind);
|
await game.dice3d.showForRoll(roll, game.user, true, whisper, blind);
|
||||||
|
@ -142,7 +142,6 @@ Hooks.once("init", async function() {
|
|||||||
carac_array : RdDUtility.getCaracArray(),
|
carac_array : RdDUtility.getCaracArray(),
|
||||||
ajustementsConditions : RdDUtility.getAjustementsConditions(),
|
ajustementsConditions : RdDUtility.getAjustementsConditions(),
|
||||||
difficultesLibres : RdDUtility.getDifficultesLibres()
|
difficultesLibres : RdDUtility.getDifficultesLibres()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register sheet application classes
|
// Register sheet application classes
|
||||||
@ -178,17 +177,12 @@ Hooks.once("renderApplication", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function messageDeBienvenue(){
|
function messageDeBienvenue(){
|
||||||
game.messages.filter(it => {
|
game.messages
|
||||||
console.log(it);
|
.filter(it => it.user._id == game.user._id && it.data.content.match(/^Bienvenu(e)? dans le Rêve des Dragons/))
|
||||||
return it.data.content.match(/^Bienvenu(e)? dans le Rêve des Dragons/);
|
.forEach(it => it.delete());
|
||||||
})
|
|
||||||
.forEach(it => {
|
|
||||||
console.log("deleting",it);
|
|
||||||
it.delete();
|
|
||||||
});
|
|
||||||
ChatMessage.create( {
|
ChatMessage.create( {
|
||||||
whisper: [game.user],
|
user: game.user._id,
|
||||||
title: "Bienvenue dans le Rêve !",
|
whisper: [game.user._id],
|
||||||
content : "Bienvenue dans le Rêve des Dragons !<br> " +
|
content : "Bienvenue dans le Rêve des Dragons !<br> " +
|
||||||
"Vous trouverez quelques informations pour démarrer dans ce document : @Compendium[foundryvtt-reve-de-dragon.rappel-des-regles.7uGrUHGdPu0EmIu2]{Documentation MJ/Joueurs}" }
|
"Vous trouverez quelques informations pour démarrer dans ce document : @Compendium[foundryvtt-reve-de-dragon.rappel-des-regles.7uGrUHGdPu0EmIu2]{Documentation MJ/Joueurs}" }
|
||||||
);
|
);
|
||||||
|
@ -224,12 +224,12 @@ export class RdDTMRDialog extends Dialog {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
_tellToUser(message) {
|
_tellToUser(message) {
|
||||||
ChatMessage.create({ title: "TMR", content: message, user: game.user._id });
|
ChatMessage.create({ content: message, user: game.user._id });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
_tellToGM(message) {
|
_tellToGM(message) {
|
||||||
ChatMessage.create({ title: "TMR", content: message, user: game.user._id, whisper: ChatMessage.getWhisperRecipients("GM") });
|
ChatMessage.create({ content: message, user: game.user._id, whisper: ChatMessage.getWhisperRecipients("GM") });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { TMRUtility } from "./tmr-utility.js";
|
import { TMRUtility } from "./tmr-utility.js";
|
||||||
import { RdDRollTables } from "./rdd-rolltables.js";
|
import { RdDRollTables } from "./rdd-rolltables.js";
|
||||||
|
import { ChatUtility } from "./chat-utility.js";
|
||||||
|
|
||||||
const level_category = {
|
const level_category = {
|
||||||
"generale": "-4",
|
"generale": "-4",
|
||||||
@ -626,23 +627,26 @@ export class RdDUtility {
|
|||||||
static performSocketMesssage( sockmsg )
|
static performSocketMesssage( sockmsg )
|
||||||
{
|
{
|
||||||
console.log(">>>>> MSG RECV", sockmsg);
|
console.log(">>>>> MSG RECV", sockmsg);
|
||||||
if ( sockmsg.msg == "msg_encaisser" ) {
|
switch(sockmsg.msg) {
|
||||||
if ( game.user.isGM ) { // Seul le GM effectue l'encaissement sur la fiche
|
case "msg_encaisser":
|
||||||
let rollData = game.system.rdd.rollDataHandler[sockmsg.data.attackerid]; // Retrieve the rolldata from the store
|
return RdDUtility._handleMsgEncaisser(sockmsg.data);
|
||||||
let defenderActor = game.actors.get( sockmsg.data.defenderid );
|
case "msg_defense" :
|
||||||
defenderActor.encaisserDommages( rollData );
|
return RdDUtility._handleMsgDefense(sockmsg.data);
|
||||||
}
|
case "msg_gm_chat_message":
|
||||||
} else if (sockmsg.msg == "msg_defense" ) {
|
return ChatUtility.handleGMChatMessage(sockmsg.data);
|
||||||
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);
|
static _handleMsgDefense(data) {
|
||||||
game.system.rdd.rollDataHandler[sockmsg.data.attackerid] = duplicate(sockmsg.data.rollData);
|
let defenderActor = game.actors.get(data.defenderid);
|
||||||
sockmsg.data.whisper = [ game.user ];
|
if (defenderActor) {
|
||||||
sockmsg.data.blind = true;
|
if ((game.user.isGM && !defenderActor.hasPlayerOwner) || (defenderActor.hasPlayerOwner && (game.user.character.id == defenderActor.id))) {
|
||||||
sockmsg.data.rollMode = "blindroll";
|
console.log("User is pushing message...", game.user.name);
|
||||||
ChatMessage.create( sockmsg.data );
|
game.system.rdd.rollDataHandler[data.attackerid] = duplicate(data.rollData);
|
||||||
}
|
data.whisper = [game.user];
|
||||||
|
data.blind = true;
|
||||||
|
data.rollMode = "blindroll";
|
||||||
|
ChatMessage.create(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -702,7 +706,16 @@ export class RdDUtility {
|
|||||||
//WFRP_Utility.displayStatus(target.attr("data-token-id"));
|
//WFRP_Utility.displayStatus(target.attr("data-token-id"));
|
||||||
//$(`#sidebar-tabs`).find(`.item[data-tab="chat"]`).click();
|
//$(`#sidebar-tabs`).find(`.item[data-tab="chat"]`).click();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
Loading…
Reference in New Issue
Block a user