Merge branch 'master-fixes' into 'master'

Plein de petits fixes

See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!167
This commit is contained in:
Leratier Bretonnien 2021-03-14 19:20:52 +00:00
commit b5e2f892a5
10 changed files with 317 additions and 370 deletions

View File

@ -2788,19 +2788,11 @@ export class RdDActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async decItemUse( itemId ) { async incDecItemUse( itemId, inc = 1 ) {
let itemUse = duplicate(this.getFlag('foundryvtt-reve-de-dragon', 'itemUse') ?? {}); let itemUse = duplicate(this.getFlag('foundryvtt-reve-de-dragon', 'itemUse') ?? {});
itemUse[itemId] = (itemUse[itemId] ?? 0) - 1; itemUse[itemId] = (itemUse[itemId] ?? 0) + inc;
await this.setFlag( 'foundryvtt-reve-de-dragon', 'itemUse', itemUse); await this.setFlag( 'foundryvtt-reve-de-dragon', 'itemUse', itemUse);
console.log("ITEM USE DEC", itemUse); console.log("ITEM USE INC", inc, itemUse);
}
/* -------------------------------------------- */
async incItemUse( itemId ) {
let itemUse = duplicate(this.getFlag('foundryvtt-reve-de-dragon', 'itemUse') ?? {});
itemUse[itemId] = (itemUse[itemId] ?? 0) + 1;
await this.setFlag( 'foundryvtt-reve-de-dragon', 'itemUse', itemUse);
console.log("ITEM USE INC", itemUse);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -17,12 +17,11 @@ export class ChatUtility {
const toDelete = game.messages.filter(it => it.data.content.includes(part)); const toDelete = game.messages.filter(it => it.data.content.includes(part));
toDelete.forEach(it => it.delete()); toDelete.forEach(it => it.delete());
} }
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static removeChatMessageContaining(part) { static removeChatMessageContaining(part) {
const gmId = game.user.isGM ? game.user._id : game.users.entities.find(u => u.isGM)?.id; const gmId = game.user.isGM ? game.user._id : game.users.entities.find(u => u.isGM && u.active)?.id;
if (!gmId || game.user.isGM) { if (!gmId || game.user.isGM) {
ChatUtility.onRemoveMessages(part, game.user._id); ChatUtility.onRemoveMessages(part, game.user._id);

View File

@ -145,7 +145,7 @@ export class RdDItemArme extends Item {
} }
static isArmeUtilisable(item) { static isArmeUtilisable(item) {
return item.type == 'arme' && (item.data.resistance > 0 || item.data.portee_courte>0); return item.type == 'arme' && item.data.equipe && (item.data.resistance > 0 || item.data.portee_courte>0);
} }
static mainsNues(actorData={}) { static mainsNues(actorData={}) {

View File

@ -8,62 +8,64 @@ import { Grammar } from "./grammar.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
const dossierIconesHeures = 'systems/foundryvtt-reve-de-dragon/icons/heures/' const dossierIconesHeures = 'systems/foundryvtt-reve-de-dragon/icons/heures/'
const heuresList = [ "vaisseau", "sirene", "faucon", "couronne", "dragon", "epees", "lyre", "serpent", "poissonacrobate", "araignee", "roseau", "chateaudormant" ]; const heuresList = ["vaisseau", "sirene", "faucon", "couronne", "dragon", "epees", "lyre", "serpent", "poissonacrobate", "araignee", "roseau", "chateaudormant"];
const heuresDef = { "vaisseau": { label: "Vaisseau", lettreFont: 'v', saison: "printemps", heure: 0, icon: 'hd01.svg' }, const heuresDef = {
"sirene": { label: "Sirène", lettreFont: 'S', saison: "printemps", heure: 1, icon: 'hd02.svg' }, "vaisseau": { label: "Vaisseau", lettreFont: 'v', saison: "printemps", heure: 0, icon: 'hd01.svg' },
"faucon": { label: "Faucon", lettreFont: 'f', saison: "printemps", heure: 2, icon: 'hd03.svg' }, "sirene": { label: "Sirène", lettreFont: 'S', saison: "printemps", heure: 1, icon: 'hd02.svg' },
"couronne": { label: "Couronne", lettreFont: 'C', saison: "ete", heure: 3, icon: 'hd04.svg' }, "faucon": { label: "Faucon", lettreFont: 'f', saison: "printemps", heure: 2, icon: 'hd03.svg' },
"dragon": { label: "Dragon", lettreFont: 'd', saison: "ete", heure: 4, icon: 'hd05.svg' }, "couronne": { label: "Couronne", lettreFont: 'C', saison: "ete", heure: 3, icon: 'hd04.svg' },
"epees": { label: "Epées", lettreFont: 'e', saison: "ete", heure: 5, icon: 'hd06.svg' }, "dragon": { label: "Dragon", lettreFont: 'd', saison: "ete", heure: 4, icon: 'hd05.svg' },
"lyre": { label: "Lyre", lettreFont: 'l', saison: "automne", heure: 6, icon: 'hd07.svg' }, "epees": { label: "Epées", lettreFont: 'e', saison: "ete", heure: 5, icon: 'hd06.svg' },
"serpent": { label: "Serpent", lettreFont: 's', saison: "automne", heure: 7, icon: 'hd08.svg' }, "lyre": { label: "Lyre", lettreFont: 'l', saison: "automne", heure: 6, icon: 'hd07.svg' },
"poissonacrobate": { label: "Poisson Acrobate", lettreFont: 'p', saison: "automne", heure: 8, icon: 'hd09.svg' }, "serpent": { label: "Serpent", lettreFont: 's', saison: "automne", heure: 7, icon: 'hd08.svg' },
"araignee": { label: "Araignée", lettreFont: 'a', saison: "hiver", heure: 9, icon: 'hd10.svg' }, "poissonacrobate": { label: "Poisson Acrobate", lettreFont: 'p', saison: "automne", heure: 8, icon: 'hd09.svg' },
"roseau": { label: "Roseau", lettreFont: 'r', saison: "hiver", heure: 10, icon: 'hd11.svg' }, "araignee": { label: "Araignée", lettreFont: 'a', saison: "hiver", heure: 9, icon: 'hd10.svg' },
"chateaudormant": { label: "Château Dormant", lettreFont: 'c', saison: "hiver", heure: 11, icon: 'hd12.svg' } "roseau": { label: "Roseau", lettreFont: 'r', saison: "hiver", heure: 10, icon: 'hd11.svg' },
}; "chateaudormant": { label: "Château Dormant", lettreFont: 'c', saison: "hiver", heure: 11, icon: 'hd12.svg' }
const saisonsDef = { "printemps": { label: "Printemps"}, };
"ete": { label: "Eté"}, const saisonsDef = {
"automne": { label: "Automne"}, "printemps": { label: "Printemps" },
"hiver": { label: "Hiver"} "ete": { label: "Eté" },
}; "automne": { label: "Automne" },
"hiver": { label: "Hiver" }
};
const RDD_JOUR_PAR_MOIS = 28; const RDD_JOUR_PAR_MOIS = 28;
const MAX_NOMBRE_ASTRAL = 12; const MAX_NOMBRE_ASTRAL = 12;
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDCalendrier extends Application { export class RdDCalendrier extends Application {
/* -------------------------------------------- */ /* -------------------------------------------- */
async initCalendrier() { async initCalendrier() {
// Calendrier // Calendrier
this.calendrier = duplicate(game.settings.get("foundryvtt-reve-de-dragon", "calendrier")); this.calendrier = duplicate(game.settings.get("foundryvtt-reve-de-dragon", "calendrier"));
console.log("CALENDRIER", this.calendrier); console.log("CALENDRIER", this.calendrier);
if ( this.calendrier == undefined || this.calendrier.moisRdD == undefined) { if (this.calendrier == undefined || this.calendrier.moisRdD == undefined) {
this.calendrier.heureRdD = 0; // Index dans heuresList this.calendrier.heureRdD = 0; // Index dans heuresList
this.calendrier.minutesRelative = 0; this.calendrier.minutesRelative = 0;
this.calendrier.moisRdD = 0; // Index dans heuresList this.calendrier.moisRdD = 0; // Index dans heuresList
this.calendrier.jour = 0; this.calendrier.jour = 0;
if ( game.user.isGM) { // Uniquement si GM if (game.user.isGM) { // Uniquement si GM
game.settings.set("foundryvtt-reve-de-dragon", "calendrier", this.calendrier ); game.settings.set("foundryvtt-reve-de-dragon", "calendrier", this.calendrier);
} }
} }
// position // position
this.calendrierPos = duplicate(game.settings.get("foundryvtt-reve-de-dragon", "calendrier-pos")); this.calendrierPos = duplicate(game.settings.get("foundryvtt-reve-de-dragon", "calendrier-pos"));
if ( this.calendrierPos == undefined || this.calendrierPos.top == undefined) { if (this.calendrierPos == undefined || this.calendrierPos.top == undefined) {
this.calendrierPos.top = 200; this.calendrierPos.top = 200;
this.calendrierPos.left = 200; this.calendrierPos.left = 200;
if ( game.user.isGM) { // Uniquement si GM if (game.user.isGM) { // Uniquement si GM
game.settings.set("foundryvtt-reve-de-dragon", "calendrier-pos", this.calendrierPos ); game.settings.set("foundryvtt-reve-de-dragon", "calendrier-pos", this.calendrierPos);
} }
} }
// nombre astral // nombre astral
if ( game.user.isGM) { if (game.user.isGM) {
this.listeNombreAstral = this._loadListNombreAstral(); this.listeNombreAstral = this._loadListNombreAstral();
this.rebuildListeNombreAstral(); // Ensure always up-to-date this.rebuildListeNombreAstral(); // Ensure always up-to-date
} }
console.log(this.calendrier, this.calendrierPos, this.listeNombreAstral); console.log(this.calendrier, this.calendrierPos, this.listeNombreAstral);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_loadListNombreAstral() { _loadListNombreAstral() {
return Object.values(game.settings.get("foundryvtt-reve-de-dragon", "liste-nombre-astral")); return Object.values(game.settings.get("foundryvtt-reve-de-dragon", "liste-nombre-astral"));
@ -79,11 +81,11 @@ export class RdDCalendrier extends Application {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
getDateFromIndex( index = undefined ) { getDateFromIndex(index = undefined) {
if ( !index) index = this.getCurrentDayIndex(); if (!index) index = this.getCurrentDayIndex();
let month = Math.floor(index / 28); let month = Math.floor(index / 28);
let day = (index - (month*28)) + 1; let day = (index - (month * 28)) + 1;
return day+" "+heuresList[month]; return day + " " + heuresList[month];
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -92,25 +94,25 @@ export class RdDCalendrier extends Application {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
getCurrentDayIndex( ) { getCurrentDayIndex() {
return (this.calendrier.moisRdD * 28) + this.calendrier.jour; return (this.calendrier.moisRdD * 28) + this.calendrier.jour;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
getJoursSuivants( num) { getJoursSuivants(num) {
let jours = []; let jours = [];
let index = this.getCurrentDayIndex(); let index = this.getCurrentDayIndex();
for (let i=0; i<num; i++) { for (let i = 0; i < num; i++) {
jours[i] = { label: this.getDateFromIndex(index), index: index }; jours[i] = { label: this.getDateFromIndex(index), index: index };
index += 1; index += 1;
} }
return jours; return jours;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
ajouterNombreAstral(index) { ajouterNombreAstral(index) {
return { return {
nombreAstral: new Roll("1d12").roll().total, nombreAstral: new Roll("1d12").roll().total,
valeursFausses: [], valeursFausses: [],
index: index index: index
} }
@ -123,12 +125,12 @@ export class RdDCalendrier extends Application {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
getNombreAstral( indexDate ) { getNombreAstral(indexDate) {
const liste = this.listeNombreAstral ?? this._loadListNombreAstral(); const liste = this.listeNombreAstral ?? this._loadListNombreAstral();
let astralData = liste.find( (nombreAstral, i) => nombreAstral.index == indexDate ); let astralData = liste.find((nombreAstral, i) => nombreAstral.index == indexDate);
if (! astralData?.nombreAstral ) { if (!astralData?.nombreAstral) {
this.rebuildListeNombreAstral(); this.rebuildListeNombreAstral();
astralData = liste.find( (nombreAstral, i) => nombreAstral.index == indexDate ); astralData = liste.find((nombreAstral, i) => nombreAstral.index == indexDate);
} }
return astralData?.nombreAstral ?? "N/A"; return astralData?.nombreAstral ?? "N/A";
} }
@ -137,7 +139,7 @@ export class RdDCalendrier extends Application {
rebuildListeNombreAstral() { rebuildListeNombreAstral() {
let jourCourant = this.getCurrentDayIndex(); let jourCourant = this.getCurrentDayIndex();
let jourFin = jourCourant + 12; let jourFin = jourCourant + 12;
let newList = [0,1,2,3,4,5,6,7,8,9,10,11].map( i => this.ajouterNombreAstral(jourCourant + i)); let newList = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].map(i => this.ajouterNombreAstral(jourCourant + i));
if (this.listeNombreAstral) { if (this.listeNombreAstral) {
for (const na of this.listeNombreAstral) { for (const na of this.listeNombreAstral) {
if (na && na.index >= jourCourant && na.index < jourFin) { if (na && na.index >= jourCourant && na.index < jourFin) {
@ -145,34 +147,47 @@ export class RdDCalendrier extends Application {
} }
} }
} }
game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral ); game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral);
}
/* -------------------------------------------- */
onCalendarButton(ev) {
ev.preventDefault();
const calendarAvance = ev.currentTarget.attributes['data-calendar-avance'];
const calendarSet = ev.currentTarget.attributes['data-calendar-set'];
if (calendarAvance) {
this.incrementTime(Number(calendarAvance.value));
}
else if (calendarSet) {
this.positionnerHeure(Number(calendarSet.value));
}
this.updateDisplay();
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
incrementTime(minute = 0) { incrementTime(minutes = 0) {
this.calendrier.minutesRelative += minute; this.calendrier.minutesRelative += minutes;
if (this.calendrier.minutesRelative >= 120 ) { if (this.calendrier.minutesRelative >= 120) {
this.calendrier.minutesRelative -= 120; this.calendrier.minutesRelative -= 120;
this.calendrier.heureRdD += 1; this.calendrier.heureRdD += 1;
} }
if ( this.calendrier.heureRdD > 11 ) { if (this.calendrier.heureRdD > 11) {
this.calendrier.heureRdD -= 12; this.calendrier.heureRdD -= 12;
this.incrementerJour(); this.incrementerJour();
} }
game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier) ); game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier));
// Notification aux joueurs // Notification aux joueurs
game.socket.emit("system.foundryvtt-reve-de-dragon", { game.socket.emit("system.foundryvtt-reve-de-dragon", {
msg: "msg_sync_time", msg: "msg_sync_time",
data: duplicate(this.calendrier) data: duplicate(this.calendrier)
} ); });
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
incrementerJour( ) { incrementerJour() {
this.calendrier.jour += 1; this.calendrier.jour += 1;
if ( this.calendrier.jour >= RDD_JOUR_PAR_MOIS) { if (this.calendrier.jour >= RDD_JOUR_PAR_MOIS) {
this.calendrier.jour -= RDD_JOUR_PAR_MOIS; this.calendrier.jour -= RDD_JOUR_PAR_MOIS;
if ( this.calendrier.jour <= 0) if (this.calendrier.jour <= 0)
this.calendrier.jour = 0; this.calendrier.jour = 0;
this.calendrier.moisRdD += 1; this.calendrier.moisRdD += 1;
// Reconstruire les nombres astraux // Reconstruire les nombres astraux
@ -181,97 +196,97 @@ export class RdDCalendrier extends Application {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
syncPlayerTime( calendrier ) { syncPlayerTime(calendrier) {
this.calendrier = duplicate(calendrier); // Local copy update this.calendrier = duplicate(calendrier); // Local copy update
this.updateDisplay(); // Then update this.updateDisplay(); // Then update
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
positionnerHeure( indexHeure ) { positionnerHeure(indexHeure) {
if ( indexHeure <= this.calendrier.heureRdD ) if (indexHeure <= this.calendrier.heureRdD)
this.incrementerJour(); this.incrementerJour();
this.calendrier.heureRdD = indexHeure; this.calendrier.heureRdD = indexHeure;
this.calendrier.minutesRelative = 0; this.calendrier.minutesRelative = 0;
game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier) ); game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier));
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
fillCalendrierData( data = {} ) { fillCalendrierData(data = {}) {
let moisKey = heuresList[this.calendrier.moisRdD]; let moisKey = heuresList[this.calendrier.moisRdD];
let heureKey = heuresList[this.calendrier.heureRdD]; let heureKey = heuresList[this.calendrier.heureRdD];
const mois = heuresDef[moisKey]; const mois = heuresDef[moisKey];
const heure = heuresDef[heureKey]; const heure = heuresDef[heureKey];
//console.log(moisKey, heureKey); //console.log(moisKey, heureKey);
data.heureKey = heureKey; data.heureKey = heureKey;
data.moisKey = moisKey; data.moisKey = moisKey;
data.jourMois = this.calendrier.jour + 1; data.jourMois = this.calendrier.jour + 1;
data.nomMois = mois.label; // heures et mois nommés identiques data.nomMois = mois.label; // heures et mois nommés identiques
data.iconMois = dossierIconesHeures + mois.icon; data.iconMois = dossierIconesHeures + mois.icon;
data.nomHeure = heure.label; data.nomHeure = heure.label;
data.iconHeure = dossierIconesHeures + heure.icon; data.iconHeure = dossierIconesHeures + heure.icon;
data.nomSaison = saisonsDef[mois.saison].label; data.nomSaison = saisonsDef[mois.saison].label;
data.heureRdD = this.calendrier.heureRdD;
data.minutesRelative = this.calendrier.minutesRelative; data.minutesRelative = this.calendrier.minutesRelative;
data.isGM = game.user.isGM; data.isGM = game.user.isGM;
return data; return data;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
getLectureAstrologieDifficulte( dateIndex ) { getLectureAstrologieDifficulte(dateIndex) {
let indexNow = this.getCurrentDayIndex(); let indexNow = this.getCurrentDayIndex();
let diffDay = dateIndex - indexNow; let diffDay = dateIndex - indexNow;
return - Math.floor(diffDay / 2); return - Math.floor(diffDay / 2);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async requestNombreAstral( request) { async requestNombreAstral(request) {
if ( game.user.isGM) { // Only GM if (game.user.isGM) { // Only GM
console.log( request ); console.log(request);
let jourDiff = this.getLectureAstrologieDifficulte( request.date); let jourDiff = this.getLectureAstrologieDifficulte(request.date);
let niveau = Number(request.astrologie.data.niveau) + Number(request.conditions) + Number(jourDiff) + Number(request.etat); let niveau = Number(request.astrologie.data.niveau) + Number(request.conditions) + Number(jourDiff) + Number(request.etat);
let rolled = await RdDResolutionTable.rollData({ let rolled = await RdDResolutionTable.rollData({
caracValue: request.carac_vue, caracValue: request.carac_vue,
finalLevel: niveau, finalLevel: niveau,
showDice: false}); showDice: false
let nbAstral = this.getNombreAstral( request.date ); });
let nbAstral = this.getNombreAstral(request.date);
let nbAstralFaux = nbAstral; let nbAstralFaux = nbAstral;
request.isValid = true; request.isValid = true;
request.rolled = rolled; request.rolled = rolled;
if ( !rolled .isSuccess ) { if (!rolled.isSuccess) {
request.isValid = false; request.isValid = false;
while ( nbAstralFaux == nbAstral ) { while (nbAstralFaux == nbAstral) {
nbAstralFaux = new Roll("1d12").roll().total; nbAstralFaux = new Roll("1d12").roll().total;
} }
nbAstral = nbAstralFaux; nbAstral = nbAstralFaux;
// Mise à jour des nombres astraux du joueur // Mise à jour des nombres astraux du joueur
let astralData = this.listeNombreAstral.find( (nombreAstral, i) => nombreAstral.index == request.date ); let astralData = this.listeNombreAstral.find((nombreAstral, i) => nombreAstral.index == request.date);
astralData.valeursFausses.push( {actorId: request.id, nombreAstral: nbAstralFaux}); astralData.valeursFausses.push({ actorId: request.id, nombreAstral: nbAstralFaux });
game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral ); game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral);
} }
request.nbAstral = nbAstral; request.nbAstral = nbAstral;
if ( game.user.isGM) { if (game.user.isGM) {
RdDUtility.responseNombreAstral( request ); RdDUtility.responseNombreAstral(request);
} else { } else {
game.socket.emit("system.foundryvtt-reve-de-dragon", { game.socket.emit("system.foundryvtt-reve-de-dragon", {
msg: "msg_response_nombre_astral", msg: "msg_response_nombre_astral",
data: request data: request
} ); });
} }
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
getAjustementAstrologique(heureNaissance, name='inconnu') getAjustementAstrologique(heureNaissance, name = 'inconnu') {
{
let heure = Grammar.toLowerCaseNoAccent(heureNaissance); let heure = Grammar.toLowerCaseNoAccent(heureNaissance);
if (heure && heuresDef[heure]) { if (heure && heuresDef[heure]) {
let hn = heuresDef[heure].heure; let hn = heuresDef[heure].heure;
let chiffreAstral = this.getCurrentNombreAstral(); let chiffreAstral = this.getCurrentNombreAstral();
let heureCourante = this.calendrier.heureRdD; let heureCourante = this.calendrier.heureRdD;
let ecartChance = (hn + chiffreAstral - heureCourante)%12; let ecartChance = (hn + chiffreAstral - heureCourante) % 12;
switch (ecartChance) switch (ecartChance) {
{
case 0: return 4; case 0: return 4;
case 4: case 8: return 2; case 4: case 8: return 2;
case 6: return -4; case 6: return -4;
@ -290,7 +305,7 @@ export class RdDCalendrier extends Application {
this.fillCalendrierData(data); this.fillCalendrierData(data);
this.setPos( this.calendrierPos ); this.setPos(this.calendrierPos);
return data; return data;
} }
@ -301,8 +316,8 @@ export class RdDCalendrier extends Application {
let elmnt = document.getElementById("calendar-time-container"); let elmnt = document.getElementById("calendar-time-container");
if (elmnt) { if (elmnt) {
elmnt.style.bottom = null; elmnt.style.bottom = null;
let xPos = (pos.left) > window.innerWidth ? window.innerWidth-200 : pos.left; let xPos = (pos.left) > window.innerWidth ? window.innerWidth - 200 : pos.left;
let yPos = (pos.top) > window.innerHeight-20 ? window.innerHeight-100 : pos.top; let yPos = (pos.top) > window.innerHeight - 20 ? window.innerHeight - 100 : pos.top;
elmnt.style.top = (yPos) + "px"; elmnt.style.top = (yPos) + "px";
elmnt.style.left = (xPos) + "px"; elmnt.style.left = (xPos) + "px";
resolve(); resolve();
@ -315,126 +330,97 @@ export class RdDCalendrier extends Application {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
updateDisplay() { updateDisplay() {
let data = this.fillCalendrierData( ); let data = this.fillCalendrierData();
// Rebuild data // Rebuild data
let dateHTML = `Jour ${data.jourMois} de ${data.nomMois} (${data.nomSaison})`; let dateHTML = `Jour ${data.jourMois} de ${data.nomMois} (${data.nomSaison})`;
if (game.user.isGM) { if (game.user.isGM) {
dateHTML = dateHTML + " - NA: "+this.getCurrentNombreAstral(); dateHTML = dateHTML + " - NA: " + this.getCurrentNombreAstral();
}
for (let handle of document.getElementsByClassName("calendar-move-handle")) {
handle.innerHTML = dateHTML;
}
for (let heure of document.getElementsByClassName("calendar-heure-texte")) {
heure.innerHTML = data.nomHeure;
}
for (const minute of document.getElementsByClassName("calendar-time-disp")) {
minute.innerHTML = `${data.minutesRelative} minutes`;
}
for (const heureImg of document.getElementsByClassName("calendar-heure-img")) {
heureImg.src = data.iconHeure;
} }
document.getElementById("calendar--move-handle").innerHTML = dateHTML;
document.getElementById("calendar-heure-texte").innerHTML = `${data.nomHeure}`;
document.getElementById("calendar-time").innerHTML = `${data.minutesRelative} min.`;
document.getElementById("calendar-heure-img").src = data.iconHeure;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
saveEditeur( calendrierData ) { saveEditeur(calendrierData) {
this.calendrier.minutesRelative = Number(calendrierData.minutesRelative); this.calendrier.minutesRelative = Number(calendrierData.minutesRelative);
this.calendrier.jour = Number(calendrierData.jourMois) - 1; this.calendrier.jour = Number(calendrierData.jourMois) - 1;
this.calendrier.moisRdD = heuresList.findIndex(mois => mois === calendrierData.moisKey); this.calendrier.moisRdD = heuresList.findIndex(mois => mois === calendrierData.moisKey);
this.calendrier.heureRdD = heuresList.findIndex(heure => heure === calendrierData.heureKey);; // Index dans heuresList this.calendrier.heureRdD = heuresList.findIndex(heure => heure === calendrierData.heureKey);; // Index dans heuresList
game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier) ); game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier));
this.rebuildListeNombreAstral(); this.rebuildListeNombreAstral();
this.updateDisplay(); this.updateDisplay();
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async showCalendarEditor() { async showCalendarEditor() {
let calendrierData = duplicate( this.fillCalendrierData( ) ); let calendrierData = duplicate(this.fillCalendrierData());
if ( this.editeur == undefined ) { if (this.editeur == undefined) {
calendrierData.jourMoisOptions = Array(28).fill().map((item, index) => 1 + index); calendrierData.jourMoisOptions = Array(28).fill().map((item, index) => 1 + index);
calendrierData.heuresOptions = [0, 1]; calendrierData.heuresOptions = [0, 1];
calendrierData.minutesOptions = Array(120).fill().map((item, index) => 0 + index); calendrierData.minutesOptions = Array(120).fill().map((item, index) => 0 + index);
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/calendar-editor-template.html', calendrierData ); let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/calendar-editor-template.html', calendrierData);
this.editeur = new RdDCalendrierEditeur(html, this, calendrierData ) this.editeur = new RdDCalendrierEditeur(html, this, calendrierData)
} }
this.editeur.updateData( calendrierData ); this.editeur.updateData(calendrierData);
this.editeur.render(true); this.editeur.render(true);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async showAstrologieEditor() { async showAstrologieEditor() {
let calendrierData = duplicate( this.fillCalendrierData( ) ); let calendrierData = duplicate(this.fillCalendrierData());
let astrologieArray = []; let astrologieArray = [];
for (let astralData of this.listeNombreAstral ) { for (let astralData of this.listeNombreAstral) {
astralData.humanDate = this.getDateFromIndex( astralData.index ); astralData.humanDate = this.getDateFromIndex(astralData.index);
for (let vf of astralData.valeursFausses) { for (let vf of astralData.valeursFausses) {
let actor = game.actors.get( vf.actorId); let actor = game.actors.get(vf.actorId);
console.log(vf.actorId, actor ); console.log(vf.actorId, actor);
vf.actorName = (actor) ? actor.name : "Inconnu"; vf.actorName = (actor) ? actor.name : "Inconnu";
} }
astrologieArray.push( duplicate(astralData ) ); astrologieArray.push(duplicate(astralData));
} }
//console.log("ASTRO", astrologieArray); //console.log("ASTRO", astrologieArray);
calendrierData.astrologieData = astrologieArray; calendrierData.astrologieData = astrologieArray;
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/calendar-astrologie-template.html', calendrierData ); let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/calendar-astrologie-template.html', calendrierData);
let astrologieEditeur = new RdDAstrologieEditeur(html, this, calendrierData ) let astrologieEditeur = new RdDAstrologieEditeur(html, this, calendrierData)
astrologieEditeur.updateData( calendrierData ); astrologieEditeur.updateData(calendrierData);
astrologieEditeur.render(true); astrologieEditeur.render(true);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
/** @override */ /** @override */
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM); HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM);
this.updateDisplay(); this.updateDisplay();
html.find('#calendar-btn-1min').click(ev => { html.find('.calendar-btn').click(ev => this.onCalendarButton(ev));
ev.preventDefault();
this.incrementTime(1); html.find('.calendar-btn-edit').click(ev => {
this.updateDisplay();
});
html.find('#calendar-btn-5min').click(ev => {
ev.preventDefault();
this.incrementTime(5);
this.updateDisplay();
});
html.find('#calendar-btn-10min').click(ev => {
ev.preventDefault();
this.incrementTime(10);
this.updateDisplay();
});
html.find('#calendar-btn-20min').click(ev => {
ev.preventDefault();
this.incrementTime(20);
this.updateDisplay();
});
html.find('#calendar-btn-30min').click(ev => {
ev.preventDefault();
this.incrementTime(30);
this.updateDisplay();
});
html.find('#calendar-btn-1heure').click(ev => {
ev.preventDefault();
this.incrementTime(120);
this.updateDisplay();
});
html.find('#calendar-btn-vaisseau').click(ev => {
ev.preventDefault();
this.positionnerHeure(0); // 0 -> vaisseau
this.updateDisplay();
});
html.find('#calendar-btn-lyre').click(ev => {
ev.preventDefault();
this.positionnerHeure(6); // 6 -> lyre
this.updateDisplay();
});
html.find('#calendar-btn-edit').click(ev => {
ev.preventDefault(); ev.preventDefault();
this.showCalendarEditor(); this.showCalendarEditor();
}); });
html.find('#astrologie-btn-edit').click(ev => {
html.find('.astrologie-btn-edit').click(ev => {
ev.preventDefault(); ev.preventDefault();
this.showAstrologieEditor(); this.showAstrologieEditor();
}); });
html.find('#calendar--move-handle').mousedown(ev => { html.find('#calendar-move-handle').mousedown(ev => {
ev.preventDefault(); ev.preventDefault();
ev = ev || window.event; ev = ev || window.event;
let isRightMB = false; let isRightMB = false;
@ -455,11 +441,11 @@ export class RdDCalendrier extends Application {
e.preventDefault(); e.preventDefault();
pos3 = e.clientX; pos3 = e.clientX;
pos4 = e.clientY; pos4 = e.clientY;
document.onmouseup = closeDragElement; document.onmouseup = closeDragElement;
document.onmousemove = elementDrag; document.onmousemove = elementDrag;
} }
function elementDrag(e) { function elementDrag(e) {
e = e || window.event; e = e || window.event;
e.preventDefault(); e.preventDefault();
@ -473,36 +459,36 @@ export class RdDCalendrier extends Application {
elmnt.style.top = (elmnt.offsetTop - pos2) + "px"; elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
elmnt.style.left = (elmnt.offsetLeft - pos1) + "px"; elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
} }
function closeDragElement() { function closeDragElement() {
// stop moving when mouse button is released: // stop moving when mouse button is released:
elmnt.onmousedown = null; elmnt.onmousedown = null;
document.onmouseup = null; document.onmouseup = null;
document.onmousemove = null; document.onmousemove = null;
let xPos = (elmnt.offsetLeft - pos1) > window.innerWidth ? window.innerWidth-200 : (elmnt.offsetLeft - pos1); let xPos = (elmnt.offsetLeft - pos1) > window.innerWidth ? window.innerWidth - 200 : (elmnt.offsetLeft - pos1);
let yPos = (elmnt.offsetTop - pos2) > window.innerHeight-20 ? window.innerHeight-100 : (elmnt.offsetTop - pos2) let yPos = (elmnt.offsetTop - pos2) > window.innerHeight - 20 ? window.innerHeight - 100 : (elmnt.offsetTop - pos2)
xPos = xPos < 0 ? 0 : xPos; xPos = xPos < 0 ? 0 : xPos;
yPos = yPos < 0 ? 0 : yPos; yPos = yPos < 0 ? 0 : yPos;
if(xPos != (elmnt.offsetLeft - pos1) || yPos != (elmnt.offsetTop - pos2)){ if (xPos != (elmnt.offsetLeft - pos1) || yPos != (elmnt.offsetTop - pos2)) {
elmnt.style.top = (yPos) + "px"; elmnt.style.top = (yPos) + "px";
elmnt.style.left = (xPos) + "px"; elmnt.style.left = (xPos) + "px";
} }
game.system.rdd.calendrier.calendrierPos.top = yPos; game.system.rdd.calendrier.calendrierPos.top = yPos;
game.system.rdd.calendrier.calendrierPos.left = xPos; game.system.rdd.calendrier.calendrierPos.left = xPos;
if ( game.user.isGM) { if (game.user.isGM) {
game.settings.set("foundryvtt-reve-de-dragon", "calendrier-pos", duplicate(game.system.rdd.calendrier.calendrierPos) ); game.settings.set("foundryvtt-reve-de-dragon", "calendrier-pos", duplicate(game.system.rdd.calendrier.calendrierPos));
} }
} }
} }
} else if(isRightMB){ } else if (isRightMB) {
game.system.rdd.calendrier.calendrierPos.top = 200; game.system.rdd.calendrier.calendrierPos.top = 200;
game.system.rdd.calendrier.calendrierPos.left = 200; game.system.rdd.calendrier.calendrierPos.left = 200;
if ( game.user.isGM) { if (game.user.isGM) {
game.settings.set("foundryvtt-reve-de-dragon", "calendrier-pos", duplicate(game.system.rdd.calendrier.calendrierPos) ); game.settings.set("foundryvtt-reve-de-dragon", "calendrier-pos", duplicate(game.system.rdd.calendrier.calendrierPos));
} }
this.setPos(game.system.rdd.calendrier.calendrierPos); this.setPos(game.system.rdd.calendrier.calendrierPos);
} }
}); });
} }
} }

View File

@ -50,7 +50,12 @@ export class RdDCombatManager extends Combat {
/* -------------------------------------------- */ /* -------------------------------------------- */
cleanSonne() { cleanSonne() {
for (let combatant of this.data.combatants) { for (let combatant of this.data.combatants) {
combatant.actor.verifierSonneRound(this.current.round); if (combatant.actor) {
combatant.actor.verifierSonneRound(this.current.round);
}
else {
ui.notifications.warn(`Le combatant ${combatant.name} n'est pas associé à un acteur!`)
}
} }
} }
@ -171,10 +176,13 @@ export class RdDCombatManager extends Combat {
/* -------------------------------------------- */ /* -------------------------------------------- */
static buildListeActionsCombat(combatant) { static buildListeActionsCombat(combatant) {
const actor = combatant.actor; // Easy access if (combatant.actor == undefined) {
let items = actor.data.items; ui.notifications.warn(`Le combatant ${combatant.name} n'est pas associé à un acteur, impossible de déterminer ses actions de combat!`)
return [];
}
let items = combatant.actor.data.items;
let actions = [] let actions = []
if (actor.isCreature()) { if (combatant.actor.isCreature()) {
actions = actions.concat(items.filter(it => RdDItemCompetenceCreature.isCompetenceAttaque(it)) actions = actions.concat(items.filter(it => RdDItemCompetenceCreature.isCompetenceAttaque(it))
.map(competence => RdDItemCompetenceCreature.toArme(competence))); .map(competence => RdDItemCompetenceCreature.toArme(competence)));
} else { } else {
@ -184,7 +192,7 @@ export class RdDCombatManager extends Combat {
.concat(RdDItemArme.mainsNues()); .concat(RdDItemArme.mainsNues());
let competences = items.filter(it => it.type == 'competence'); let competences = items.filter(it => it.type == 'competence');
actions = actions.concat(RdDCombatManager.finalizeArmeList(armes, competences, actor.data.data.carac)); actions = actions.concat(RdDCombatManager.finalizeArmeList(armes, competences, combatant.actor.data.data.carac));
actions.push({ name: "Draconic", data: { initOnly: true, competence: "Draconic" } }); actions.push({ name: "Draconic", data: { initOnly: true, competence: "Draconic" } });
} }
@ -251,17 +259,20 @@ export class RdDCombatManager extends Combat {
/* -------------------------------------------- */ /* -------------------------------------------- */
static rollInitiativeCompetence(combatantId, arme) { static rollInitiativeCompetence(combatantId, arme) {
const combatant = game.combat.getCombatant(combatantId); const combatant = game.combat.getCombatant(combatantId);
const actor = combatant.actor; if (combatant.actor == undefined) {
ui.notifications.warn(`Le combatant ${combatant.name} n'est pas associé à un acteur, impossible de déterminer ses actions de combat!`)
return [];
}
let initInfo = ""; let initInfo = "";
let initOffset = 0; let initOffset = 0;
let caracForInit = 0; let caracForInit = 0;
let compNiveau = 0; let compNiveau = 0;
let competence = { name: "Aucune" }; let competence = { name: "Aucune" };
if (actor.getSurprise() == "totale") { if (combatant.actor.getSurprise() == "totale") {
initOffset = -1; // To force 0 initOffset = -1; // To force 0
initInfo = "Surprise Totale" initInfo = "Surprise Totale"
} else if (actor.getSurprise() == "demi") { } else if (combatant.actor.getSurprise() == "demi") {
initOffset = 0; initOffset = 0;
initInfo = "Demi Surprise" initInfo = "Demi Surprise"
} else if (arme.name == "Autre action") { } else if (arme.name == "Autre action") {
@ -276,13 +287,13 @@ export class RdDCombatManager extends Combat {
compNiveau = competence.data.niveau; compNiveau = competence.data.niveau;
initInfo = arme.name + " / " + arme.data.competence; initInfo = arme.name + " / " + arme.data.competence;
if (actor.data.type == 'creature' || actor.data.type == 'entite') { if (combatant.actor.data.type == 'creature' || combatant.actor.data.type == 'entite') {
caracForInit = competence.data.carac_value; caracForInit = competence.data.carac_value;
if (competence.data.categorie == "lancer") { if (competence.data.categorie == "lancer") {
initOffset = 5; initOffset = 5;
} }
} else { } else {
caracForInit = actor.data.data.carac[competence.data.defaut_carac].value; caracForInit = combatant.actor.data.data.carac[competence.data.defaut_carac].value;
if (competence.data.categorie == "lancer") { // Offset de principe pour les armes de jet if (competence.data.categorie == "lancer") { // Offset de principe pour les armes de jet
initOffset = 4; initOffset = 4;
} }
@ -294,7 +305,7 @@ export class RdDCombatManager extends Combat {
} }
} }
} }
let malus = actor.getEtatGeneral(); // Prise en compte état général let malus = combatant.actor.getEtatGeneral(); // Prise en compte état général
// Cas des créatures et entités vs personnages // Cas des créatures et entités vs personnages
let rollFormula = initOffset + "+ ( (" + RdDCombatManager.calculInitiative(compNiveau, caracForInit) + " + " + malus + ") /100)"; let rollFormula = initOffset + "+ ( (" + RdDCombatManager.calculInitiative(compNiveau, caracForInit) + " + " + malus + ") /100)";
// Garder la trace de l'arme/compétence utilisée pour l'iniative // Garder la trace de l'arme/compétence utilisée pour l'iniative
@ -638,6 +649,7 @@ export class RdDCombat {
static isEchec(rollData) { static isEchec(rollData) {
switch (rollData.ajustements.surprise.used) { switch (rollData.ajustements.surprise.used) {
case 'totale': return true; case 'totale': return true;
case 'demi': return !rollData.rolled.isSign;
} }
return rollData.rolled.isEchec; return rollData.rolled.isEchec;
} }
@ -662,6 +674,7 @@ export class RdDCombat {
static isReussite(rollData) { static isReussite(rollData) {
switch (rollData.ajustements.surprise.used) { switch (rollData.ajustements.surprise.used) {
case 'totale': return false; case 'totale': return false;
case 'demi': return rollData.rolled.isSign;
} }
return rollData.rolled.isSuccess; return rollData.rolled.isSuccess;
} }
@ -675,7 +688,6 @@ export class RdDCombat {
let rollData = this._prepareAttaque(competence, arme); let rollData = this._prepareAttaque(competence, arme);
console.log("RdDCombat.attaque >>>", rollData); console.log("RdDCombat.attaque >>>", rollData);
if (arme) { if (arme) {
this.attacker.incItemUse(arme._id); // Usage
this.attacker.verifierForceMin(arme); this.attacker.verifierForceMin(arme);
} }
@ -689,6 +701,7 @@ export class RdDCombat {
callbacks: [ callbacks: [
this.attacker.createCallbackExperience(), this.attacker.createCallbackExperience(),
{ action: r => this.removeChatMessageActionsPasseArme(r.passeArme) }, { action: r => this.removeChatMessageActionsPasseArme(r.passeArme) },
{ condition: r => arme && !RdDCombat.isParticuliere(r), action: r => this.attacker.incDecItemUse(arme._id) },
{ condition: r => (RdDCombat.isReussite(r) && !RdDCombat.isParticuliere(r)), action: r => this._onAttaqueNormale(r) }, { condition: r => (RdDCombat.isReussite(r) && !RdDCombat.isParticuliere(r)), action: r => this._onAttaqueNormale(r) },
{ condition: RdDCombat.isParticuliere, action: r => this._onAttaqueParticuliere(r) }, { condition: RdDCombat.isParticuliere, action: r => this._onAttaqueParticuliere(r) },
{ condition: RdDCombat.isEchec, action: r => this._onAttaqueEchec(r) }, { condition: RdDCombat.isEchec, action: r => this._onAttaqueEchec(r) },
@ -727,10 +740,9 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onAttaqueParticuliere(rollData) { async _onAttaqueParticuliere(rollData) {
RdDCombat._storeAttaque(this.attackerId, rollData); RdDCombat._storeAttaque(this.attackerId, rollData);
this.attacker.decItemUse( rollData.arme._id ); // Usage décrémenté sur particulière
// Finesse et Rapidité seulement en mêlée et si la difficulté libre est de -1 minimum // Finesse et Rapidité seulement en mêlée et si la difficulté libre est de -1 minimum
const isMeleeDiffNegative = rollData.selectedCarac.label == "Mêlée" && rollData.diffLibre < 0; const isMeleeDiffNegative = (rollData.competence.type == 'competencecreature' || rollData.selectedCarac.label == "Mêlée") && rollData.diffLibre < 0;
ChatMessage.create({ ChatMessage.create({
alias: this.attacker.name, alias: this.attacker.name,
whisper: ChatUtility.getWhisperRecipientsAndGMs(this.attacker.name), whisper: ChatUtility.getWhisperRecipientsAndGMs(this.attacker.name),
@ -898,6 +910,10 @@ export class RdDCombat {
async choixParticuliere(rollData, choix) { async choixParticuliere(rollData, choix) {
console.log("RdDCombat.choixParticuliere >>>", rollData, choix); console.log("RdDCombat.choixParticuliere >>>", rollData, choix);
if (choix != "rapidite") {
this.attacker.incDecItemUse(rollData.arme._id);
}
this.removeChatMessageActionsPasseArme(rollData.passeArme); this.removeChatMessageActionsPasseArme(rollData.passeArme);
rollData.particuliere = choix; rollData.particuliere = choix;
await this._onAttaqueNormale(rollData); await this._onAttaqueNormale(rollData);
@ -908,7 +924,6 @@ export class RdDCombat {
let arme = this.defender.getArmeParade(armeParadeId); let arme = this.defender.getArmeParade(armeParadeId);
console.log("RdDCombat.parade >>>", attackerRoll, armeParadeId, arme); console.log("RdDCombat.parade >>>", attackerRoll, armeParadeId, arme);
this.defender.incItemUse(armeParadeId); // Usage
let rollData = this._prepareParade(attackerRoll, arme); let rollData = this._prepareParade(attackerRoll, arme);
@ -922,6 +937,7 @@ export class RdDCombat {
callbacks: [ callbacks: [
this.defender.createCallbackExperience(), this.defender.createCallbackExperience(),
{ action: r => this.removeChatMessageActionsPasseArme(r.passeArme) }, { action: r => this.removeChatMessageActionsPasseArme(r.passeArme) },
{ condition: r => !RdDCombat.isParticuliere(r), action: r => this.defender.incDecItemUse(armeParadeId) },
{ condition: RdDCombat.isReussite, action: r => this._onParadeNormale(r) }, { condition: RdDCombat.isReussite, action: r => this._onParadeNormale(r) },
{ condition: RdDCombat.isParticuliere, action: r => this._onParadeParticuliere(r) }, { condition: RdDCombat.isParticuliere, action: r => this._onParadeParticuliere(r) },
{ condition: RdDCombat.isEchec, action: r => this._onParadeEchec(r) }, { condition: RdDCombat.isEchec, action: r => this._onParadeEchec(r) },
@ -935,7 +951,7 @@ export class RdDCombat {
const compName = armeParade.data.competence; const compName = armeParade.data.competence;
const armeAttaque = attackerRoll.arme; const armeAttaque = attackerRoll.arme;
let rollData = { let defenderRoll = {
passeArme: attackerRoll.passeArme, passeArme: attackerRoll.passeArme,
diffLibre: attackerRoll.diffLibre, diffLibre: attackerRoll.diffLibre,
attackerRoll: attackerRoll, attackerRoll: attackerRoll,
@ -947,13 +963,13 @@ export class RdDCombat {
carac: this.defender.data.data.carac, carac: this.defender.data.data.carac,
show: {} show: {}
}; };
rollData.diviseurSignificative = this._getDiviseurSignificative(rollData); defenderRoll.diviseurSignificative = this._getDiviseurSignificative(defenderRoll);
if (this.defender.isCreature()) { if (this.defender.isCreature()) {
RdDItemCompetenceCreature.setRollDataCreature(rollData); RdDItemCompetenceCreature.setRollDataCreature(defenderRoll);
} }
return rollData; return defenderRoll;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -1016,7 +1032,6 @@ export class RdDCombat {
} }
console.log("RdDCombat.esquive >>>", attackerRoll, esquive); console.log("RdDCombat.esquive >>>", attackerRoll, esquive);
let rollData = this._prepareEsquive(attackerRoll, esquive); let rollData = this._prepareEsquive(attackerRoll, esquive);
this.defender.incItemUse(esquive._id); // Usage
const dialog = await RdDRoll.create(this.defender, rollData, const dialog = await RdDRoll.create(this.defender, rollData,
{ html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html' }, { { html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html' }, {
@ -1024,6 +1039,7 @@ export class RdDCombat {
label: 'Esquiver', label: 'Esquiver',
callbacks: [ callbacks: [
this.defender.createCallbackExperience(), this.defender.createCallbackExperience(),
{ condition: r => !RdDCombat.isParticuliere(r), action: r => this.defender.incDecItemUse(esquive._id) },
{ action: r => this.removeChatMessageActionsPasseArme(r.passeArme) }, { action: r => this.removeChatMessageActionsPasseArme(r.passeArme) },
{ condition: RdDCombat.isReussite, action: r => this._onEsquiveNormale(r) }, { condition: RdDCombat.isReussite, action: r => this._onEsquiveNormale(r) },
{ condition: RdDCombat.isParticuliere, action: r => this._onEsquiveParticuliere(r) }, { condition: RdDCombat.isParticuliere, action: r => this._onEsquiveParticuliere(r) },

View File

@ -32,7 +32,7 @@ export class RdDCommands {
rddCommands.registerCommand({ path: ["/nom"], func: (content, msg, params) => RdDNameGen.getName(msg, params), descr: "Génère un nom aléatoire" }); rddCommands.registerCommand({ path: ["/nom"], func: (content, msg, params) => RdDNameGen.getName(msg, params), descr: "Génère un nom aléatoire" });
rddCommands.registerCommand({ rddCommands.registerCommand({
path: ["/tmra"], func: (content, msg, params) => rddCommands.getTMRAleatoire(msg, params), path: ["/tmra"], func: (content, msg, params) => rddCommands.getTMRAleatoire(msg, params),
descr: `Tire une case aléatoire des Terres médianes descr: `Tire une case aléatoire des Terres médianes
<br><strong>/tmra forêt</strong> détermine une 'forêt' aléatoire <br><strong>/tmra forêt</strong> détermine une 'forêt' aléatoire
<br><strong>/tmra</strong> détermine une case aléatoire dans toutes les TMR` }); <br><strong>/tmra</strong> détermine une case aléatoire dans toutes les TMR` });
@ -241,7 +241,7 @@ export class RdDCommands {
getTMRAleatoire(msg, params) { getTMRAleatoire(msg, params) {
if (params.length < 2) { if (params.length < 2) {
let type = params[0]; let type = params[0];
const tmr = TMRUtility.getTMRAleatoire(it => it.type == type); const tmr = TMRUtility.getTMRAleatoire(type ? (it => it.type == type) : (it => true));
RdDCommands._chatAnswer(msg, `Case aléatoire: ${tmr.coord} - ${tmr.label}`); RdDCommands._chatAnswer(msg, `Case aléatoire: ${tmr.coord} - ${tmr.label}`);
} }
else { else {

File diff suppressed because one or more lines are too long

View File

@ -1058,7 +1058,7 @@ ul, li {
position: absolute; position: absolute;
display: block; display: block;
} }
#calendar{ .calendar{
min-width: 150px; min-width: 150px;
grid-row: 1; grid-row: 1;
grid-column: 1; grid-column: 1;
@ -1072,7 +1072,7 @@ ul, li {
font-family: "GoudyAcc"; font-family: "GoudyAcc";
z-index: 100; z-index: 100;
} }
#calendar-hdr{ .calendar-hdr{
display: grid; display: grid;
font-size: 1rem; font-size: 1rem;
margin: 3px; margin: 3px;
@ -1091,7 +1091,7 @@ ul, li {
font-size: 1.10rem; font-size: 1.10rem;
opacity: 90; opacity: 90;
} }
#calendar--move-handle { #calendar-move-handle {
font-family: "GoudyAcc"; font-family: "GoudyAcc";
font-size: 13px; font-size: 13px;
line-height: 1; line-height: 1;
@ -1101,7 +1101,7 @@ ul, li {
border: none; border: none;
flex: 1; flex: 1;
} }
#calendar-date{ .calendar-date{
grid-row: 1; grid-row: 1;
grid-column: 2; grid-column: 2;
float: left; float: left;
@ -1112,11 +1112,11 @@ ul, li {
color: #CCC; color: #CCC;
cursor: pointer; cursor: pointer;
} }
#calendar-date, .calendar-date,
#calendar-date-num { .calendar-date-num {
transition: 0.2s; transition: 0.2s;
} }
#calendar-date-num { .calendar-date-num {
grid-row: 1; grid-row: 1;
grid-column: 2; grid-column: 2;
float: left; float: left;
@ -1128,18 +1128,18 @@ ul, li {
opacity: 0; opacity: 0;
cursor: pointer; cursor: pointer;
} }
#calendar-heure-img{ .calendar-heure-img{
width: 24px; width: 24px;
height: 24px; height: 24px;
flex-grow: 0; flex-grow: 0;
border-width: 0; border-width: 0;
opacity: 90; opacity: 90;
color: #CCC; color: rgba(255, 255, 255, 0.5);
} }
#calendar-hdr:hover #calendar-date { .calendar-hdr:hover .calendar-date {
opacity: 0; opacity: 0;
} }
#calendar-hdr:hover #calendar-date-num{ .calendar-hdr:hover .calendar-date-num{
opacity: 1; opacity: 1;
} }
.calendar-container{ .calendar-container{
@ -1161,132 +1161,86 @@ ul, li {
margin: 2px; margin: 2px;
grid-row-gap: 3px; grid-row-gap: 3px;
} }
#astrologie-btn-edit, .astrologie-btn-edit,
#calendar-btn-edit{ .calendar-btn-edit{
grid-row: 1; grid-row: 1;
grid-column: 1; grid-column: 1;
margin: auto; margin: auto;
color: rgba(0, 0, 0, 0.5); color: rgba(0, 0, 0, 0.5);
} }
#astrologie-btn-edit:hover, .astrologie-btn-edit:hover,
#calendar-btn-edit:hover { .calendar-btn-edit:hover {
color: #FFF; color: #FFF;
border: 0px solid #000; border: 0px solid #000;
cursor: pointer; cursor: pointer;
} }
#calendar-btn-1min{ .calendar-btn{
margin: auto;
border: 1px solid rgba(0, 0, 0, 0);
color: rgba(255, 255, 255, 0.5);
}
.calendar-btn:hover {
color: rgba(255, 255, 128, 0.7);
border: 1px solid rgba(255, 128, 0, 0.8);
cursor: pointer;
}
.calendar-1min{
grid-row: 1; grid-row: 1;
grid-column: 1; grid-column: 1;
margin: auto;
color: rgba(0, 0, 0, 0.7);
} }
#calendar-btn-5min{ .calendar-5min{
grid-row: 1; grid-row: 1;
grid-column: 2; grid-column: 2;
margin: auto;
color: rgba(0, 0, 0, 0.7);
} }
#calendar-btn-10min{ .calendar-10min{
grid-row: 2; grid-row: 2;
grid-column: 1; grid-column: 1;
margin-left: 10px; margin-left: 10px;
color: rgba(0, 0, 0, 0.7);
} }
#calendar-btn-20min{ .calendar-20min{
grid-row: 2; grid-row: 2;
grid-column: 2; grid-column: 2;
margin-left: 10px; margin-left: 10px;
color: rgba(0, 0, 0, 0.7);
} }
#calendar-btn-lyre{ .calendar-lyre{
grid-row: 1; grid-row: 1;
grid-column: 1; grid-column: 1;
height: fit-content; height: fit-content;
text-align: center; text-align: center;
vertical-align: center; vertical-align: center;
color: rgba(0, 0, 0, 0.7);
} }
#calendar-btn-vaisseau{ .calendar-vaisseau{
grid-row: 1; grid-row: 1;
grid-column: 2; grid-column: 2;
height: fit-content; height: fit-content;
text-align: center; text-align: center;
vertical-align: center; vertical-align: center;
color: rgba(0, 0, 0, 0.7);
} }
#calendar-btn-30min{ .calendar-30min{
grid-row: 2; grid-row: 2;
grid-column: 1; grid-column: 1;
height: fit-content; height: fit-content;
text-align: center; text-align: center;
vertical-align: center; vertical-align: center;
color: rgba(0, 0, 0, 0.7);
} }
#calendar-btn-1heure{ .calendar-1heure{
grid-row: 2; grid-row: 2;
grid-column: 2; grid-column: 2;
height: fit-content; height: fit-content;
text-align: center; text-align: center;
vertical-align: center; vertical-align: center;
color: rgba(0, 0, 0, 0.7);
}
#calendar-btn-container-left:hover{
color: #FFF;
border: 0px solid #000;
cursor: pointer;
}
#calendar-btn-1min:hover {
color: #FFF;
border: 0px solid #000;
cursor: pointer;
} }
#calendar-btn-5min:hover { .calendar-btn-container-left:hover{
color: #FFF; color: #FFF;
border: 0px solid #000; border: 0px solid #000;
cursor: pointer; cursor: pointer;
} }
#calendar-btn-10min:hover {
color: #FFF;
border: 0px solid #000;
cursor: pointer;
}
#calendar-btn-20min:hover {
color: #FFF;
border: 0px solid #000;
cursor: pointer;
}
#calendar-btn-30min:hover {
color: #FFF;
border: 0px solid #000;
cursor: pointer;
}
#calendar-btn-1heure:hover {
color: #FFF;
border: 0px solid #000;
cursor: pointer;
}
#calendar-btn-vaisseau:hover {
color: #FFF;
border: 0px solid #000;
cursor: pointer;
}
#calendar-btn-lyre:hover{
color: #FFF;
border: 0px solid #000;
cursor: pointer;
}
.calendar-weekday-time{ .calendar-weekday-time{
display: grid; display: grid;
float: left; float: left;
@ -1296,7 +1250,7 @@ ul, li {
margin: auto; margin: auto;
color: #CCC; color: #CCC;
} }
#calendar-weekday{ .calendar-weekday{
grid-column: 1; grid-column: 1;
grid-row: 1; grid-row: 1;
text-align: center; text-align: center;

View File

@ -1,34 +1,34 @@
<div id="calendar-time-container"> <div id="calendar-time-container">
<div id="calendar"> <div class="calendar">
{{#if isGM}} {{#if isGM}}
<i id="calendar-btn-edit" class="fas fa-cog" title="Editer"></i> <i class="calendar-btn-edit fas fa-cog" title="Editer"></i>
<i id="astrologie-btn-edit" class="fas fa-cog" title="Astrologie"></i> <i class="astrologie-btn-edit fas fa-cog" title="Astrologie"></i>
{{/if}} {{/if}}
<div id="calendar-hdr"> <div class="calendar-hdr">
<p id="calendar--move-handle" class="calendar-date-rdd" title="Deplacer">Jour {{jourMois}} de {{nomMois}} ({{nomSaison}})</p> <p id="calendar-move-handle" class="calendar-date-rdd" title="Deplacer">Jour {{jourMois}} de {{nomMois}} ({{nomSaison}})</p>
</div> </div>
<div class="calendar-container"> <div class="calendar-container">
{{#if isGM}} {{#if isGM}}
<div class="calendar-btn-container-left"> <div class="calendar-btn-container-left">
<i id="calendar-btn-1min" class="fas fa-angle-right" title="Avancer de 1 minute"></i> <i class="calendar-btn calendar-1min fas fa-angle-right" data-calendar-avance="1" title="Avancer de 1 minute"></i>
<i id="calendar-btn-5min" class="fas fa-angle-double-right" title="Avancer de 5 minutes"></i> <i class="calendar-btn calendar-5min fas fa-angle-double-right" data-calendar-avance="5" title="Avancer de 5 minutes"></i>
<i id="calendar-btn-10min" class="fas fa-play" title="Avancer de 10 minutes"></i> <i class="calendar-btn calendar-10min fas fa-play" data-calendar-avance="10" title="Avancer de 10 minutes"></i>
<i id="calendar-btn-20min" class="fas fa-step-forward" title="Avancer de 20 minutes"></i> <i class="calendar-btn calendar-20min fas fa-step-forward" data-calendar-avance="20" title="Avancer de 20 minutes"></i>
</div> </div>
{{else}} {{else}}
<div class="calendar-btn-container-left"> <div class="calendar-btn-container-left">
</div> </div>
{{/if}} {{/if}}
<div class="calendar-weekday-time"> <div class="calendar-weekday-time">
<p id="calendar-weekday"><img id="calendar-heure-img" src="{{iconHeure}}" alt="{{nomHeure}}"/>&nbsp;<span id="calendar-heure-texte">{{nomHeure}}</span></p> <p class="calendar-weekday"><img class="calendar-heure-img" src="{{iconHeure}}" alt="{{nomHeure}}"/>&nbsp;<span class="calendar-heure-texte">{{nomHeure}}</span></p>
<span class="calendar-time isGM"><p class="calendar-time-disp" id="calendar-time" title="Start/Stop">{{heuresRelative}}:{{minutesRelative}}</p></span> <span class="calendar-time isGM"><p class="calendar-time-disp">{{minutesRelative}} minutes</p></span>
</div> </div>
{{#if isGM}} {{#if isGM}}
<div class="calendar-btn-container-right"> <div class="calendar-btn-container-right">
<i id="calendar-btn-30min" class="fas fa-forward" title="Avancer de 30 minutes" ></i> <i class="calendar-btn calendar-30min fas fa-forward" data-calendar-avance="30" title="Avancer de 30 minutes" ></i>
<i id="calendar-btn-1heure" class="fas fa-fast-forward" title="Avancer d'1 heure" ></i> <i class="calendar-btn calendar-1heure fas fa-fast-forward" data-calendar-avance="120" title="Avancer d'1 heure" ></i>
<i id="calendar-btn-vaisseau" class="fas fa-sun" title="Avancer au Vaisseau"></i> <i class="calendar-btn calendar-vaisseau fas fa-sun" data-calendar-set="0" title="Avancer au Vaisseau"></i>
<i id="calendar-btn-lyre" class="fas fa-moon" title="Avancer à Lyre"></i> <i class="calendar-btn calendar-lyre fas fa-moon" data-calendar-set="6" title="Avancer à Lyre"></i>
</div> </div>
{{/if}} {{/if}}
</div> </div>

View File

@ -37,19 +37,19 @@
{{else}} {{else}}
{{#each armes as |arme key|}} {{#each armes as |arme key|}}
<a class='chat-card-button' id='parer-button' data-attackerId='{{../attackerId}}' data-defenderTokenId='{{../defenderTokenId}}' data-armeid='{{arme._id }}'> <a class='chat-card-button' id='parer-button' data-attackerId='{{../attackerId}}' data-defenderTokenId='{{../defenderTokenId}}' data-armeid='{{arme._id }}'>
Parer avec {{arme.name}} à {{../diffLibre }} (Utilisation : {{arme.data.nbUsage}}) Parer avec {{arme.name}} à {{../diffLibre }}{{#if arme.data.nbUsage}} (Utilisations : {{arme.data.nbUsage}}){{/if}}
</a> </a>
<br> <br>
{{/each}} {{/each}}
{{#if mainsNues}} {{#if mainsNues}}
<a class='chat-card-button' id='parer-button' data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderTokenId}}'> <a class='chat-card-button' id='parer-button' data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderTokenId}}'>
Parer à mains nues à {{diffLibre}} (Utilisation : {{arme.data.nbUsage}}) Parer à mains nues à {{diffLibre}}{{#if arme.data.nbUsage}} (Utilisations : {{arme.data.nbUsage}}){{/if}}
</a> </a>
<br> <br>
{{/if}} {{/if}}
{{#if (ne attaqueCategorie 'tir')}} {{#if (ne attaqueCategorie 'tir')}}
<a class='chat-card-button' id='esquiver-button' data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderTokenId}}'> <a class='chat-card-button' id='esquiver-button' data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderTokenId}}'>
Esquiver à {{diffLibre}} (Utilisation : {{esquiveUsage}}) Esquiver à {{diffLibre}} {{#if esquiveUsage}} (Utilisations : {{esquiveUsage}}){{/if}}
</a> </a>
<br> <br>
{{/if}} {{/if}}