#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); 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 */ /** @override */
activateListeners(html) { activateListeners(html) {
@ -226,6 +232,9 @@ export class RdDActorSheet extends ActorSheet {
this.actor.remiseANeuf(); this.actor.remiseANeuf();
} }
}); });
html.find('#creer-tache').click(ev => {
this.createEmptyTache();
});
// Blessure control // Blessure control
html.find('.blessure-control').click(ev => { html.find('.blessure-control').click(ev => {
@ -280,7 +289,12 @@ export class RdDActorSheet extends ActorSheet {
let compName = event.currentTarget.text; let compName = event.currentTarget.text;
this.actor.rollCompetence( compName); 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 // Points de reve actuel
html.find('.ptreve-actuel a').click((event) => { html.find('.ptreve-actuel a').click((event) => {
this.actor.rollCarac( 'reve-actuel' ); this.actor.rollCarac( 'reve-actuel' );

View File

@ -1436,6 +1436,11 @@ export class RdDActor extends Actor {
ChatUtility.chatWithRollMode(chatOptions, this.name) ChatUtility.chatWithRollMode(chatOptions, this.name)
} }
/* -------------------------------------------- */
getCompetenceList() {
return this.data.items.filter( (item) => item.type == 'competence');
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollCarac( caracName ) { async rollCarac( caracName ) {
let rollData = { let rollData = {
@ -1503,6 +1508,55 @@ export class RdDActor extends Actor {
dialog.render(true); 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) { _competenceResult(rollData) {
ChatUtility.chatWithRollMode({ 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 + "<br>Difficultés <strong>libre : " + rollData.diffLibre + "</strong> / conditions : " + Misc.toSignedString(rollData.diffConditions) +" / état : " + rollData.etat
+ RdDResolutionTable.explain(rollData.rolled) + RdDResolutionTable.explain(rollData.rolled)
+ "<br>Points de taches : " + rollData.rolled.ptTache + ", ajustement qualité: " + rollData.rolled.ptQualite + "<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 ) ); let competence = duplicate( RdDUtility.findCompetence( this.data.items, competenceName ) );
competence.data.xp += xpComp; competence.data.xp += xpComp;
await this.updateEmbeddedEntity( "OwnedItem", competence); 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) { if ( !carac[caracName].isderivee) {
carac[caracName].xp += xpCarac; carac[caracName].xp += xpCarac;

View File

@ -32,6 +32,11 @@ export class RdDItemSheet extends ItemSheet {
getData() { getData() {
let data = super.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.bonusCaseList = RdDItemSort.getBonusCaseList(data, true);
data.isGM = game.user.isGM; // Pour vérouiller certaines éditions data.isGM = game.user.isGM; // Pour vérouiller certaines éditions
@ -63,7 +68,6 @@ export class RdDItemSheet extends ItemSheet {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
get template() get template()
{ {
let type = this.item.type; 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,26 +28,27 @@ export class RdDRoll extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
static _setDefaultOptions(actor, rollData) { static _setDefaultOptions(actor, rollData) {
mergeObject(rollData, let defaultRollData = {
{ ajustementsConditions: CONFIG.RDD.ajustementsConditions,
ajustementsConditions: CONFIG.RDD.ajustementsConditions, difficultesLibres: CONFIG.RDD.difficultesLibres,
difficultesLibres: CONFIG.RDD.difficultesLibres, etat: actor.data.data.compteurs.etat.value,
etat: actor.data.data.compteurs.etat.value, carac: actor.data.data.carac,
carac: actor.data.data.carac, finalLevel: 0,
finalLevel: 0, diffConditions: 0,
diffConditions: 0, diffLibre: 0,
diffLibre: 0, editLibre: true,
forceValue : actor.getForceValue(), editConditions: true,
malusArmureValue: (actor.type == 'personnage ' && actor.data.data.attributs && actor.data.data.attributs.malusarmure) ? actor.data.data.attributs.malusarmure.value : 0, forceValue : actor.getForceValue(),
surencMalusFlag: actor.type == 'personnage ' ? (actor.data.data.compteurs.surenc.value < 0) : false, malusArmureValue: (actor.type == 'personnage ' && actor.data.data.attributs && actor.data.data.attributs.malusarmure) ? actor.data.data.attributs.malusarmure.value : 0,
surencMalusValue: actor.type == 'personnage ' ? actor.data.data.compteurs.surenc.value : 0, surencMalusFlag: actor.type == 'personnage ' ? (actor.data.data.compteurs.surenc.value < 0) : false,
surencMalusApply: false, surencMalusValue: actor.type == 'personnage ' ? actor.data.data.compteurs.surenc.value : 0,
isNatation: rollData.competence ? rollData.competence.name.toLowerCase().includes("natation") : false, surencMalusApply: false,
useEncForNatation: false, isNatation: rollData.competence ? rollData.competence.name.toLowerCase().includes("natation") : false,
encValueForNatation: actor.encombrementTotal ? Math.floor(actor.encombrementTotal) : 0, useEncForNatation: false,
ajustementAstrologique: actor.ajustementAstrologique() 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.souffles = this.checkNull(data.itemsByType['souffle']);
data.data.ombres = this.checkNull(data.itemsByType['ombre']); data.data.ombres = this.checkNull(data.itemsByType['ombre']);
data.data.tetes = this.checkNull(data.itemsByType['tete']); 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); 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, .generic-label,
.competence-label, .competence-label,
.astrologie-label, .astrologie-label,
.tache-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.7", "version": "1.1.9",
"minimumCoreVersion": "0.7.5", "minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.8", "compatibleCoreVersion": "0.7.8",
"templateVersion": 66, "templateVersion": 68,
"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", "nombreastral"], "types": ["objet", "arme", "armure", "conteneur", "competence", "sort", "herbe", "ingredient", "livre", "potion", "munition", "rencontresTMR", "queue", "ombre", "souffle", "tete", "competencecreature", "tarot", "monnaie", "nombreastral", "tache"],
"objet": { "objet": {
"description": "", "description": "",
"quantite": 1, "quantite": 1,
@ -641,7 +641,10 @@
"cout": 0 "cout": 0
}, },
"tache": { "tache": {
"carac": "",
"competence": "", "competence": "",
"periodicite": "",
"fatigue": 0,
"difficulte": 0, "difficulte": 0,
"points_de_tache": 0, "points_de_tache": 0,
"points_de_tache_courant": 0, "points_de_tache_courant": 0,

View File

@ -662,6 +662,21 @@
</li> </li>
</ul> </ul>
</article> </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"> <article class="flexcol">
<h3>Biographie : </h3> <h3>Biographie : </h3>
<div class="form-group editor"> <div class="form-group editor">

View File

@ -12,7 +12,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="categorie">Difficulté libre</label> <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}} {{#select diffLibre}}
{{#each difficultesLibres as |key|}} {{#each difficultesLibres as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option> <option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>
@ -20,7 +20,7 @@
{{/select}} {{/select}}
</select> </select>
<label for="categorie">&nbsp;&nbsp;Conditions</label> <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}} {{#select diffConditions}}
{{#each ajustementsConditions as |key|}} {{#each ajustementsConditions as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option> <option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>

View File

@ -9,19 +9,43 @@
{{!-- Sheet Body --}} {{!-- Sheet Body --}}
<section class="sheet-body"> <section class="sheet-body">
<div class="form-group"> <div class="form-group">
<label for="xp">Compétence</label> <label for="xp">Caractéristique</label>
<input class="attribute-value" type="text" name="data.competence" value="{{data.competence}}" data-dtype="Number"/> <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>
<div class="form-group">
<label for="xp">Compétence</label>
<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"> <div class="form-group">
<label for="xp">Difficulté</label> <label for="xp">Difficulté</label>
<input class="attribute-value" type="text" name="data.difficulte" value="{{data.difficulte}}" data-dtype="Number"/> <input class="attribute-value" type="text" name="data.difficulte" value="{{data.difficulte}}" data-dtype="Number"/>
</div> </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"> <div class="form-group">
<label for="xp">Points de tâches nécessaires</label> <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"/> <input class="attribute-value" type="text" name="data.points_de_tache" value="{{data.points_de_tache}}" data-dtype="Number"/>
</div> </div>
<div class="form-group"> <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"/> <input class="attribute-value" type="text" name="data.points_de_tache_courant" value="{{data.points_de_tache_courant}}" data-dtype="Number"/>
</div> </div>
<span><label>Description : </label></span> <span><label>Description : </label></span>