This commit is contained in:
sladecraven 2022-03-20 23:17:52 +01:00
parent 1a69116c06
commit 80725d57e1
7 changed files with 190 additions and 68 deletions

View File

@ -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;
}

View File

@ -2,7 +2,7 @@
* Extend the basic ActorSheet with some very simple modifications * Extend the basic ActorSheet with some very simple modifications
* @extends {ActorSheet} * @extends {ActorSheet}
*/ */
import {BoLRoll} from "../controllers/bol-rolls.js"; import { BoLRoll } from "../controllers/bol-rolls.js";
import { BoLUtility } from "../system/bol-utility.js"; import { BoLUtility } from "../system/bol-utility.js";
export class BoLActorSheet extends ActorSheet { export class BoLActorSheet extends ActorSheet {
@ -45,20 +45,20 @@ export class BoLActorSheet extends ActorSheet {
html.find(".toggle-fight-option").click((ev) => { html.find(".toggle-fight-option").click((ev) => {
const li = $(ev.currentTarget).parents(".item") const li = $(ev.currentTarget).parents(".item")
this.actor.toggleFightOption( li.data("itemId") ) this.actor.toggleFightOption(li.data("itemId"))
}) })
html.find(".inc-dec-btns-alchemy").click((ev) => { html.find(".inc-dec-btns-alchemy").click((ev) => {
const li = $(ev.currentTarget).parents(".item"); const li = $(ev.currentTarget).parents(".item");
this.actor.spendAlchemyPoint( li.data("itemId"), 1) this.actor.spendAlchemyPoint(li.data("itemId"), 1)
}) })
// Incr./Decr. career ranks // Incr./Decr. career ranks
html.find(".inc-dec-btns").click((ev) => { html.find(".inc-dec-btns").click((ev) => {
const li = $(ev.currentTarget).parents(".item"); const li = $(ev.currentTarget).parents(".item");
if(li){ if (li) {
const item = this.actor.items.get(li.data("itemId")); const item = this.actor.items.get(li.data("itemId"));
if(item){ if (item) {
const dataset = ev.currentTarget.dataset; const dataset = ev.currentTarget.dataset;
const operator = dataset.operator; const operator = dataset.operator;
const target = dataset.target; const target = dataset.target;
@ -66,18 +66,18 @@ export class BoLActorSheet extends ActorSheet {
const min = parseInt(dataset.min) const min = parseInt(dataset.min)
const max = parseInt(dataset.max) || 10000 const max = parseInt(dataset.max) || 10000
const itemData = item.data; const itemData = item.data;
let value = eval("itemData."+target) let value = eval("itemData." + target)
value = value || 0 value = value || 0
console.log("IncDec", item, target, value, operator, min, max) console.log("IncDec", item, target, value, operator, min, max)
if(operator === "minus"){ if (operator === "minus") {
if(value >= min + incr) value -= incr; if (value >= min + incr) value -= incr;
else value = min; else value = min;
} }
if(operator === "plus") { if (operator === "plus") {
if(value <= max - incr) value += incr; if (value <= max - incr) value += incr;
else value = max; else value = max;
} }
let update = { [`${target}`]: value}; let update = { [`${target}`]: value };
item.update(update); item.update(update);
} }
} }
@ -94,7 +94,7 @@ export class BoLActorSheet extends ActorSheet {
this.actor.deleteEmbeddedDocuments("Item", [li.data("itemId")]) this.actor.deleteEmbeddedDocuments("Item", [li.data("itemId")])
li.slideUp(200, () => this.render(false)); li.slideUp(200, () => this.render(false));
}, },
no: () => {}, no: () => { },
defaultYes: false, defaultYes: false,
}); });
}); });
@ -133,9 +133,9 @@ export class BoLActorSheet extends ActorSheet {
formData.combat = this.actor.buildCombat() formData.combat = this.actor.buildCombat()
formData.features = this.actor.buildFeatures() formData.features = this.actor.buildFeatures()
formData.isGM = game.user.isGM formData.isGM = game.user.isGM
formData.options= this.options formData.options = this.options
formData.owner= this.document.isOwner formData.owner = this.document.isOwner
formData.editScore= this.options.editScore formData.editScore = this.options.editScore
formData.useBougette = BoLUtility.getUseBougette() formData.useBougette = BoLUtility.getUseBougette()
formData.isSorcerer = this.actor.isSorcerer() formData.isSorcerer = this.actor.isSorcerer()
@ -190,16 +190,16 @@ 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);
break; break;
case "aptitude" : case "aptitude":
BoLRoll.aptitudeCheck(this.actor, actorData, dataset, event); BoLRoll.aptitudeCheck(this.actor, actorData, dataset, event);
break; break;
case "weapon": case "weapon":
@ -217,7 +217,17 @@ 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;
default : 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;
} }
} }

View File

@ -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)

View File

@ -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);
}); })

View File

@ -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",

View File

@ -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>&nbsp; <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>&nbsp;
<span class="item-field">{{item.data.rank}}</span>&nbsp; <span class="item-field">{{item.data.rank}}</span>&nbsp;
<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">&nbsp;&nbsp;</span>&nbsp;
<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">

View File

@ -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>