Rework chant danse jeu

This commit is contained in:
Vincent Vandemeulebrouck 2021-04-21 00:59:10 +02:00
parent d376ba1c26
commit a20037698b
6 changed files with 83 additions and 126 deletions

View File

@ -2315,15 +2315,17 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async _rollArt(artData, selected, oeuvre, callBackResult = r => this._resultArt(r)) { async _rollArt(artData, selected, oeuvre, callBackResult = r => this._resultArt(r)) {
const actorData = Misc.data(this); const actorData = Misc.data(this);
mergeObject(artData, { mergeObject(artData,
{
oeuvre: oeuvre, oeuvre: oeuvre,
art: oeuvre.type, art: oeuvre.type,
competence: Misc.data(this.getCompetence(oeuvre.data.competence ?? artData.art)), competence: duplicate(Misc.data(this.getCompetence(oeuvre.data.competence ?? artData.art))),
diffLibre: - (oeuvre.data.niveau ?? 0), diffLibre: - (oeuvre.data.niveau ?? 0),
diffConditions: 0, diffConditions: 0,
use: { libre: false, conditions: true }, use: { libre: false, conditions: true },
selectedCarac: duplicate(actorData.data.carac[selected]) selectedCarac: duplicate(actorData.data.carac[selected])
}); },
{ overwrite: false });
artData.competence.data.defaut_carac = selected; artData.competence.data.defaut_carac = selected;
if (!artData.forceCarac) { if (!artData.forceCarac) {
artData.forceCarac = {}; artData.forceCarac = {};
@ -2366,13 +2368,13 @@ export class RdDActor extends Actor {
const actorData = Misc.data(this); const actorData = Misc.data(this);
const artData = { art: 'danse', verbe: 'Danser', forceCarac: {} }; const artData = { art: 'danse', verbe: 'Danser', forceCarac: {} };
const oeuvre = duplicate(this.getItemOfType(id, artData.art)); const oeuvre = duplicate(this.getItemOfType(id, artData.art));
const selectedCarac = this._getCaracDanse(oeuvre);
if (oeuvre.data.agilite) { if (oeuvre.data.agilite) {
artData.forceCarac['agilite'] = duplicate(actorData.data.carac.agilite); artData.forceCarac['agilite'] = duplicate(actorData.data.carac.agilite);
} }
if (oeuvre.data.apparence) { if (oeuvre.data.apparence) {
artData.forceCarac['apparence'] = duplicate(actorData.data.carac.apparence); artData.forceCarac['apparence'] = duplicate(actorData.data.carac.apparence);
} }
const selectedCarac = this._getCaracDanse(oeuvre);
await this._rollArt(artData, selectedCarac, oeuvre); await this._rollArt(artData, selectedCarac, oeuvre);
} }
@ -2434,12 +2436,21 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollJeu(id) { async rollJeu(id) {
const actorData = Misc.data(this);
const oeuvre = Misc.data(this.getJeu(id));
const listCarac = oeuvre.data.caraccomp.toLowerCase().split(/[.,:\/-]/).map(it => it.trim());
const carac = listCarac.length > 0 ? listCarac[0] : 'chance'
const artData = { const artData = {
art: 'jeu', verbe: 'Jeu', art: 'jeu', verbe: 'Jeu',
use: { libre: true, conditions: true, }, use: { libre: true, conditions: true, },
competence: duplicate(Misc.data(this.getCompetence('jeu'))),
forceCarac: {}
}; };
const oeuvre = duplicate(this.getJeu(id)); listCarac.forEach(c => artData.forceCarac[c] = actorData.data.carac[c]);
await this._rollArt(artData, oeuvre.data?.caraccomp.toLowerCase() ?? 'chance', oeuvre); artData.competence.data.niveauReel = artData.competence.data.niveau;
artData.competence.data.niveau = Math.max(artData.competence.data.niveau, oeuvre.data.base);
await this._rollArt(artData, carac, oeuvre);
} }
async rollOeuvre(id) { async rollOeuvre(id) {
@ -2597,9 +2608,8 @@ export class RdDActor extends Actor {
let xpComp = 0; let xpComp = 0;
if (competence) { if (competence) {
xpComp = xp - xpCarac; xpComp = xp - xpCarac;
competence = duplicate(competence); let update = { _id: competence.id, 'data.xp': Misc.toInt(competence.data.xp) + xpComp };
competence.data.xp = Misc.toInt(competence.data.xp) + xpComp; await this.updateEmbeddedDocuments('Item', [update]);
await this.updateEmbeddedDocuments('Item', [competence]);
} else { } else {
xpCarac = Math.max(xpCarac, 1); xpCarac = Math.max(xpCarac, 1);
} }

View File

@ -1,36 +1,26 @@
<form class="rdddialog"> <form class="rdddialog">
<div class="form-group"> <h2>Chanter: {{oeuvre.name}}</h2>
<ul>
<li><label>Chant : {{oeuvre.name}}</label></li>
<li><label>Jet : OUIE / {{competence.name}}</label></li>
</ul>
<div class="tooltipAppelAuMoral divAppelAuMoral">
<img class="imgAppelAuMoral small-button-container" src="/systems/foundryvtt-reve-de-dragon/icons/moral-neutre.svg">
<span class="tooltipAppelAuMoralText">Sans appel au moral</span>
</div>
</div>
<div class="form-group"> <div class="grid grid-2col">
<label>conditions</label> <div class="flex-group-left">
<select name="diffConditions" id="diffConditions" data-dtype="number"> <img class="chat-icon" src="{{competence.img}}" alt="{{competence.name}}"/>
{{#select diffConditions}} <div class="grid grid-2col">
{{#each ajustementsConditions as |key|}} <label>Caractéristique: </label><label class="flex-grow">{{selectedCarac.label}}</label>
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option> <label>{{competence.name}}:</label><label class="flex-grow">{{numberFormat competence.data.niveau decimals=0 sign=true}}</label></label>
{{/each}} </div>
{{/select}} {{> "systems/foundryvtt-reve-de-dragon/templates/chat-poesie.html" oeuvre.data}}
</select> </div>
<div class="flex-group-left">
<div class="flexrow">
<label>Difficulté</label> <label>Difficulté</label>
<select name="diffLibre" id="diffLibre" data-dtype="number"> <label>{{numberFormat diffLibre decimals=0 sign=true}}</label>
{{#select diffLibre}} </div>
{{#each difficultesLibres as |key|}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option> {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}}
{{/each}} <div id="tableAjustements" class="flexrow"></div>
{{/select}} </div>
</select>
</div> </div>
<div id="tableAjustements">
</div>
<div id="tableResolution"> <div id="tableResolution">
</div> </div>
<div id="tableProbaReussite"> <div id="tableProbaReussite">

View File

@ -1,47 +1,26 @@
<form class="dialog-roll-danse"> <form class="dialog-roll-danse">
<div class="form-group"> <h2>Danser: {{oeuvre.name}}</h2>
<ul>
<li><label>Danse : {{oeuvre.name}}</label></li>
<li><label>Jet : APPARENCE ou AGILITE / {{competence.name}}</label></li>
</ul>
</div>
<div class="form-group"> <div class="grid grid-2col">
<label>Caractéristique</label> <div class="flex-group-left">
<select name="carac" id="carac" class="select-diff" data-dtype="String"> <img class="chat-icon" src="{{competence.img}}" alt="{{competence.name}}"/>
{{#select carac}} <div class="grid grid-2col">
{{#each carac as |caracitem key|}} <label for="carac">Caractéristique:</label>{{>"systems/foundryvtt-reve-de-dragon/templates/partial-select-carac.html"}}
<option value={{key}}>{{caracitem.label}}</option> <label>{{competence.name}}:</label><label class="flex-grow">{{numberFormat competence.data.niveau decimals=0 sign=true}}</label></label>
{{/each}}
{{/select}}
</select>
<div class="tooltipAppelAuMoral divAppelAuMoral">
<img class="imgAppelAuMoral small-button-container" src="/systems/foundryvtt-reve-de-dragon/icons/moral-neutre.svg">
<span class="tooltipAppelAuMoralText">Sans appel au moral</span>
</div> </div>
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-poesie.html" oeuvre.data}}
</div> </div>
<div class="flex-group-left">
<div class="form-group"> <div class="flexrow">
<label>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>Difficulté</label> <label>Difficulté</label>
<select name="diffLibre" id="diffLibre" data-dtype="number"> <label>{{numberFormat diffLibre decimals=0 sign=true}}</label>
{{#select diffLibre}} </div>
{{#each difficultesLibres as |key|}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option> {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}}
{{/each}} <div id="tableAjustements" class="flexrow"></div>
{{/select}} </div>
</select>
</div> </div>
<div id="tableAjustements">
</div>
<div id="tableResolution"> <div id="tableResolution">
</div> </div>
<div id="tableProbaReussite"> <div id="tableProbaReussite">

View File

@ -1,47 +1,25 @@
<form class="rdddialog"> <form class="rdddialog">
<div class="form-group"> <h2>Jouer à : {{oeuvre.name}}</h2>
<ul>
<li><label for="competence-label">Jouer à : {{oeuvre.name}}</label></li>
<li><label for="competence-label">Type : {{oeuvre.data.type}}</label></li>
<li><label for="competence-label">Base : {{oeuvre.data.base}}</label></li>
<li><label for="competence-label">Carac/Compétence : {{oeuvre.data.caraccomp}}</label></li>
</ul>
</div>
<div class="form-group">
<label>Caractéristique</label>
<select name="carac" id="carac" class="select-diff" data-dtype="String">
{{#select carac}}
{{#each carac as |caracitem key|}}
<option value={{key}}>{{caracitem.label}}</option>
{{/each}}
{{/select}}
</select>
<div class="tooltipAppelAuMoral divAppelAuMoral">
<img class="imgAppelAuMoral small-button-container" src="/systems/foundryvtt-reve-de-dragon/icons/moral-neutre.svg">
<span class="tooltipAppelAuMoralText">Sans appel au moral</span>
</div>
</div>
<div class="form-group">
<label>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>Difficulté </label>
<select name="diffLibre" id="diffLibre" data-dtype="number">
{{#select diffLibre}}
{{#each difficultesLibres as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>
{{/each}}
{{/select}}
</select>
</div>
<div id="tableAjustements"> <div class="grid grid-2col">
<div class="flex-group-left">
<img class="chat-icon" src="{{competence.img}}" alt="{{competence.name}}"/>
<div class="grid grid-2col">
<label>Type:</label><label class="flex-grow">{{oeuvre.data.type}}</label>
<label for="carac">Caractéristique:</label>{{>"systems/foundryvtt-reve-de-dragon/templates/partial-select-carac.html"}}
<label>{{competence.name}}:</label><label class="flex-grow">{{numberFormat competence.data.niveauReel decimals=0 sign=true}}</label></label>
<label>Niveau de base:</label><label class="flex-grow">{{oeuvre.data.base}}</label>
</div> </div>
</div>
<div class="flex-group-left">
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffLibre.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}}
<div id="tableAjustements" class="flexrow"></div>
</div>
</div>
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-poesie.html" oeuvre.data}}
<div id="tableResolution"> <div id="tableResolution">
</div> </div>
<div id="tableProbaReussite"> <div id="tableProbaReussite">

View File

@ -1,5 +1,5 @@
<div class="flexrow"> <div class="flexrow">
<label>Conditions</label> <label for="diffConditions">Conditions</label>
<select name="diffConditions" id="diffConditions" data-dtype="number" {{#unless use.conditions}}disabled{{/unless}}> <select name="diffConditions" id="diffConditions" data-dtype="number" {{#unless use.conditions}}disabled{{/unless}}>
{{#select diffConditions}} {{#select diffConditions}}
{{#each ajustementsConditions as |key|}} {{#each ajustementsConditions as |key|}}

View File

@ -1,5 +1,5 @@
<div class="flexrow"> <div class="flexrow">
<label>Difficulté libre</label> <label for="diffLibre">Difficulté libre</label>
<select name="diffLibre" id="diffLibre" data-dtype="number" {{#unless use.libre}}disabled{{/unless}}> <select name="diffLibre" id="diffLibre" data-dtype="number" {{#unless use.libre}}disabled{{/unless}}>
{{#select diffLibre}} {{#select diffLibre}}
{{#each difficultesLibres as |key|}} {{#each difficultesLibres as |key|}}