mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
146 - Measured Templates (#147)
* Added DhMeasuredTemplate * Added TemplateEnricher for Template buttons in text
This commit is contained in:
parent
7802d18a4d
commit
96ed90b5fc
9 changed files with 168 additions and 66 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import DhMeasuredTemplate from '../placeables/measuredTemplate.mjs';
|
||||
|
||||
export default class DhpRuler extends foundry.canvas.interaction.Ruler {
|
||||
_getWaypointLabelContext(waypoint, state) {
|
||||
const context = super._getWaypointLabelContext(waypoint, state);
|
||||
|
|
@ -6,29 +8,11 @@ export default class DhpRuler extends foundry.canvas.interaction.Ruler {
|
|||
const range = game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.RangeMeasurement);
|
||||
|
||||
if (range.enabled) {
|
||||
const distance = this.#getRangeLabel(waypoint.measurement.distance.toNearest(0.01), range);
|
||||
const distance = DhMeasuredTemplate.getDistanceLabel(waypoint.measurement.distance.toNearest(0.01), range);
|
||||
context.cost = { total: distance, units: null };
|
||||
context.distance = { total: distance, units: null };
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
#getRangeLabel(distance, settings) {
|
||||
if (distance <= settings.melee) {
|
||||
return game.i18n.localize('DAGGERHEART.Range.melee.name');
|
||||
}
|
||||
if (distance <= settings.veryClose) {
|
||||
return game.i18n.localize('DAGGERHEART.Range.veryClose.name');
|
||||
}
|
||||
if (distance <= settings.close) {
|
||||
return game.i18n.localize('DAGGERHEART.Range.close.name');
|
||||
}
|
||||
if (distance <= settings.far) {
|
||||
return game.i18n.localize('DAGGERHEART.Range.far.name');
|
||||
}
|
||||
if (distance <= settings.veryFar) {
|
||||
return game.i18n.localize('DAGGERHEART.Range.veryFar.name');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue