#77 Gestion alchimie
This commit is contained in:
parent
ec86c81fc8
commit
f4dc42743a
@ -17,6 +17,7 @@ import { DeDraconique } from "./de-draconique.js";
|
||||
import { RdDAudio } from "./rdd-audio.js";
|
||||
import { RdDItemCompetence } from "./item-competence.js";
|
||||
import { RdDItemArme } from "./item-arme.js";
|
||||
import { RdDAlchimie } from "./rdd-alchimie.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/**
|
||||
@ -2369,6 +2370,46 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async effectuerTacheAlchimie( recetteId, alchimieName, alchimieData) {
|
||||
let recette = this.data.items.find( item => item.type =='recettealchimique' && item._id == recetteId );
|
||||
if ( recette) {
|
||||
let competence = this.data.items.find( item => item.type =='competence' && item.name.toLowerCase() == "alchimie" );
|
||||
let diffAlchimie = RdDAlchimie.getDifficulte(alchimieData);
|
||||
let rollData = {
|
||||
recetteName: recette.name,
|
||||
competence: competence,
|
||||
diffLibre: diffAlchimie // Per default at startup
|
||||
}
|
||||
if ( alchimieName == "couleur") {
|
||||
rollData.selectedCarac = this.data.data.carac.vue,
|
||||
rollData.alchimieTexte = `Couleurs ${alchimieData} (${diffAlchimie}) (Malus de -4 si vous ne possédez pas de Cristal Alchimique)`;
|
||||
} else {
|
||||
rollData.selectedCarac = this.data.data.carac.dexterite,
|
||||
rollData.alchimieTexte = `Consistances ${alchimieData} (${diffAlchimie})`;
|
||||
}
|
||||
|
||||
const dialog = await RdDRoll.create(this, rollData,
|
||||
{ html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-alchimie.html',
|
||||
},
|
||||
{
|
||||
name: 'tache-alchimique',
|
||||
label: 'Tache Alchimique',
|
||||
callbacks: [
|
||||
this.createCallbackExperience(),
|
||||
{ action: r => this._alchimieResult(r, false) }
|
||||
]
|
||||
}
|
||||
);
|
||||
dialog.render(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_alchimieResult( rollData ) {
|
||||
RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-alchimie.html');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { RdDItemSort } from "./item-sort.js";
|
||||
import { RdDUtility } from "./rdd-utility.js";
|
||||
import { RdDItem } from "./item-rdd.js";
|
||||
import { RdDAlchimie } from "./rdd-alchimie.js";
|
||||
|
||||
/**
|
||||
* Extend the basic ItemSheet with some very simple modifications
|
||||
@ -51,6 +52,9 @@ export class RdDItemSheet extends ItemSheet {
|
||||
data.caracList = duplicate(game.system.model.Actor.personnage.carac);
|
||||
data.competenceList = await RdDUtility.getCompetenceList( 'foundryvtt-reve-de-dragon.competences' );
|
||||
}
|
||||
if ( data.item.type == 'recettealchimique' ) {
|
||||
RdDAlchimie.processManipulation(data.item, this.actor && this.actor._id );
|
||||
}
|
||||
if ( this.actor ) {
|
||||
data.isOwned = true;
|
||||
data.actorId = this.actor._id;
|
||||
@ -77,6 +81,20 @@ export class RdDItemSheet extends ItemSheet {
|
||||
let actor = game.actors.get( actorId );
|
||||
actor.creerTacheDepuisLivre( this.item );
|
||||
});
|
||||
|
||||
html.find('.alchimie-tache a').click((event) => {
|
||||
let actorId = event.currentTarget.attributes['data-actor-id'].value;
|
||||
let recetteId = event.currentTarget.attributes['data-recette-id'].value;
|
||||
let tacheName = event.currentTarget.attributes['data-alchimie-tache'].value;
|
||||
let tacheData = event.currentTarget.attributes['data-alchimie-data'].value;
|
||||
let actor = game.actors.get( actorId );
|
||||
if ( actor ) {
|
||||
actor.effectuerTacheAlchimie(recetteId, tacheName, tacheData);
|
||||
} else {
|
||||
ui.notifications.info("Impossible trouver un actur pour réaliser cette tache Alchimique.");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
66
module/rdd-alchimie.js
Normal file
66
module/rdd-alchimie.js
Normal file
@ -0,0 +1,66 @@
|
||||
/* -------------------------------------------- */
|
||||
import { Misc } from "./misc.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class RdDAlchimie {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static processManipulation( recette, actorId = undefined ) {
|
||||
//console.log("CALLED", recette, recette.isOwned, actorId );
|
||||
let manip = duplicate(recette.data.manipulation);
|
||||
let reg1 = new RegExp(/@(\w*){([\w\-]+)}/ig);
|
||||
let matchArray = manip.match( reg1 );
|
||||
for( let matchStr of matchArray) {
|
||||
let reg2 = new RegExp(/@(\w*){([\w\-]+)}/i);
|
||||
let result = matchStr.match(reg2);
|
||||
//console.log("RESULT ", result);
|
||||
if ( result[1] && result[2]) {
|
||||
let commande = Misc.upperFirst( result[1] );
|
||||
let replacement = this[`_alchimie${commande}`](recette, result[2], actorId);
|
||||
manip = manip.replace( result[0], replacement);
|
||||
}
|
||||
}
|
||||
recette.data.manipulation_update = manip;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static _alchimieCouleur( recette, couleurs, actorId ) {
|
||||
let replacement
|
||||
if ( actorId ) {
|
||||
replacement = `<span class="alchimie-tache"><a data-recette-id="${recette._id}" data-actor-id="${actorId}" data-alchimie-tache="couleur" data-alchimie-data="${couleurs}">couleur ${couleurs}</a></span>`;
|
||||
} else {
|
||||
replacement = `<span class="alchimie-tache">couleur ${couleurs} </span>`;
|
||||
}
|
||||
return replacement;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static _alchimieConsistance( recette, consistances, actorId ) {
|
||||
let replacement
|
||||
if ( actorId ) {
|
||||
replacement = `<span class="alchimie-tache"><a data-recette-id="${recette._id}" data-actor-id="${actorId}" data-alchimie-tache="consistance" data-alchimie-data="${consistances}">consistance ${consistances}</a></span>`;
|
||||
} else {
|
||||
replacement = `<span class="alchimie-tache">consistance ${consistances} </span>`;
|
||||
}
|
||||
return replacement;
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getDifficulte( aspects ) {
|
||||
let aspectsArray = aspects.split('-');
|
||||
let diff = 0;
|
||||
let nbDifferent = 0;
|
||||
let aspectsHash = {}
|
||||
for (let colconst of aspectsArray) {
|
||||
if ( aspectsHash[colconst] ){ // Deja present, augmente difficulté de 1
|
||||
diff -= 1;
|
||||
} else {
|
||||
nbDifferent++;
|
||||
aspectsHash[colconst] = colconst; // Keep track
|
||||
}
|
||||
}
|
||||
diff = diff - ((nbDifferent>1) ? nbDifferent : 0); // Ca doit marcher ....
|
||||
return Math.min(0, diff); // Pour être sur
|
||||
}
|
||||
}
|
@ -191,6 +191,7 @@ export class RdDUtility {
|
||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-enctotal.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-alchimie.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-astrologie-joueur.html',
|
||||
// Calendrier
|
||||
'systems/foundryvtt-reve-de-dragon/templates/calendar-template.html',
|
||||
@ -215,6 +216,7 @@ export class RdDUtility {
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-general.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-tache.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-sort.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-alchimie.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-summary.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-actor-competence-xp.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-actor-carac-xp.html'
|
||||
@ -270,6 +272,7 @@ export class RdDUtility {
|
||||
data.data.taches = this.checkNull(data.itemsByType['tache']);
|
||||
data.data.monnaie = this.checkNull(data.itemsByType['monnaie']);
|
||||
data.data.meditations = this.checkNull(data.itemsByType['meditation']);
|
||||
data.data.recettesAlchimiques = this.checkNull(data.itemsByType['recettealchimique']);
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -296,6 +296,12 @@ table {border: 1px solid #7a7971;}
|
||||
padding: 0 3px;
|
||||
}
|
||||
|
||||
.small-editor {
|
||||
border: 2;
|
||||
height: 150px;
|
||||
padding: 0 3px;
|
||||
}
|
||||
|
||||
.foundryvtt-reve-de-dragon .tox .tox-editor-container {
|
||||
background: #fff;
|
||||
}
|
||||
@ -503,6 +509,14 @@ section.sheet-body:after {
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
|
||||
.alchimie-tache {
|
||||
font-weight: bold;
|
||||
background: rgb(182, 180, 179);
|
||||
border: 1px solid rgba(72, 46, 28, 1);
|
||||
border-radius: 0.25rem;
|
||||
color: rgba(212, 27, 27, 0.5);
|
||||
}
|
||||
|
||||
.window-app.sheet .window-content .tooltip:hover .tooltiptext {
|
||||
top: 2rem;
|
||||
left: 2rem;
|
||||
|
@ -2,10 +2,10 @@
|
||||
"name": "foundryvtt-reve-de-dragon",
|
||||
"title": "Rêve de Dragon",
|
||||
"description": "Rêve de Dragon RPG for FoundryVTT",
|
||||
"version": "1.2.2",
|
||||
"version": "1.2.4",
|
||||
"minimumCoreVersion": "0.7.5",
|
||||
"compatibleCoreVersion": "0.7.8",
|
||||
"templateVersion": 79,
|
||||
"templateVersion": 80,
|
||||
"author": "LeRatierBretonnien",
|
||||
"esmodules": [ "module/rdd-main.js", "module/hook-renderChatLog.js" ],
|
||||
"styles": ["styles/simple.css"],
|
||||
|
@ -541,7 +541,8 @@
|
||||
}
|
||||
},
|
||||
"Item": {
|
||||
"types": ["objet", "arme", "armure", "conteneur", "competence", "sort", "herbe", "ingredient", "livre", "potion", "munition", "rencontresTMR", "queue", "ombre", "souffle", "tete", "competencecreature", "tarot", "monnaie", "nombreastral", "tache", "meditation", "casetmr" ],
|
||||
"types": ["objet", "arme", "armure", "conteneur", "competence", "sort", "herbe", "ingredient", "livre", "potion", "munition", "rencontresTMR", "queue", "ombre", "souffle",
|
||||
"tete", "competencecreature", "tarot", "monnaie", "nombreastral", "tache", "meditation", "casetmr", "recettealchimique" ],
|
||||
"objet": {
|
||||
"description": "",
|
||||
"quantite": 1,
|
||||
@ -738,6 +739,14 @@
|
||||
"label": "",
|
||||
"specific": "",
|
||||
"description": ""
|
||||
},
|
||||
"recettealchimique": {
|
||||
"but": "",
|
||||
"utilisation": "",
|
||||
"enchantement": "",
|
||||
"sureffet": "",
|
||||
"manipulation": "",
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -781,6 +781,21 @@
|
||||
<hr>
|
||||
</article>
|
||||
|
||||
<article class="flexcol">
|
||||
<h3>Recettes Alchimiques</h3>
|
||||
<ul class="item-list alterne-list">
|
||||
{{#each data.recettesAlchimiques as |recette id|}}
|
||||
<li class="item flexrow list-item" data-item-id="{{recette._id}}"><span class="competence-title recette-label item-edit"><a>{{recette.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>
|
||||
<hr>
|
||||
</article>
|
||||
|
||||
<article class="flexcol">
|
||||
<h3>Biographie : </h3>
|
||||
<div class="form-group editor">
|
||||
|
12
templates/chat-resultat-alchimie.html
Normal file
12
templates/chat-resultat-alchimie.html
Normal file
@ -0,0 +1,12 @@
|
||||
<h4>
|
||||
{{alias}} essaye de réaliser sa recette Alchimique : {{recette.name}}
|
||||
</h4>
|
||||
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.html"}}
|
||||
<hr>
|
||||
<div>
|
||||
{{#if rolled.isSuccess}}
|
||||
{{alias}} a réussi son opération alchimiue ! Il/Elle peut passer à l'étape suivante de sa recette.
|
||||
{{else}}
|
||||
{{alias}} a raté son opération Alchimique ! Sa recette est un echec.
|
||||
{{/if}}
|
||||
</div>
|
38
templates/dialog-roll-alchimie.html
Normal file
38
templates/dialog-roll-alchimie.html
Normal file
@ -0,0 +1,38 @@
|
||||
<form class="dialog-roll-sort">
|
||||
<div class="form-group">
|
||||
<ul>
|
||||
<li><label for="categorie">Recette : {{recetteName}}</label></li>
|
||||
<li><label for="categorie">Tâche Alchimique : {{alchimieTexte}}</label></li>
|
||||
<li><label for="categorie">Jet : {{selectedCarac.label}} / {{competence.name}}</label></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="categorie">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 for="categorie">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>
|
||||
<div id="tableResolution">
|
||||
</div>
|
||||
<div id="tableProbaReussite">
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
</script>
|
47
templates/item-recettealchimique-sheet.html
Normal file
47
templates/item-recettealchimique-sheet.html
Normal file
@ -0,0 +1,47 @@
|
||||
<form class="{{cssClass}}" autocomplete="off">
|
||||
<header class="sheet-header">
|
||||
<img class="profile-img" src="{{item.img}}" data-edit="img" title="{{item.name}}"/>
|
||||
<div class="header-fields">
|
||||
<h1 class="charname"><input name="name" type="text" value="{{item.name}}" placeholder="Name"/></h1>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{{!-- Sheet Body --}}
|
||||
<section class="sheet-body">
|
||||
<div class="form-group">
|
||||
<label for="xp">But</label>
|
||||
<input class="attribute-value" type="text" name="data.but" value="{{data.but}}" data-dtype="String"/>
|
||||
</div>
|
||||
<div class="flexcol">
|
||||
<span><label>Manipulation : </label></span>
|
||||
<div class="form-group small-editor">
|
||||
{{editor content=data.manipulation_update target="data.manipulation" button=true owner=owner editable=editable}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flexcol">
|
||||
<span><label>Utilisation : </label></span>
|
||||
<div class="form-group small-editor">
|
||||
{{editor content=data.utilisation target="data.utilisation" button=true owner=owner editable=editable}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flexcol">
|
||||
<span><label>Enchantement : </label></span>
|
||||
<div class="form-group small-editor">
|
||||
{{editor content=data.enchantement target="data.enchantement" button=true owner=owner editable=editable}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flexcol">
|
||||
<span><label>Sur-effet : </label></span>
|
||||
<div class="form-group small-editor">
|
||||
{{editor content=data.sureffet target="data.sureffet" button=true owner=owner editable=editable}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flexcol">
|
||||
<span><label>Notes additionnelles : </label></span>
|
||||
<div class="form-group editor">
|
||||
{{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</form>
|
Loading…
Reference in New Issue
Block a user