Fix XP
This commit is contained in:
parent
1a69116c06
commit
80725d57e1
36
css/bol.css
36
css/bol.css
@ -946,3 +946,39 @@ body.system-bol img#logo {
|
|||||||
.dialog-button {
|
.dialog-button {
|
||||||
max-height: 2rem;
|
max-height: 2rem;
|
||||||
}
|
}
|
||||||
|
.xp-next {
|
||||||
|
color: darkgrey;
|
||||||
|
font-size: 1.0rem;
|
||||||
|
border: 1px solid #4b4a44;
|
||||||
|
box-shadow: 1px 1px 1px gray;
|
||||||
|
border-radius: 100px;
|
||||||
|
width: 1.25rem;
|
||||||
|
height: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Tooltip section */
|
||||||
|
.tooltip-container {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
.tooltip-container .tooltiptext {
|
||||||
|
text-align: center;
|
||||||
|
/* Position the tooltip text */
|
||||||
|
position: absolute;
|
||||||
|
z-index: 1;
|
||||||
|
/* Fade in tooltip */
|
||||||
|
visibility: hidden;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.3s;
|
||||||
|
background-color: #f2f3a2a0;
|
||||||
|
padding: 4px;
|
||||||
|
width: 4rem;
|
||||||
|
border-radius: 25%;
|
||||||
|
border-width: 1px;
|
||||||
|
transform: translate(-40%, -60%);
|
||||||
|
}
|
||||||
|
/* Show the tooltip text when you mouse over the tooltip container */
|
||||||
|
.tooltip-container:hover .tooltiptext {
|
||||||
|
visibility: visible;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
@ -190,11 +190,11 @@ export class BoLActorSheet extends ActorSheet {
|
|||||||
*/
|
*/
|
||||||
_onRoll(event) {
|
_onRoll(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const element = event.currentTarget;
|
const element = event.currentTarget
|
||||||
const dataset = element.dataset;
|
const dataset = element.dataset
|
||||||
const actorData = this.getData();
|
const actorData = this.getData()
|
||||||
const rollType = dataset.rollType;
|
const rollType = dataset.rollType
|
||||||
const li = $(event.currentTarget).closest(".item");
|
const li = $(event.currentTarget).closest(".item")
|
||||||
switch (rollType) {
|
switch (rollType) {
|
||||||
case "attribute":
|
case "attribute":
|
||||||
BoLRoll.attributeCheck(this.actor, actorData, dataset, event);
|
BoLRoll.attributeCheck(this.actor, actorData, dataset, event);
|
||||||
@ -217,6 +217,16 @@ export class BoLActorSheet extends ActorSheet {
|
|||||||
case "damage":
|
case "damage":
|
||||||
this.actor.rollWeaponDamage(li.data("item-id"))
|
this.actor.rollWeaponDamage(li.data("item-id"))
|
||||||
break;
|
break;
|
||||||
|
case "aptitudexp":
|
||||||
|
this.actor.incAptitudeXP(dataset.key)
|
||||||
|
break;
|
||||||
|
case "attributexp":
|
||||||
|
this.actor.incAttributeXP(dataset.key)
|
||||||
|
break;
|
||||||
|
case "careerxp":
|
||||||
|
this.actor.incCareerXP( li.data("item-id"))
|
||||||
|
break;
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,54 @@ export class BoLActor extends Actor {
|
|||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
incAttributeXP( key) {
|
||||||
|
let attr = duplicate(this.data.data.attributes[key])
|
||||||
|
if (attr) {
|
||||||
|
let nextXP = (attr.value == -1) ? 2 : attr.value + (attr.value+1)
|
||||||
|
let xp = duplicate(this.data.data.xp)
|
||||||
|
if ( xp.total - xp.spent >= nextXP) {
|
||||||
|
attr.value += 1
|
||||||
|
xp.spent += nextXP
|
||||||
|
this.update( { [`data.attributes.${key}`]: attr, [`data.xp`]: xp } )
|
||||||
|
} else {
|
||||||
|
ui.notifications.warn("Pas assez de points d'expérience !")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
incAptitudeXP( key) {
|
||||||
|
let apt = duplicate(this.data.data.aptitudes[key])
|
||||||
|
if (apt) {
|
||||||
|
let nextXP = (apt.value == -1) ? 1 : apt.value + 2
|
||||||
|
let xp = duplicate(this.data.data.xp)
|
||||||
|
if ( xp.total - xp.spent >= nextXP) {
|
||||||
|
apt.value += 1
|
||||||
|
xp.spent += nextXP
|
||||||
|
this.update( { [`data.aptitudes.${key}`]: apt, [`data.xp`]: xp } )
|
||||||
|
} else {
|
||||||
|
ui.notifications.warn("Pas assez de points d'expérience !")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
incCareerXP( itemId) {
|
||||||
|
let career = this.data.items.get( itemId )
|
||||||
|
if (career) {
|
||||||
|
career = duplicate(career)
|
||||||
|
let nextXP = career.data.rank + 1
|
||||||
|
let xp = duplicate(this.data.data.xp)
|
||||||
|
if ( xp.total - xp.spent >= nextXP) {
|
||||||
|
xp.spent += nextXP
|
||||||
|
this.update( { [`data.xp`]: xp } )
|
||||||
|
this.updateEmbeddedDocuments( 'Item', [ { _id: career._id, 'data.rank': career.data.rank + 1 } ])
|
||||||
|
} else {
|
||||||
|
ui.notifications.warn("Pas assez de points d'expérience !")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async toggleFightOption( itemId) {
|
async toggleFightOption( itemId) {
|
||||||
let fightOption = this.data.items.get(itemId)
|
let fightOption = this.data.items.get(itemId)
|
||||||
|
@ -39,53 +39,49 @@ export const registerHandlebarsHelpers = function () {
|
|||||||
|
|
||||||
Handlebars.registerHelper('gt', function (val1, val2) {
|
Handlebars.registerHelper('gt', function (val1, val2) {
|
||||||
return val1 > val2;
|
return val1 > val2;
|
||||||
});
|
})
|
||||||
|
|
||||||
Handlebars.registerHelper('lt', function (val1, val2) {
|
Handlebars.registerHelper('lt', function (val1, val2) {
|
||||||
return val1 < val2;
|
return val1 < val2;
|
||||||
});
|
})
|
||||||
|
|
||||||
Handlebars.registerHelper('gte', function (val1, val2) {
|
Handlebars.registerHelper('gte', function (val1, val2) {
|
||||||
return val1 >= val2;
|
return val1 >= val2;
|
||||||
});
|
})
|
||||||
|
|
||||||
Handlebars.registerHelper('lte', function (val1, val2) {
|
Handlebars.registerHelper('lte', function (val1, val2) {
|
||||||
return val1 <= val2;
|
return val1 <= val2;
|
||||||
});
|
})
|
||||||
Handlebars.registerHelper('and', function (val1, val2) {
|
Handlebars.registerHelper('and', function (val1, val2) {
|
||||||
return val1 && val2;
|
return val1 && val2;
|
||||||
});
|
})
|
||||||
|
|
||||||
Handlebars.registerHelper('or', function (val1, val2) {
|
Handlebars.registerHelper('or', function (val1, val2) {
|
||||||
return val1 || val2;
|
return val1 || val2;
|
||||||
});
|
})
|
||||||
|
|
||||||
Handlebars.registerHelper('or3', function (val1, val2, val3) {
|
Handlebars.registerHelper('or3', function (val1, val2, val3) {
|
||||||
return val1 || val2 || val3;
|
return val1 || val2 || val3;
|
||||||
});
|
})
|
||||||
|
|
||||||
Handlebars.registerHelper('for', function(from, to, incr, block) {
|
Handlebars.registerHelper('for', function(from, to, incr, block) {
|
||||||
var accum = '';
|
var accum = '';
|
||||||
for(var i = from; i < to; i += incr)
|
for(var i = from; i < to; i += incr)
|
||||||
accum += block.fn(i);
|
accum += block.fn(i);
|
||||||
return accum;
|
return accum;
|
||||||
});
|
})
|
||||||
|
|
||||||
Handlebars.registerHelper('not', function (cond) {
|
Handlebars.registerHelper('not', function (cond) {
|
||||||
return !cond;
|
return !cond;
|
||||||
});
|
})
|
||||||
|
|
||||||
Handlebars.registerHelper('count', function (list) {
|
Handlebars.registerHelper('count', function (list) {
|
||||||
return list.length;
|
return list.length;
|
||||||
});
|
})
|
||||||
|
|
||||||
Handlebars.registerHelper('isEnabled', function (configKey) {
|
Handlebars.registerHelper('isEnabled', function (configKey) {
|
||||||
return game.settings.get("bol", configKey);
|
return game.settings.get("bol", configKey);
|
||||||
});
|
})
|
||||||
|
|
||||||
Handlebars.registerHelper('split', function (str, separator, keep) {
|
Handlebars.registerHelper('split', function (str, separator, keep) {
|
||||||
return str.split(separator)[keep];
|
return str.split(separator)[keep];
|
||||||
});
|
})
|
||||||
|
|
||||||
// If you need to add Handlebars helpers, here are a few useful examples:
|
// If you need to add Handlebars helpers, here are a few useful examples:
|
||||||
Handlebars.registerHelper('concat', function () {
|
Handlebars.registerHelper('concat', function () {
|
||||||
@ -96,32 +92,30 @@ export const registerHandlebarsHelpers = function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return outStr;
|
return outStr;
|
||||||
});
|
})
|
||||||
|
|
||||||
Handlebars.registerHelper('add', function (a, b) {
|
Handlebars.registerHelper('add', function (a, b) {
|
||||||
return parseInt(a) + parseInt(b);
|
return parseInt(a) + parseInt(b);
|
||||||
});
|
});
|
||||||
|
Handlebars.registerHelper('mul', function (a, b) {
|
||||||
|
return parseInt(a) * parseInt(b);
|
||||||
|
})
|
||||||
Handlebars.registerHelper('sub', function (a, b) {
|
Handlebars.registerHelper('sub', function (a, b) {
|
||||||
return parseInt(a) - parseInt(b);
|
return parseInt(a) - parseInt(b);
|
||||||
});
|
})
|
||||||
|
|
||||||
Handlebars.registerHelper('valueAtIndex', function (arr, idx) {
|
Handlebars.registerHelper('valueAtIndex', function (arr, idx) {
|
||||||
return arr[idx];
|
return arr[idx];
|
||||||
});
|
})
|
||||||
|
|
||||||
Handlebars.registerHelper('includesKey', function (items, type, key) {
|
Handlebars.registerHelper('includesKey', function (items, type, key) {
|
||||||
// console.log(items);
|
// console.log(items);
|
||||||
return items.filter(i => i.type === type).map(i => i.data.key).includes(key);
|
return items.filter(i => i.type === type).map(i => i.data.key).includes(key);
|
||||||
});
|
})
|
||||||
|
|
||||||
Handlebars.registerHelper('includes', function (array, val) {
|
Handlebars.registerHelper('includes', function (array, val) {
|
||||||
return array.includes(val);
|
return array.includes(val);
|
||||||
});
|
})
|
||||||
|
|
||||||
Handlebars.registerHelper('eval', function (expr) {
|
Handlebars.registerHelper('eval', function (expr) {
|
||||||
return eval(expr);
|
return eval(expr);
|
||||||
});
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"url": "https://github.com/ZigmundKreud/bol",
|
"url": "https://github.com/ZigmundKreud/bol",
|
||||||
"license": "LICENSE.txt",
|
"license": "LICENSE.txt",
|
||||||
"flags": {},
|
"flags": {},
|
||||||
"version": "1.2.1",
|
"version": "1.2.2",
|
||||||
"templateVersion": 22,
|
"templateVersion": 22,
|
||||||
"minimumCoreVersion": "0.8.6",
|
"minimumCoreVersion": "0.8.6",
|
||||||
"compatibleCoreVersion": "9",
|
"compatibleCoreVersion": "9",
|
||||||
|
@ -19,6 +19,18 @@
|
|||||||
<a class="inc-dec-btns" data-operator="minus" data-target="data.rank" data-incr="1" data-min="0" data-max="5"><i class="fas fa-minus-square"></i></a>
|
<a class="inc-dec-btns" data-operator="minus" data-target="data.rank" data-incr="1" data-min="0" data-max="5"><i class="fas fa-minus-square"></i></a>
|
||||||
<span class="item-field">{{item.data.rank}}</span>
|
<span class="item-field">{{item.data.rank}}</span>
|
||||||
<a class="inc-dec-btns" data-operator="plus" data-target="data.rank" data-incr="1" data-min="0" data-max="5"><i class="fas fa-plus-square"></i></a>
|
<a class="inc-dec-btns" data-operator="plus" data-target="data.rank" data-incr="1" data-min="0" data-max="5"><i class="fas fa-plus-square"></i></a>
|
||||||
|
<span class="item-field"> </span>
|
||||||
|
<span class="tooltip-container">
|
||||||
|
<span class="stat-roll rollable" title="XP" data-roll-type="careerxp" data-key="{{key}}">
|
||||||
|
<i class="xp-next fas fa-arrow-up"></i></span>
|
||||||
|
<span class="tooltiptext">
|
||||||
|
{{#if (eq data.rank 0)}}
|
||||||
|
1 XP
|
||||||
|
{{else}}
|
||||||
|
{{add data.rank 1}} XP
|
||||||
|
{{/if}}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
<div class="item-field flex1 right">
|
<div class="item-field flex1 right">
|
||||||
|
@ -3,9 +3,20 @@
|
|||||||
<div class="attribute stat flex1 flex-group-center {{key}}">
|
<div class="attribute stat flex1 flex-group-center {{key}}">
|
||||||
<label class="stat-label"><a class="rollable" data-roll-type="attribute" data-roll="2d6+@attributes.{{key}}.value" data-adv="0" data-key="{{key}}">{{localize label}}</a></label><br/>
|
<label class="stat-label"><a class="rollable" data-roll-type="attribute" data-roll="2d6+@attributes.{{key}}.value" data-adv="0" data-key="{{key}}">{{localize label}}</a></label><br/>
|
||||||
<input class="stat-value rounded" type="text" name="data.attributes.{{key}}.value" value="{{numberFormat value decimals=0 sign=true}}" data-dtype="Number"/><br/>
|
<input class="stat-value rounded" type="text" name="data.attributes.{{key}}.value" value="{{numberFormat value decimals=0 sign=true}}" data-dtype="Number"/><br/>
|
||||||
<span class="stat-roll malus rollable" title="2d6M" data-roll-type="attribute" data-roll="3d6kh2+@attributes.{{key}}.value" data-adv="-1" data-key="{{key}}"><i class="fas fa-dice"></i></span>
|
<span class="stat-roll rollable" title="2d6" data-roll-type="attribute" data-roll="2d6+@attributes.{{key}}.value" data-adv="0" data-key="{{key}}">
|
||||||
<span class="stat-roll rollable" title="2d6" data-roll-type="attribute" data-roll="2d6+@attributes.{{key}}.value" data-adv="0" data-key="{{key}}"><i class="fas fa-dice"></i></span>
|
<i class="darkgreen fas fa-dice"></i>
|
||||||
<span class="stat-roll bonus rollable" title="2d6B" data-roll-type="attribute" data-roll="3d6kl2+@attributes.{{key}}.value" data-adv="1" data-key="{{key}}"><i class="fas fa-dice"></i></span>
|
</span>
|
||||||
|
<span class="tooltip-container">
|
||||||
|
<span class="stat-roll rollable" title="XP" data-roll-type="attributexp" data-key="{{key}}">
|
||||||
|
<i class="xp-next fas fa-arrow-up"></i></span>
|
||||||
|
<span class="tooltiptext">
|
||||||
|
{{#if (eq value -1)}}
|
||||||
|
2 XP
|
||||||
|
{{else}}
|
||||||
|
{{add value (add value 1)}} XP
|
||||||
|
{{/if}}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
@ -15,9 +26,20 @@
|
|||||||
<div class="aptitude stat flex1 flex-group-center">
|
<div class="aptitude stat flex1 flex-group-center">
|
||||||
<label class="stat-label"><a class="rollable" data-roll-type="aptitude" data-roll="2d6+@aptitudes.{{key}}.value" data-adv="0" data-key="{{key}}">{{localize label}}</a></label><br/>
|
<label class="stat-label"><a class="rollable" data-roll-type="aptitude" data-roll="2d6+@aptitudes.{{key}}.value" data-adv="0" data-key="{{key}}">{{localize label}}</a></label><br/>
|
||||||
<input class="stat-value rounded-border" type="text" name="data.aptitudes.{{key}}.value" value="{{numberFormat value decimals=0 sign=true}}" data-dtype="Number"/><br/>
|
<input class="stat-value rounded-border" type="text" name="data.aptitudes.{{key}}.value" value="{{numberFormat value decimals=0 sign=true}}" data-dtype="Number"/><br/>
|
||||||
<span class="stat-roll malus rollable" title="2d6M" data-roll-type="aptitude" data-roll="3d6kh2+@aptitudes.{{key}}.value" data-adv="-1" data-key="{{key}}"><i class="fas fa-dice"></i></span>
|
<span class="stat-roll rollable" title="2d6" data-roll-type="aptitude" data-roll="2d6+@aptitudes.{{key}}.value" data-adv="0" data-key="{{key}}">
|
||||||
<span class="stat-roll rollable" title="2d6" data-roll-type="aptitude" data-roll="2d6+@aptitudes.{{key}}.value" data-adv="0" data-key="{{key}}"><i class="fas fa-dice"></i></span>
|
<i class="darkgreen fas fa-dice"></i>
|
||||||
<span class="stat-roll bonus rollable" title="2d6B" data-roll-type="aptitude" data-roll="3d6kl2+@aptitudes.{{key}}.value" data-adv="1" data-key="{{key}}"><i class="fas fa-dice"></i></span>
|
</span>
|
||||||
|
<span class="tooltip-container">
|
||||||
|
<span class="stat-roll rollable" title="XP" data-roll-type="aptitudexp" data-key="{{key}}">
|
||||||
|
<i class="xp-next fas fa-arrow-up"></i></span>
|
||||||
|
<span class="tooltiptext">
|
||||||
|
{{#if (eq value -1)}}
|
||||||
|
1 XP
|
||||||
|
{{else}}
|
||||||
|
{{add value 2}} XP
|
||||||
|
{{/if}}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user