#36 et #70 : corrections sur XP et ajout première version des taches

This commit is contained in:
sladecraven 2020-12-15 08:37:52 +01:00
parent 0e5caf048e
commit a726705c0c
12 changed files with 154 additions and 31 deletions

View File

@ -194,6 +194,12 @@ export class RdDActorSheet extends ActorSheet {
new Dialog( dialogData ).render(true);
}
/* -------------------------------------------- */
async createEmptyTache( ) {
let emptyTache = await Item.create( { name: 'Nouvelle tache', type: 'tache'} );
await this.actor.createOwnedItem( emptyTache.data, { renderSheet: true } );
}
/* -------------------------------------------- */
/** @override */
activateListeners(html) {
@ -226,6 +232,9 @@ export class RdDActorSheet extends ActorSheet {
this.actor.remiseANeuf();
}
});
html.find('#creer-tache').click(ev => {
this.createEmptyTache();
});
// Blessure control
html.find('.blessure-control').click(ev => {
@ -280,6 +289,11 @@ export class RdDActorSheet extends ActorSheet {
let compName = event.currentTarget.text;
this.actor.rollCompetence( compName);
});
html.find('.tache-label a').click((event) => {
const li = $(event.currentTarget).parents(".item");
let tacheId = li.data('item-id');
this.actor.rollTache( tacheId );
});
// Points de reve actuel
html.find('.ptreve-actuel a').click((event) => {

View File

@ -1436,6 +1436,11 @@ export class RdDActor extends Actor {
ChatUtility.chatWithRollMode(chatOptions, this.name)
}
/* -------------------------------------------- */
getCompetenceList() {
return this.data.items.filter( (item) => item.type == 'competence');
}
/* -------------------------------------------- */
async rollCarac( caracName ) {
let rollData = {
@ -1503,6 +1508,55 @@ export class RdDActor extends Actor {
dialog.render(true);
}
/* -------------------------------------------- */
getTache ( id ) {
return this.data.items.find( item => item._id == id );
}
/* -------------------------------------------- */
async rollTache( id ) {
let tache = duplicate( this.getTache( id ) );
let competence = duplicate(this.getCompetence(tache.data.competence));
competence.data.defaut_carac = tache.data.carac; // Patch !
let rollData = {
competence: competence,
needSignificative : this.data.data.sante.sonne.value,
tache: tache,
diffConditions: tache.data.difficulte,
editLibre: false,
editConditions: false,
actor: this
}
rollData.carac = {};
rollData.carac[tache.data.carac] = duplicate(this.data.data.carac[tache.data.carac]); // Single carac
console.log("rollTache !!!", duplicate(rollData));
const dialog = await RdDRoll.create(this, rollData, {html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html'}, {
name: 'jet-competence',
label: 'Jet de Tâche ' + tache.name,
callbacks: [
this.createCallbackExperience(),
{ action: this._tacheResult }
]
} );
dialog.render(true);
}
/* -------------------------------------------- */
_tacheResult(rollData) {
ChatUtility.chatWithRollMode({
content: "<strong>Test de Tache : " + rollData.tache.name + " - " + rollData.selectedCarac.label + " / " + rollData.competence.name + "</strong>"
+ "<br>Difficultés <strong>libre : " + rollData.diffLibre + "</strong> / conditions : " + Misc.toSignedString(rollData.diffConditions) +" / état : " + rollData.etat
+ RdDResolutionTable.explain(rollData.rolled)
+ "<br>Points de taches : " + rollData.rolled.ptTache + ", ajustement qualité: " + rollData.rolled.ptQualite
}, this.name);
rollData.tache.data.points_de_tache_courant += rollData.rolled.ptTache;
rollData.actor.updateEmbeddedEntity( "OwnedItem", rollData.tache);
}
/* -------------------------------------------- */
_competenceResult(rollData) {
ChatUtility.chatWithRollMode({
@ -1510,7 +1564,7 @@ export class RdDActor extends Actor {
+ "<br>Difficultés <strong>libre : " + rollData.diffLibre + "</strong> / conditions : " + Misc.toSignedString(rollData.diffConditions) +" / état : " + rollData.etat
+ RdDResolutionTable.explain(rollData.rolled)
+ "<br>Points de taches : " + rollData.rolled.ptTache + ", ajustement qualité: " + rollData.rolled.ptQualite
}, this.name)
}, this.name);
}
/* -------------------------------------------- */
@ -1587,6 +1641,8 @@ export class RdDActor extends Actor {
let competence = duplicate( RdDUtility.findCompetence( this.data.items, competenceName ) );
competence.data.xp += xpComp;
await this.updateEmbeddedEntity( "OwnedItem", competence);
} else {
xpCarac = 1; // Si pas de competence, le max d'XP en carac est de 1 (cf p. 144)
}
if ( !carac[caracName].isderivee) {
carac[caracName].xp += xpCarac;

View File

@ -32,6 +32,11 @@ export class RdDItemSheet extends ItemSheet {
getData() {
let data = super.getData();
if ( data.item.type == 'tache') {
//console.log("****", data, this);
data.caracList = duplicate(this.actor.data.data.carac),
data.competenceList = this.actor.getCompetenceList()
}
data.bonusCaseList = RdDItemSort.getBonusCaseList(data, true);
data.isGM = game.user.isGM; // Pour vérouiller certaines éditions
@ -63,7 +68,6 @@ export class RdDItemSheet extends ItemSheet {
}
/* -------------------------------------------- */
get template()
{
let type = this.item.type;

4
module/item-tache.js Normal file
View File

@ -0,0 +1,4 @@
export class RdDItemTache extends Item {
}

View File

@ -28,8 +28,7 @@ export class RdDRoll extends Dialog {
/* -------------------------------------------- */
static _setDefaultOptions(actor, rollData) {
mergeObject(rollData,
{
let defaultRollData = {
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
difficultesLibres: CONFIG.RDD.difficultesLibres,
etat: actor.data.data.compteurs.etat.value,
@ -37,6 +36,8 @@ export class RdDRoll extends Dialog {
finalLevel: 0,
diffConditions: 0,
diffLibre: 0,
editLibre: true,
editConditions: true,
forceValue : actor.getForceValue(),
malusArmureValue: (actor.type == 'personnage ' && actor.data.data.attributs && actor.data.data.attributs.malusarmure) ? actor.data.data.attributs.malusarmure.value : 0,
surencMalusFlag: actor.type == 'personnage ' ? (actor.data.data.compteurs.surenc.value < 0) : false,
@ -46,8 +47,8 @@ export class RdDRoll extends Dialog {
useEncForNatation: false,
encValueForNatation: actor.encombrementTotal ? Math.floor(actor.encombrementTotal) : 0,
ajustementAstrologique: actor.ajustementAstrologique()
},
{ overwrite: false });
}
mergeObject(rollData, defaultRollData, { overwrite: false, insertValues:false } );
}
/* -------------------------------------------- */

View File

@ -236,6 +236,7 @@ export class RdDUtility {
data.data.souffles = this.checkNull(data.itemsByType['souffle']);
data.data.ombres = this.checkNull(data.itemsByType['ombre']);
data.data.tetes = this.checkNull(data.itemsByType['tete']);
data.data.taches = this.checkNull(data.itemsByType['tache']);
data.data.objets = data.data.conteneurs.concat(data.data.materiel).concat(data.data.armes).concat(data.data.armures).concat(data.data.munitions).concat(data.data.livres).concat(data.data.potions).concat(data.data.herbes).concat(data.data.ingredients);
}

View File

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

View File

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

View File

@ -531,7 +531,7 @@
}
},
"Item": {
"types": ["objet", "arme", "armure", "conteneur", "competence", "sort", "herbe", "ingredient", "livre", "potion", "munition", "rencontresTMR", "queue", "ombre", "souffle", "tete", "competencecreature", "tarot", "monnaie", "nombreastral"],
"types": ["objet", "arme", "armure", "conteneur", "competence", "sort", "herbe", "ingredient", "livre", "potion", "munition", "rencontresTMR", "queue", "ombre", "souffle", "tete", "competencecreature", "tarot", "monnaie", "nombreastral", "tache"],
"objet": {
"description": "",
"quantite": 1,
@ -641,7 +641,10 @@
"cout": 0
},
"tache": {
"carac": "",
"competence": "",
"periodicite": "",
"fatigue": 0,
"difficulte": 0,
"points_de_tache": 0,
"points_de_tache_courant": 0,

View File

@ -662,6 +662,21 @@
</li>
</ul>
</article>
<article class="flexcol">
<h3>Tâches</h3><a id='creer-tache'>Créer une nouvelle Tâche</a>
<ul class="item-list alterne-list">
{{#each data.taches as |tache id|}}
<li class="item flexrow list-item" data-item-id="{{tache._id}}"><span class="competence-title tache-label"><a>{{tache.name}}</a></span>
<div class="item-controls">
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ul>
</article>
<article class="flexcol">
<h3>Biographie : </h3>
<div class="form-group editor">

View File

@ -12,7 +12,7 @@
</div>
<div class="form-group">
<label for="categorie">Difficulté libre</label>
<select name="diffLibre" id="diffLibre" data-dtype="number">
<select name="diffLibre" id="diffLibre" data-dtype="number" {{#unless editLibre}}disabled{{/unless}}>
{{#select diffLibre}}
{{#each difficultesLibres as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>
@ -20,7 +20,7 @@
{{/select}}
</select>
<label for="categorie">&nbsp;&nbsp;Conditions</label>
<select name="diffConditions" id="diffConditions" data-dtype="number">
<select name="diffConditions" id="diffConditions" data-dtype="number" {{#unless editConditions}}disabled{{/unless}}>
{{#select diffConditions}}
{{#each ajustementsConditions as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>

View File

@ -8,20 +8,44 @@
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
<label for="xp">Caractéristique</label>
<select name="data.carac" id="caracselect" data-dtype="String">
{{#select item.data.carac}}
{{#each caracList as |carac key|}}
<option value="{{key}}">{{carac.label}}</option>
{{/each}}
{{/select}}
</select>
</div>
<div class="form-group">
<label for="xp">Compétence</label>
<input class="attribute-value" type="text" name="data.competence" value="{{data.competence}}" data-dtype="Number"/>
<select name="data.competence" id="competenceselect" data-dtype="String">
{{#select item.data.competence}}
{{#each competenceList as |competence key|}}
<option value="{{competence.name}}">{{competence.name}}</option>
{{/each}}
{{/select}}
</select>
</div>
<div class="form-group">
<label for="xp">Difficulté</label>
<input class="attribute-value" type="text" name="data.difficulte" value="{{data.difficulte}}" data-dtype="Number"/>
</div>
<div class="form-group">
<label for="xp">Périodicité</label>
<input class="attribute-value" type="text" name="data.periodicite" value="{{data.periodicite}}" data-dtype="String"/>
</div>
<div class="form-group">
<label for="xp">Fatigue</label>
<input class="attribute-value" type="text" name="data.fatigue" value="{{data.fatigue}}" data-dtype="Number"/>
</div>
<div class="form-group">
<label for="xp">Points de tâches nécessaires</label>
<input class="attribute-value" type="text" name="data.points_de_tache" value="{{data.points_de_tache}}" data-dtype="Number"/>
</div>
<div class="form-group">
<label for="xp">Points de tâches obtenus<</label>
<label for="xp">Points de tâches obtenus</label>
<input class="attribute-value" type="text" name="data.points_de_tache_courant" value="{{data.points_de_tache_courant}}" data-dtype="Number"/>
</div>
<span><label>Description : </label></span>