#52 Travaux en progres....

This commit is contained in:
sladecraven 2020-12-12 23:31:19 +01:00
parent be825ffa8a
commit 808cd7296d
11 changed files with 131 additions and 20 deletions

View File

@ -1414,6 +1414,7 @@ export class RdDActor extends Actor {
dialog.render(true); dialog.render(true);
} }
/* -------------------------------------------- */
async _rollCaracResult(rollData) { async _rollCaracResult(rollData) {
let rolled = rollData.rolled; let rolled = rollData.rolled;
@ -1515,9 +1516,9 @@ export class RdDActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
astrologieNombresAstraux( ) { async astrologieNombresAstraux( ) {
// Afficher l'interface spéciale // Afficher l'interface spéciale
const myDialog = RdDAstrologieJoueur.create( this, {} ); const myDialog = await RdDAstrologieJoueur.create( this, {} );
myDialog.render(true); myDialog.render(true);
} }

View File

@ -1,4 +1,6 @@
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
import { RdDCalendrier } from "./rdd-calendrier.js";
import { RdDUtility } from "./rdd-utility.js";
/** /**
* Extend the base Dialog entity by defining a custom window to perform roll. * Extend the base Dialog entity by defining a custom window to perform roll.
@ -9,12 +11,16 @@ export class RdDAstrologieJoueur extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
static async create(actor, dialogConfig) { static async create(actor, dialogConfig) {
let data = { nombres: actor.data.items.filter( (item) => item.type == 'nombreastral') let data = { nombres: actor.data.items.filter( (item) => item.type == 'nombreastral') ,
dates: game.system.rdd.calendrier.getJoursSuivants( 10 ),
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
astrologie: RdDUtility.findCompetence( actor.data.items, 'Astrologie')
} }
console.log("DATA", data);
const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-astrologie-joueur.html', data); const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-astrologie-joueur.html', data);
let options = { classes: ["rdddialog"], width: 600, height: 500, 'z-index': 99999 }; let options = { classes: ["rdddialog"], width: 600, height: 500, 'z-index': 99999 };
if (dialogConfig.options) { if (dialogConfig.options) {
mergeObject(options, dialogConfig.options, { overwrite: true }) mergeObject(options, dialogConfig.options, { overwrite: true });
} }
return new RdDAstrologieJoueur(html, actor, data); return new RdDAstrologieJoueur(html, actor, data);
} }
@ -23,7 +29,7 @@ export class RdDAstrologieJoueur extends Dialog {
constructor(html, actor, data ) { constructor(html, actor, data ) {
let myButtons = { let myButtons = {
saveButton: { label: "Fermer", callback: html => this.fillData() } saveButton: { label: "Fermer", callback: html => this.fillData() }
}; };
// Get all n // Get all n
@ -36,6 +42,24 @@ export class RdDAstrologieJoueur extends Dialog {
this.dataNombreAstral = duplicate(data); this.dataNombreAstral = duplicate(data);
} }
/* -------------------------------------------- */
requestJetAstrologie( ) {
let data = { id: this.actor.data._id,
carac_vue: this.actor.data.data.carac['vue'].value,
astrologie: this.dataNombreAstral.astrologie,
conditions: $("#diffConditions").val(),
date: $("#joursAstrologie").val()
}
if ( game.user.isGM) {
game.system.rdd.calendrier.requestNombreAstral( data );
} else {
game.socket.emit("system.foundryvtt-reve-de-dragon", {
msg: "msg_request_nombre_astral",
data: data
} );
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
fillData() { fillData() {

View File

@ -2,6 +2,8 @@
import { RdDCalendrierEditeur } from "./rdd-calendrier-editeur.js"; import { RdDCalendrierEditeur } from "./rdd-calendrier-editeur.js";
import { RdDAstrologieEditeur } from "./rdd-astrologie-editeur.js"; import { RdDAstrologieEditeur } from "./rdd-astrologie-editeur.js";
import { HtmlUtility } from "./html-utility.js"; import { HtmlUtility } from "./html-utility.js";
import { RdDResolutionTable } from "./rdd-resolution-table.js";
import { RdDUtility } from "./rdd-utility.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
const dossierIconesHeures = 'systems/foundryvtt-reve-de-dragon/icons/heures/' const dossierIconesHeures = 'systems/foundryvtt-reve-de-dragon/icons/heures/'
@ -84,6 +86,17 @@ export class RdDCalendrier extends Application {
return (this.calendrier.moisRdD * 28) + this.calendrier.jour; return (this.calendrier.moisRdD * 28) + this.calendrier.jour;
} }
/* -------------------------------------------- */
getJoursSuivants( num) {
let jours = [];
let index = this.getCurrentDayIndex();
for (let i=0; i<num; i++) {
jours[i] = { label: this.getDateFromIndex(index), index: index };
index += 1;
}
return jours;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
ajouterNombreAstral(index) { ajouterNombreAstral(index) {
return { return {
@ -98,7 +111,12 @@ export class RdDCalendrier extends Application {
let index = this.getCurrentDayIndex(); let index = this.getCurrentDayIndex();
let astralData = this.listeNombreAstral.find( (nombreAstral, i) => nombreAstral.index == index ); let astralData = this.listeNombreAstral.find( (nombreAstral, i) => nombreAstral.index == index );
return astralData.nombreAstral || "N/A"; return astralData.nombreAstral || "N/A";
}
/* -------------------------------------------- */
getNombreAstral( index ) {
let astralData = this.listeNombreAstral.find( (nombreAstral, i) => nombreAstral.index == index );
return astralData.nombreAstral || "N/A";
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -203,6 +221,43 @@ export class RdDCalendrier extends Application {
return data; return data;
} }
/* -------------------------------------------- */
getLectureAstrologieDifficulte( dateIndex ) {
let indexNow = this.getCurrentDayIndex();
let diffDay = dateIndex - indexNow;
return - Math.floor(diffDay / 2);
}
/* -------------------------------------------- */
async requestNombreAstral( request) {
if ( game.user.isGM) { // Only GM
console.log( request );
let jourDiff = this.getLectureAstrologieDifficulte( request.date);
let niveau = Number(request.astrologie.data.niveau) + Number(request.conditions) + Number(jourDiff);
let rolled = await RdDResolutionTable.roll(request.carac_vue, niveau, undefined, false);
let nbAstral = this.getNombreAstral( request.date );
let nbAstralFaux = nbAstral;
request.isValid = true;
if ( !rolled .isSuccess ) {
request.isValid = false;
while ( nbAstralFaux == nbAstral ) {
nbAstralFaux = new Roll("1d12").roll().total;
}
nbAstral = nbAstralFaux;
}
request.nbAstral = nbAstral;
if ( game.user.isGM) {
RdDUtility.responseNombreAstral( request );
} else {
game.socket.emit("system.foundryvtt-reve-de-dragon", {
msg: "msg_response_nombre_astral",
data: request
} );
}
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
getAjustementAstrologique(heureNaissance) getAjustementAstrologique(heureNaissance)
{ {

View File

@ -103,9 +103,9 @@ export class RdDResolutionTable {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static async roll(caracValue, finalLevel, bonus = undefined ) { static async roll(caracValue, finalLevel, bonus = undefined, showDice = true ) {
let chances = this.computeChances(caracValue, finalLevel); let chances = this.computeChances(caracValue, finalLevel);
chances.showDice = true; chances.showDice = showDice;
this.updateChancesWithBonus( chances, bonus); this.updateChancesWithBonus( chances, bonus);
let rolled = await this.rollChances(chances); let rolled = await this.rollChances(chances);
rolled.caracValue = caracValue; rolled.caracValue = caracValue;

View File

@ -214,7 +214,6 @@ export class RdDRoll extends Dialog {
$("#addon-message").text(""); $("#addon-message").text("");
} }
let diffCompetence = 0; let diffCompetence = 0;
if (rollData.competence) { if (rollData.competence) {
diffCompetence = Misc.toInt(rollData.competence.data.niveau); diffCompetence = Misc.toInt(rollData.competence.data.niveau);

View File

@ -718,6 +718,14 @@ export class RdDUtility {
return defenseMsg; return defenseMsg;
} }
/* -------------------------------------------- */
static async responseNombreAstral( data ) {
let actor = game.actors.get( data.id);
const item = {name: "Nombre Astral", type: "nombreastral", data:
{ value: data.nbAstral, istrue: data.isvalid, jourindex: Number(data.date), jourlabel: game.system.rdd.calendrier.getDateFromIndex( Number(data.date) ) } };
await actor.createEmbeddedEntity("OwnedItem", item);
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static performSocketMesssage( sockmsg ) static performSocketMesssage( sockmsg )
{ {
@ -731,6 +739,10 @@ export class RdDUtility {
return ChatUtility.handleGMChatMessage(sockmsg.data); return ChatUtility.handleGMChatMessage(sockmsg.data);
case "msg_sync_time": case "msg_sync_time":
return game.system.rdd.calendrier.syncPlayerTime( sockmsg.data ); return game.system.rdd.calendrier.syncPlayerTime( sockmsg.data );
case "msg_request_nombre_astral":
return game.system.rdd.calendrier.requestNombreAstral( sockmsg.data );
case "msg_response_nombre_astral":
return RdDUtility.responseNombreAstral( sockmsg.data );
} }
} }

View File

@ -571,6 +571,7 @@ ul, li {
.arme-label, .arme-label,
.generic-label, .generic-label,
.competence-label, .competence-label,
.astrologie-label,
.description-label { .description-label {
flex-grow: 2; flex-grow: 2;
} }

View File

@ -2,10 +2,10 @@
"name": "foundryvtt-reve-de-dragon", "name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon", "title": "Rêve de Dragon",
"description": "Rêve de Dragon RPG for FoundryVTT", "description": "Rêve de Dragon RPG for FoundryVTT",
"version": "1.1.4", "version": "1.1.7",
"minimumCoreVersion": "0.7.5", "minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.8", "compatibleCoreVersion": "0.7.8",
"templateVersion": 61, "templateVersion": 66,
"author": "LeRatierBretonnien", "author": "LeRatierBretonnien",
"esmodules": [ "module/rdd-main.js", "module/hook-renderChatLog.js" ], "esmodules": [ "module/rdd-main.js", "module/hook-renderChatLog.js" ],
"styles": ["styles/simple.css"], "styles": ["styles/simple.css"],

View File

@ -531,7 +531,7 @@
} }
}, },
"Item": { "Item": {
"types": ["objet", "arme", "armure", "conteneur", "competence", "sort", "herbe", "ingredient", "livre", "potion", "munition", "rencontresTMR", "queue", "ombre", "souffle", "tete", "competencecreature", "tarot", "monnaie"], "types": ["objet", "arme", "armure", "conteneur", "competence", "sort", "herbe", "ingredient", "livre", "potion", "munition", "rencontresTMR", "queue", "ombre", "souffle", "tete", "competencecreature", "tarot", "monnaie", "nombreastral"],
"objet": { "objet": {
"description": "", "description": "",
"quantite": 1, "quantite": 1,
@ -690,7 +690,8 @@
"nombreastral": { "nombreastral": {
"value": 0, "value": 0,
"istrue": false, "istrue": false,
"jourindex": 1 "jourindex": 1,
"jourlabel": ""
}, },
"monnaie": { "monnaie": {
"quantite": "", "quantite": "",

View File

@ -541,7 +541,7 @@
</span> </span>
</li> </li>
<li class="item flexrow" > <li class="item flexrow" >
<span class="competence-label"><a id="jet-astrologie">Astrologie : Nombres Astraux</a></span> <span class="astrologie-label"><a id="jet-astrologie">Astrologie : Nombres Astraux</a></span>
</li> </li>
</ul> </ul>
</div> </div>

View File

@ -5,19 +5,37 @@
</div> </div>
</header> </header>
<label for="categorie">&nbsp;&nbsp;Conditions</label>
<select name="diffConditions" id="diffConditions" data-dtype="number">
{{#select diffConditions}}
{{#each ajustementsConditions as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>
{{/each}}
{{/select}}
</select>
<label for="categorie">&nbsp;&nbsp;Jours</label>
<select name="joursAstrologie" id="joursAstrologie" data-dtype="number">
{{#select joursSuivants}}
{{#each dates as |date key|}}
<option value={{date.index}}>{{date.label}}</option>
{{/each}}
{{/select}}
</select>
<label for="categorie">&nbsp;&nbsp;<a id='jet-astrologie'>Faire un jet d'Astrologie</a></label>
{{!-- Sheet Body --}} {{!-- Sheet Body --}}
<section class="sheet-body"> <section class="sheet-body">
<div class="form-group"> <div class="form-group">
<label for="astralList">Nombres Astraux</label> <label for="astralList">Nombres Astraux</label>
<table border=1> <table border=1>
<tr> <tr>
{{#each astrologieData as |nombreData key|}} {{#each nombres as |nombreData key|}}
<td align="center">{{nombreData.humanDate}}</td> <td align="center">{{nombreData.data.jourlabel}}</td>
{{/each}} {{/each}}
</tr> </tr>
<tr> <tr>
{{#each astrologieData as |nombreData key|}} {{#each nombres as |nombreData key|}}
<td align="center">{{nombreData.nombreAstral}}</td> <td align="center">{{nombreData.data.value}}</td>
{{/each}} {{/each}}
</tr> </tr>
</table> </table>