XP fix avec tooltip
This commit is contained in:
parent
b69c515a7c
commit
4f236adbec
@ -46,8 +46,9 @@ export class RdDActorSheet extends ActorSheet {
|
||||
data.itemsByType.competence,
|
||||
item => item.data.categorie,
|
||||
item => {
|
||||
item.data.isLevelUp = item.data.xp >= RdDItemCompetence.getCompetenceNextXp(item.data.niveau); // Flag de niveau à MAJ
|
||||
this.actor.checkCompetenceXP(item.name); // Petite vérification experience
|
||||
item.data.xpNext = RdDItemCompetence.getCompetenceNextXp(item.data.niveau);
|
||||
item.data.isLevelUp = item.data.xp >= item.data.xpNext; // Flag de niveau à MAJ
|
||||
//this.actor.checkCompetenceXP(item.name); // Petite vérification experience
|
||||
item.data.showCompetence = !data.data.showCompNiveauBase || (Number(item.data.niveau) != Number(RdDUtility.getLevelCategory(item.data.categorie)));
|
||||
// Ignorer les compétences 'troncs' à ce stade
|
||||
competenceXPTotal += RdDItemCompetence.isTronc(item.name) ? 0 : RdDItemCompetence.computeCompetenceXPCost(item);
|
||||
@ -63,7 +64,8 @@ export class RdDActorSheet extends ActorSheet {
|
||||
if (!currentCarac.derivee) {
|
||||
sum += parseInt(currentCarac.value);
|
||||
}
|
||||
currentCarac.isLevelUp = (currentCarac.xp >= RdDUtility.getCaracNextXp(currentCarac.value));
|
||||
currentCarac.xpNext = RdDUtility.getCaracNextXp(currentCarac.value);
|
||||
currentCarac.isLevelUp = (currentCarac.xp >= currentCarac.xpNext);
|
||||
}
|
||||
data.data.caracSum = sum;
|
||||
|
||||
@ -512,7 +514,6 @@ export class RdDActorSheet extends ActorSheet {
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/** @override */
|
||||
setPosition(options = {}) {
|
||||
const position = super.setPosition(options);
|
||||
@ -524,7 +525,6 @@ export class RdDActorSheet extends ActorSheet {
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/** @override */
|
||||
_updateObject(event, formData) {
|
||||
// Update the Actor
|
||||
|
@ -621,6 +621,7 @@ export class RdDActor extends Actor {
|
||||
async updateCompetenceXP(compName, compValue) {
|
||||
let comp = this.getCompetence(compName);
|
||||
if (comp) {
|
||||
this.checkCompetenceXP(compName, compValue);
|
||||
const update = { _id: comp._id, 'data.xp': compValue };
|
||||
const updated = await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity
|
||||
} else {
|
||||
@ -1461,13 +1462,18 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async checkCompetenceXP(compName) {
|
||||
async checkCompetenceXP(compName, newXP = undefined) {
|
||||
let competence = RdDItemCompetence.findCompetence(this.data.items, compName);
|
||||
if (competence && competence.data.xp > 0) {
|
||||
if ( competence && newXP && newXP == competence.data.xp ) { // Si édition, mais sans changement XP
|
||||
return;
|
||||
}
|
||||
newXP = (newXP) ? newXP : competence.data.xp;
|
||||
if (competence && newXP > 0) {
|
||||
let xpNeeded = RdDItemCompetence.getCompetenceNextXp(competence.data.niveau);
|
||||
if (competence.data.xp >= xpNeeded) {
|
||||
if (newXP >= xpNeeded) {
|
||||
let newCompetence = duplicate(competence);
|
||||
newCompetence.data.niveau += 1;
|
||||
newCompetence.data.xp = newXP;
|
||||
|
||||
let xpData = {
|
||||
alias: this.name,
|
||||
@ -2698,4 +2704,12 @@ export class RdDActor extends Actor {
|
||||
await this.createEmbeddedEntity('ActiveEffect', effet, options);
|
||||
this.applyActiveEffects();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateEmbeddedEntity(embeddedName, data, options) {
|
||||
if ( data && data['data.defaut_carac'] && data['data.xp'] ) { // C'est une compétence
|
||||
this.checkCompetenceXP(data['name'], data['data.xp'] );
|
||||
}
|
||||
return super.updateEmbeddedEntity(embeddedName, data, options);
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,6 @@ export class RdDItemSheet extends ItemSheet {
|
||||
|
||||
/** @override */
|
||||
_updateObject(event, formData) {
|
||||
|
||||
// Données de bonus de cases ?
|
||||
formData = RdDItemSort.buildBonusCaseStringFromFormData( formData );
|
||||
|
||||
|
@ -362,7 +362,7 @@ export class RdDUtility {
|
||||
//console.log("OBJ:", objet);
|
||||
let str = Handlebars.partials['systems/foundryvtt-reve-de-dragon/templates/actor-inventaire-conteneur.html']({ item: objet });
|
||||
if (objet.type == 'conteneur') {
|
||||
console.log("ITEM DISPLAYED", objet );
|
||||
//console.log("ITEM DISPLAYED", objet );
|
||||
if (this.getAfficheContenu(objet._id)) {
|
||||
str = str + "<ul class='item-list alterne-list item-display-show list-item-margin" + niveau + "'>";
|
||||
} else {
|
||||
|
@ -1297,6 +1297,17 @@ display: inline-flex;
|
||||
padding: 3px 0;
|
||||
}
|
||||
|
||||
.tooltip-nobottom {
|
||||
border-bottom: unset; /* If you want dots under the hoverable text */
|
||||
}
|
||||
.tooltip .ttt-xp {
|
||||
width: 250px;
|
||||
background: rgba(220,220,210,0.95);
|
||||
border-radius: 6px;
|
||||
font-size: 0.9rem;
|
||||
padding: 3px 0;
|
||||
}
|
||||
|
||||
/* Show the tooltip text when you mouse over the tooltip container */
|
||||
.tooltip:hover .tooltiptext {
|
||||
visibility: visible;
|
||||
|
@ -2,7 +2,7 @@
|
||||
"name": "foundryvtt-reve-de-dragon",
|
||||
"title": "Rêve de Dragon",
|
||||
"description": "Rêve de Dragon RPG for FoundryVTT",
|
||||
"version": "1.2.19",
|
||||
"version": "1.2.20",
|
||||
"manifestPlusVersion": "1.0.0",
|
||||
"minimumCoreVersion": "0.7.5",
|
||||
"compatibleCoreVersion": "0.7.8",
|
||||
|
@ -132,7 +132,15 @@
|
||||
<label class="competence-value flexrow">{{carac.value}}</label>
|
||||
<label class="carac-xp flexrow"/>
|
||||
{{else}}
|
||||
<span class="carac-label flexrow" name="data.carac.{{key}}.label"><a name={{key}}>{{carac.label}}</a></span>
|
||||
{{#if carac.isLevelUp}}
|
||||
<span class="carac-label flexrow tooltip tooltip-nobottom" name="data.carac.{{key}}.label">
|
||||
<span class="tooltiptext ttt-xp">
|
||||
Vous pouvez dépenser {{carac.xpNext}} points d'Experience pour augmenter de 1 votre caractéristique {{carac.label}}
|
||||
</span>
|
||||
<a name={{key}}>{{carac.label}}</a></span>
|
||||
{{else}}
|
||||
<span class="carac-label flexrow tooltip tooltip-nobottom" name="data.carac.{{key}}.label"><a name={{key}}>{{carac.label}}</a></span>
|
||||
{{/if}}
|
||||
<input class="carac-value flexrow" type="text" name="data.carac.{{key}}.value" value="{{carac.value}}" data-dtype="{{carac.type}}" {{#unless @root.data.editCaracComp}}disabled{{/unless}} />
|
||||
<input class="carac-xp flexrow" type="text" name="data.carac.{{key}}.xp" value="{{carac.xp}}" data-dtype="number" {{#unless @root.data.editCaracComp}}disabled{{/unless}} />
|
||||
{{/if}}
|
||||
@ -228,7 +236,15 @@
|
||||
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
|
||||
{{/if}}
|
||||
<img class="sheet-competence-img" src="{{comp.img}}"/>
|
||||
{{#if comp.data.isLevelUp}}
|
||||
<span class="competence-label tooltip tooltip-nobottom">
|
||||
<span class="tooltiptext ttt-xp">
|
||||
Vous pouvez dépenser {{comp.data.xpNext}} points d'Experience pour augmenter de 1 votre compétence {{comp.name}}
|
||||
</span>
|
||||
<a name={{key}}>{{comp.name}}</a></span>
|
||||
{{else}}
|
||||
<span class="competence-label"><a>{{comp.name}}</a></span>
|
||||
{{/if}}
|
||||
<input class="competence-value" type="text" compname="{{comp.name}}" value="{{numberFormat comp.data.niveau decimals=0 sign=true}}" data-dtype="number" {{#unless @root.data.editCaracComp}}disabled{{/unless}}/>
|
||||
<input class="competence-xp" type="text" compname="{{comp.name}}" value="{{comp.data.xp}}" data-dtype="number" {{#unless @root.data.editCaracComp}}disabled{{/unless}}/>
|
||||
<div class="item-controls">
|
||||
@ -255,7 +271,15 @@
|
||||
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
|
||||
{{/if}}
|
||||
<img class="sheet-competence-img" src="{{comp.img}}"/>
|
||||
{{#if comp.data.isLevelUp}}
|
||||
<span class="competence-label tooltip tooltip-nobottom">
|
||||
<span class="tooltiptext ttt-xp">
|
||||
Vous pouvez dépenser {{comp.data.xpNext}} points d'Experience pour augmenter de 1 votre compétence {{comp.name}}
|
||||
</span>
|
||||
<a name={{key}}>{{comp.name}}</a></span>
|
||||
{{else}}
|
||||
<span class="competence-label"><a>{{comp.name}}</a></span>
|
||||
{{/if}}
|
||||
<input class="competence-value" type="text" compname="{{comp.name}}" value="{{numberFormat comp.data.niveau decimals=0 sign=true}}" data-dtype="number" {{#unless @root.data.editCaracComp}}disabled{{/unless}}/>
|
||||
<input class="competence-xp" type="text" compname="{{comp.name}}" value="{{comp.data.xp}}" data-dtype="number" {{#unless @root.data.editCaracComp}}disabled{{/unless}}/>
|
||||
<div class="item-controls">
|
||||
@ -281,7 +305,15 @@
|
||||
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
|
||||
{{/if}}
|
||||
<img class="sheet-competence-img" src="{{comp.img}}"/>
|
||||
{{#if comp.data.isLevelUp}}
|
||||
<span class="competence-label tooltip tooltip-nobottom">
|
||||
<span class="tooltiptext ttt-xp">
|
||||
Vous pouvez dépenser {{comp.data.xpNext}} points d'Experience pour augmenter de 1 votre compétence {{comp.name}}
|
||||
</span>
|
||||
<a name={{key}}>{{comp.name}}</a></span>
|
||||
{{else}}
|
||||
<span class="competence-label"><a>{{comp.name}}</a></span>
|
||||
{{/if}}
|
||||
<input class="competence-value" type="text" compname="{{comp.name}}" value="{{numberFormat comp.data.niveau decimals=0 sign=true}}" data-dtype="number" {{#unless @root.data.editCaracComp}}disabled{{/unless}}/>
|
||||
<input class="competence-xp" type="text" compname="{{comp.name}}" value="{{comp.data.xp}}" data-dtype="number" {{#unless @root.data.editCaracComp}}disabled{{/unless}}/>
|
||||
<div class="item-controls">
|
||||
@ -310,7 +342,15 @@
|
||||
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
|
||||
{{/if}}
|
||||
<img class="sheet-competence-img" src="{{comp.img}}"/>
|
||||
{{#if comp.data.isLevelUp}}
|
||||
<span class="competence-label tooltip tooltip-nobottom">
|
||||
<span class="tooltiptext ttt-xp">
|
||||
Vous pouvez dépenser {{comp.data.xpNext}} points d'Experience pour augmenter de 1 votre compétence {{comp.name}}
|
||||
</span>
|
||||
<a name={{key}}>{{comp.name}}</a></span>
|
||||
{{else}}
|
||||
<span class="competence-label"><a>{{comp.name}}</a></span>
|
||||
{{/if}}
|
||||
<input class="competence-value" type="text" compname="{{comp.name}}" value="{{numberFormat comp.data.niveau decimals=0 sign=true}}" data-dtype="number" {{#unless @root.data.editCaracComp}}disabled{{/unless}}/>
|
||||
<input class="competence-xp" type="text" name="data.competenceByCategory.melee[{{key}}].data.xp" compname="{{comp.name}}" value="{{comp.data.xp}}" data-dtype="number" {{#unless @root.data.editCaracComp}}disabled{{/unless}}/>
|
||||
<div class="item-controls">
|
||||
@ -337,7 +377,15 @@
|
||||
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
|
||||
{{/if}}
|
||||
<img class="sheet-competence-img" src="{{comp.img}}"/>
|
||||
{{#if comp.data.isLevelUp}}
|
||||
<span class="competence-label tooltip tooltip-nobottom">
|
||||
<span class="tooltiptext ttt-xp">
|
||||
Vous pouvez dépenser {{comp.data.xpNext}} points d'Experience pour augmenter de 1 votre compétence {{comp.name}}
|
||||
</span>
|
||||
<a name={{key}}>{{comp.name}}</a></span>
|
||||
{{else}}
|
||||
<span class="competence-label"><a>{{comp.name}}</a></span>
|
||||
{{/if}}
|
||||
<input class="competence-value" type="text" compname="{{comp.name}}" value="{{numberFormat comp.data.niveau decimals=0 sign=true}}" data-dtype="number" {{#unless @root.data.editCaracComp}}disabled{{/unless}}/>
|
||||
<input class="competence-xp" type="text" name="data.competenceByCategory.tir[{{key}}].data.xp" compname="{{comp.name}}" value="{{comp.data.xp}}" data-dtype="number" {{#unless @root.data.editCaracComp}}disabled{{/unless}}/>
|
||||
<div class="item-controls">
|
||||
@ -364,7 +412,15 @@
|
||||
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
|
||||
{{/if}}
|
||||
<img class="sheet-competence-img" src="{{comp.img}}"/>
|
||||
{{#if comp.data.isLevelUp}}
|
||||
<span class="competence-label tooltip tooltip-nobottom">
|
||||
<span class="tooltiptext ttt-xp">
|
||||
Vous pouvez dépenser {{comp.data.xpNext}} points d'Experience pour augmenter de 1 votre compétence {{comp.name}}
|
||||
</span>
|
||||
<a name={{key}}>{{comp.name}}</a></span>
|
||||
{{else}}
|
||||
<span class="competence-label"><a>{{comp.name}}</a></span>
|
||||
{{/if}}
|
||||
<input class="competence-value" type="text" compname="{{comp.name}}" value="{{numberFormat comp.data.niveau decimals=0 sign=true}}" data-dtype="number"{{#unless @root.data.editCaracComp}}disabled{{/unless}}/>
|
||||
<input class="competence-xp" type="text" name="data.competenceByCategory.lancer[{{key}}].data.xp" compname="{{comp.name}}" value="{{comp.data.xp}}" data-dtype="number" {{#unless @root.data.editCaracComp}}disabled{{/unless}}/>
|
||||
<div class="item-controls">
|
||||
@ -391,7 +447,15 @@
|
||||
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
|
||||
{{/if}}
|
||||
<img class="sheet-competence-img" src="{{comp.img}}"/>
|
||||
{{#if comp.data.isLevelUp}}
|
||||
<span class="competence-label tooltip tooltip-nobottom">
|
||||
<span class="tooltiptext ttt-xp">
|
||||
Vous pouvez dépenser {{comp.data.xpNext}} points d'Experience pour augmenter de 1 votre compétence {{comp.name}}
|
||||
</span>
|
||||
<a name={{key}}>{{comp.name}}</a></span>
|
||||
{{else}}
|
||||
<span class="competence-label"><a>{{comp.name}}</a></span>
|
||||
{{/if}}
|
||||
<input class="competence-value" type="text" compname="{{comp.name}}" value="{{numberFormat comp.data.niveau decimals=0 sign=true}}" data-dtype="number" {{#unless @root.data.editCaracComp}}disabled{{/unless}}/>
|
||||
<input class="competence-xp" type="text" name="data.competenceByCategory.connaissance[{{key}}].data.xp" compname="{{comp.name}}" value="{{comp.data.xp}}" data-dtype="number" {{#unless @root.data.editCaracComp}}disabled{{/unless}}/>
|
||||
<div class="item-controls">
|
||||
@ -418,7 +482,15 @@
|
||||
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
|
||||
{{/if}}
|
||||
<img class="sheet-competence-img" src="{{comp.img}}"/>
|
||||
{{#if comp.data.isLevelUp}}
|
||||
<span class="competence-label tooltip tooltip-nobottom">
|
||||
<span class="tooltiptext ttt-xp">
|
||||
Vous pouvez dépenser {{comp.data.xpNext}} points d'Experience pour augmenter de 1 votre compétence {{comp.name}}
|
||||
</span>
|
||||
<a name={{key}}>{{comp.name}}</a></span>
|
||||
{{else}}
|
||||
<span class="competence-label"><a>{{comp.name}}</a></span>
|
||||
{{/if}}
|
||||
<input class="competence-value" type="text" compname="{{comp.name}}" value="{{numberFormat comp.data.niveau decimals=0 sign=true}}" data-dtype="number" {{#unless @root.data.editCaracComp}}disabled{{/unless}}/>
|
||||
<input class="competence-xp" type="text" name="data.competenceByCategory.draconic[{{key}}].data.xp" compname="{{comp.name}}" value="{{comp.data.xp}}" data-dtype="number" {{#unless @root.data.editCaracComp}}disabled{{/unless}}/>
|
||||
<input class="competence-xp-sort" type="text" name="data.competenceByCategory.draconic[{{key}}].data.xp_sort" compname="{{comp.name}}" value="{{comp.data.xp_sort}}" data-dtype="number" {{#unless @root.data.editCaracComp}}disabled{{/unless}}/>
|
||||
|
Loading…
Reference in New Issue
Block a user