#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...
|
||||
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( ) {
|
||||
// Afficher l'interface spéciale
|
||||
const myDialog = await RdDAstrologieJoueur.create( this, {} );
|
||||
myDialog.render(true);
|
||||
const astrologieDialog = await RdDAstrologieJoueur.create( this, {} );
|
||||
astrologieDialog.render(true);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -11,12 +11,12 @@ export class RdDAstrologieJoueur extends Dialog {
|
||||
/* -------------------------------------------- */
|
||||
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 ),
|
||||
etat: actor.data.data.compteurs.etat.value,
|
||||
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);
|
||||
let options = { classes: ["rdddialog"], width: 600, height: 500, 'z-index': 99999 };
|
||||
if (dialogConfig.options) {
|
||||
@ -42,10 +42,28 @@ export class RdDAstrologieJoueur extends Dialog {
|
||||
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( ) {
|
||||
let data = { id: this.actor.data._id,
|
||||
carac_vue: this.actor.data.data.carac['vue'].value,
|
||||
etat: this.dataNombreAstral.etat,
|
||||
astrologie: this.dataNombreAstral.astrologie,
|
||||
conditions: $("#diffConditions").val(),
|
||||
date: $("#joursAstrologie").val()
|
||||
@ -58,6 +76,7 @@ export class RdDAstrologieJoueur extends Dialog {
|
||||
data: data
|
||||
} );
|
||||
}
|
||||
this.close();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -69,6 +88,10 @@ export class RdDAstrologieJoueur extends Dialog {
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
$(function () {
|
||||
$("#diffConditions").val(0);
|
||||
});
|
||||
|
||||
html.find('#jet-astrologie').click((event) => {
|
||||
this.requestJetAstrologie();
|
||||
});
|
||||
|
@ -233,7 +233,7 @@ export class RdDCalendrier extends Application {
|
||||
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 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 nbAstral = this.getNombreAstral( request.date );
|
||||
@ -356,6 +356,11 @@ export class RdDCalendrier extends Application {
|
||||
let astrologieArray = [];
|
||||
for (let astralData of this.listeNombreAstral ) {
|
||||
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 ) );
|
||||
}
|
||||
//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);
|
||||
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);
|
||||
actor.ajouteNombreAstral(data);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -635,6 +635,17 @@ ul, li {
|
||||
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 {
|
||||
display: flex;
|
||||
|
@ -8,20 +8,21 @@
|
||||
{{!-- Sheet Body --}}
|
||||
<section class="sheet-body">
|
||||
<div class="form-group">
|
||||
<label for="astralList">Nombres Astraux</label>
|
||||
<table border=1>
|
||||
<tr>
|
||||
<table class='table-nombres-astraux'>
|
||||
<tr class='table-nombres-astraux-td'>
|
||||
{{#each astrologieData as |nombreData key|}}
|
||||
<td align="center">{{nombreData.humanDate}}</td>
|
||||
<td class='table-nombres-astraux-td'>{{nombreData.humanDate}}</td>
|
||||
{{/each}}
|
||||
</tr>
|
||||
<tr>
|
||||
<tr class='table-nombres-astraux-td'>
|
||||
{{#each astrologieData as |nombreData key|}}
|
||||
<td align="center">
|
||||
{{nombreData.nombreAstral}}
|
||||
<td class='table-nombres-astraux-td'>
|
||||
<ol>
|
||||
<b>{{nombreData.nombreAstral}}</b>
|
||||
{{#each nombreData.valeursFausses as |fausseVal key|}}
|
||||
<li>{{fausseVal.actorId}} - {{fausseVal.nombreAstral}}</li>
|
||||
<li>{{fausseVal.actorName}} - {{fausseVal.nombreAstral}}</li>
|
||||
{{/each}}
|
||||
</ol>
|
||||
</td>
|
||||
{{/each}}
|
||||
</tr>
|
||||
|
@ -21,21 +21,28 @@
|
||||
{{/each}}
|
||||
{{/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>
|
||||
|
||||
{{!-- Sheet Body --}}
|
||||
<section class="sheet-body">
|
||||
<div class="form-group">
|
||||
<label for="astralList">Nombres Astraux</label>
|
||||
<table border=1>
|
||||
<tr>
|
||||
<table class='table-nombres-astraux'>
|
||||
<tr class='table-nombres-astraux-td'>
|
||||
{{#each nombres as |nombreData key|}}
|
||||
<td align="center">{{nombreData.data.jourlabel}}</td>
|
||||
<td class='table-nombres-astraux-td'>{{nombreData.jourlabel}}</td>
|
||||
{{/each}}
|
||||
</tr>
|
||||
<tr>
|
||||
<tr class='table-nombres-astraux-td'>
|
||||
{{#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}}
|
||||
</tr>
|
||||
</table>
|
||||
|
Loading…
Reference in New Issue
Block a user