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

@ -190,11 +190,11 @@ export class BoLActorSheet extends ActorSheet {
*/
_onRoll(event) {
event.preventDefault();
const element = event.currentTarget;
const dataset = element.dataset;
const actorData = this.getData();
const rollType = dataset.rollType;
const li = $(event.currentTarget).closest(".item");
const element = event.currentTarget
const dataset = element.dataset
const actorData = this.getData()
const rollType = dataset.rollType
const li = $(event.currentTarget).closest(".item")
switch (rollType) {
case "attribute":
BoLRoll.attributeCheck(this.actor, actorData, dataset, event);
@ -217,6 +217,16 @@ export class BoLActorSheet extends ActorSheet {
case "damage":
this.actor.rollWeaponDamage(li.data("item-id"))
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
}
/* -------------------------------------------- */
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) {
let fightOption = this.data.items.get(itemId)

View File

@ -39,53 +39,49 @@ export const registerHandlebarsHelpers = function () {
Handlebars.registerHelper('gt', function (val1, val2) {
return val1 > val2;
});
})
Handlebars.registerHelper('lt', function (val1, val2) {
return val1 < val2;
});
})
Handlebars.registerHelper('gte', function (val1, val2) {
return val1 >= val2;
});
})
Handlebars.registerHelper('lte', function (val1, val2) {
return val1 <= val2;
});
})
Handlebars.registerHelper('and', function (val1, val2) {
return val1 && val2;
});
})
Handlebars.registerHelper('or', function (val1, val2) {
return val1 || val2;
});
})
Handlebars.registerHelper('or3', function (val1, val2, val3) {
return val1 || val2 || val3;
});
})
Handlebars.registerHelper('for', function(from, to, incr, block) {
var accum = '';
for(var i = from; i < to; i += incr)
accum += block.fn(i);
return accum;
});
})
Handlebars.registerHelper('not', function (cond) {
return !cond;
});
})
Handlebars.registerHelper('count', function (list) {
return list.length;
});
})
Handlebars.registerHelper('isEnabled', function (configKey) {
return game.settings.get("bol", configKey);
});
})
Handlebars.registerHelper('split', function (str, separator, keep) {
return str.split(separator)[keep];
});
})
// If you need to add Handlebars helpers, here are a few useful examples:
Handlebars.registerHelper('concat', function () {
@ -96,32 +92,30 @@ export const registerHandlebarsHelpers = function () {
}
}
return outStr;
});
})
Handlebars.registerHelper('add', function (a, b) {
return parseInt(a) + parseInt(b);
});
Handlebars.registerHelper('mul', function (a, b) {
return parseInt(a) * parseInt(b);
})
Handlebars.registerHelper('sub', function (a, b) {
return parseInt(a) - parseInt(b);
});
})
Handlebars.registerHelper('valueAtIndex', function (arr, idx) {
return arr[idx];
});
})
Handlebars.registerHelper('includesKey', function (items, type, key) {
// console.log(items);
return items.filter(i => i.type === type).map(i => i.data.key).includes(key);
});
})
Handlebars.registerHelper('includes', function (array, val) {
return array.includes(val);
});
})
Handlebars.registerHelper('eval', function (expr) {
return eval(expr);
});
})

View File

@ -7,7 +7,7 @@
"url": "https://github.com/ZigmundKreud/bol",
"license": "LICENSE.txt",
"flags": {},
"version": "1.2.1",
"version": "1.2.2",
"templateVersion": 22,
"minimumCoreVersion": "0.8.6",
"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;
<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>
<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}}
</div>
<div class="item-field flex1 right">

View File

@ -3,9 +3,20 @@
<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/>
<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}}"><i class="fas fa-dice"></i></span>
<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 class="stat-roll rollable" title="2d6" data-roll-type="attribute" data-roll="2d6+@attributes.{{key}}.value" data-adv="0" data-key="{{key}}">
<i class="darkgreen fas fa-dice"></i>
</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>
{{/each}}
</div>
@ -15,9 +26,20 @@
<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/>
<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}}"><i class="fas fa-dice"></i></span>
<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 class="stat-roll rollable" title="2d6" data-roll-type="aptitude" data-roll="2d6+@aptitudes.{{key}}.value" data-adv="0" data-key="{{key}}">
<i class="darkgreen fas fa-dice"></i>
</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>
{{/each}}
</div>