#52 Gestion astrologie
This commit is contained in:
parent
e07120aa23
commit
5aba029da9
@ -1514,12 +1514,28 @@ export class RdDActor extends Actor {
|
|||||||
// selon l'heure de naissance...
|
// selon l'heure de naissance...
|
||||||
return game.system.rdd.calendrier.getAjustementAstrologique(this.data.data.heure);
|
return game.system.rdd.calendrier.getAjustementAstrologique(this.data.data.heure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async ajouteNombreAstral( data ) {
|
||||||
|
// Ajout du nombre astral
|
||||||
|
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 this.createEmbeddedEntity("OwnedItem", item);
|
||||||
|
|
||||||
|
// Suppression des anciens nombres astraux
|
||||||
|
let toDelete = this.data.items.filter( (item) => item.data.jourindex < game.system.rdd.calendrier.getCurrentDayIndex() );
|
||||||
|
const deletions = toDelete.map(i => i._id);
|
||||||
|
await this.deleteEmbeddedEntity("OwnedItem", deletions);
|
||||||
|
|
||||||
|
// Affichage Dialog
|
||||||
|
this.astrologieNombresAstraux();
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async astrologieNombresAstraux( ) {
|
async astrologieNombresAstraux( ) {
|
||||||
// Afficher l'interface spéciale
|
// Afficher l'interface spéciale
|
||||||
const myDialog = await RdDAstrologieJoueur.create( this, {} );
|
const astrologieDialog = await RdDAstrologieJoueur.create( this, {} );
|
||||||
myDialog.render(true);
|
astrologieDialog.render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -11,12 +11,12 @@ 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: this.organizeNombres( actor),
|
||||||
dates: game.system.rdd.calendrier.getJoursSuivants( 10 ),
|
dates: game.system.rdd.calendrier.getJoursSuivants( 10 ),
|
||||||
|
etat: actor.data.data.compteurs.etat.value,
|
||||||
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
||||||
astrologie: RdDUtility.findCompetence( actor.data.items, 'Astrologie')
|
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) {
|
||||||
@ -42,10 +42,28 @@ export class RdDAstrologieJoueur extends Dialog {
|
|||||||
this.dataNombreAstral = duplicate(data);
|
this.dataNombreAstral = duplicate(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
static organizeNombres(actor) {
|
||||||
|
let itemNombres = actor.data.items.filter( (item) => item.type == 'nombreastral');
|
||||||
|
let itemFiltered = {};
|
||||||
|
for ( let item of itemNombres) {
|
||||||
|
if ( itemFiltered[item.data.jourindex] ) {
|
||||||
|
itemFiltered[item.data.jourindex].listValues.push(item.data.value);
|
||||||
|
} else {
|
||||||
|
itemFiltered[item.data.jourindex] = {
|
||||||
|
listValues: [ item.data.value ],
|
||||||
|
jourlabel: item.data.jourlabel
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return itemFiltered;
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
requestJetAstrologie( ) {
|
requestJetAstrologie( ) {
|
||||||
let data = { id: this.actor.data._id,
|
let data = { id: this.actor.data._id,
|
||||||
carac_vue: this.actor.data.data.carac['vue'].value,
|
carac_vue: this.actor.data.data.carac['vue'].value,
|
||||||
|
etat: this.dataNombreAstral.etat,
|
||||||
astrologie: this.dataNombreAstral.astrologie,
|
astrologie: this.dataNombreAstral.astrologie,
|
||||||
conditions: $("#diffConditions").val(),
|
conditions: $("#diffConditions").val(),
|
||||||
date: $("#joursAstrologie").val()
|
date: $("#joursAstrologie").val()
|
||||||
@ -58,6 +76,7 @@ export class RdDAstrologieJoueur extends Dialog {
|
|||||||
data: data
|
data: data
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
this.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -69,6 +88,10 @@ export class RdDAstrologieJoueur extends Dialog {
|
|||||||
activateListeners(html) {
|
activateListeners(html) {
|
||||||
super.activateListeners(html);
|
super.activateListeners(html);
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
$("#diffConditions").val(0);
|
||||||
|
});
|
||||||
|
|
||||||
html.find('#jet-astrologie').click((event) => {
|
html.find('#jet-astrologie').click((event) => {
|
||||||
this.requestJetAstrologie();
|
this.requestJetAstrologie();
|
||||||
});
|
});
|
||||||
|
@ -233,7 +233,7 @@ export class RdDCalendrier extends Application {
|
|||||||
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);
|
let niveau = Number(request.astrologie.data.niveau) + Number(request.conditions) + Number(jourDiff) + Number(request.etat);
|
||||||
let rolled = await RdDResolutionTable.roll(request.carac_vue, niveau, undefined, false);
|
let rolled = await RdDResolutionTable.roll(request.carac_vue, niveau, undefined, false);
|
||||||
|
|
||||||
let nbAstral = this.getNombreAstral( request.date );
|
let nbAstral = this.getNombreAstral( request.date );
|
||||||
@ -356,6 +356,11 @@ export class RdDCalendrier extends Application {
|
|||||||
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) {
|
||||||
|
let actor = game.actors.get( vf.actorId);
|
||||||
|
console.log(vf.actorId, actor );
|
||||||
|
vf.actorName = (actor) ? actor.name : "Inconnu";
|
||||||
|
}
|
||||||
astrologieArray.push( duplicate(astralData ) );
|
astrologieArray.push( duplicate(astralData ) );
|
||||||
}
|
}
|
||||||
//console.log("ASTRO", astrologieArray);
|
//console.log("ASTRO", astrologieArray);
|
||||||
|
@ -719,11 +719,9 @@ export class RdDUtility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async responseNombreAstral( data ) {
|
static async responseNombreAstral( data ) {
|
||||||
let actor = game.actors.get( data.id);
|
let actor = game.actors.get( data.id);
|
||||||
const item = {name: "Nombre Astral", type: "nombreastral", data:
|
actor.ajouteNombreAstral(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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -635,6 +635,17 @@ ul, li {
|
|||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ======================================== */
|
||||||
|
.table-nombres-astraux {
|
||||||
|
border:1;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
}
|
||||||
|
.table-nombres-astraux td {
|
||||||
|
border: 1px solid black;
|
||||||
|
text-align: center;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
/* ======================================== */
|
/* ======================================== */
|
||||||
.tokenhudext {
|
.tokenhudext {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -8,20 +8,21 @@
|
|||||||
{{!-- 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>
|
<table class='table-nombres-astraux'>
|
||||||
<table border=1>
|
<tr class='table-nombres-astraux-td'>
|
||||||
<tr>
|
|
||||||
{{#each astrologieData as |nombreData key|}}
|
{{#each astrologieData as |nombreData key|}}
|
||||||
<td align="center">{{nombreData.humanDate}}</td>
|
<td class='table-nombres-astraux-td'>{{nombreData.humanDate}}</td>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr class='table-nombres-astraux-td'>
|
||||||
{{#each astrologieData as |nombreData key|}}
|
{{#each astrologieData as |nombreData key|}}
|
||||||
<td align="center">
|
<td class='table-nombres-astraux-td'>
|
||||||
{{nombreData.nombreAstral}}
|
<ol>
|
||||||
|
<b>{{nombreData.nombreAstral}}</b>
|
||||||
{{#each nombreData.valeursFausses as |fausseVal key|}}
|
{{#each nombreData.valeursFausses as |fausseVal key|}}
|
||||||
<li>{{fausseVal.actorId}} - {{fausseVal.nombreAstral}}</li>
|
<li>{{fausseVal.actorName}} - {{fausseVal.nombreAstral}}</li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
</ol>
|
||||||
</td>
|
</td>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -21,21 +21,28 @@
|
|||||||
{{/each}}
|
{{/each}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
</select>
|
</select>
|
||||||
|
<label for="categorie">Etat Général: {{etat}}</label>
|
||||||
<label for="categorie"> <a id='jet-astrologie'>Faire un jet d'Astrologie</a></label>
|
<label for="categorie"> <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 class='table-nombres-astraux'>
|
||||||
<tr>
|
<tr class='table-nombres-astraux-td'>
|
||||||
{{#each nombres as |nombreData key|}}
|
{{#each nombres as |nombreData key|}}
|
||||||
<td align="center">{{nombreData.data.jourlabel}}</td>
|
<td class='table-nombres-astraux-td'>{{nombreData.jourlabel}}</td>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr class='table-nombres-astraux-td'>
|
||||||
{{#each nombres as |nombreData key|}}
|
{{#each nombres as |nombreData key|}}
|
||||||
<td align="center">{{nombreData.data.value}}</td>
|
<td class='table-nombres-astraux-td'>
|
||||||
|
<ol>
|
||||||
|
{{#each nombreData.listValues as |nombreAstral key|}}
|
||||||
|
<li>{{nombreAstral}}</li>
|
||||||
|
{{/each}}
|
||||||
|
</ol>
|
||||||
|
</td>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
Loading…
Reference in New Issue
Block a user