mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-07 06:26:13 +01:00
Compare commits
2 commits
4aab5d315a
...
37c53ad74e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37c53ad74e | ||
|
|
bcb30a6ff7 |
10 changed files with 54 additions and 21 deletions
|
|
@ -59,6 +59,8 @@ CONFIG.Canvas.layers.tokens.layerClass = DhTokenLayer;
|
||||||
|
|
||||||
CONFIG.MeasuredTemplate.objectClass = placeables.DhMeasuredTemplate;
|
CONFIG.MeasuredTemplate.objectClass = placeables.DhMeasuredTemplate;
|
||||||
|
|
||||||
|
CONFIG.Region.objectClass = placeables.DhRegion;
|
||||||
|
|
||||||
CONFIG.RollTable.documentClass = documents.DhRollTable;
|
CONFIG.RollTable.documentClass = documents.DhRollTable;
|
||||||
CONFIG.RollTable.resultTemplate = 'systems/daggerheart/templates/ui/chat/table-result.hbs';
|
CONFIG.RollTable.resultTemplate = 'systems/daggerheart/templates/ui/chat/table-result.hbs';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1222,8 +1222,8 @@
|
||||||
"cone": "Cone",
|
"cone": "Cone",
|
||||||
"emanation": "Emanation",
|
"emanation": "Emanation",
|
||||||
"inFront": "In Front",
|
"inFront": "In Front",
|
||||||
"rect": "Rectangle",
|
"rectangle": "Rectangle",
|
||||||
"ray": "Ray"
|
"line": "Line"
|
||||||
},
|
},
|
||||||
"TokenSize": {
|
"TokenSize": {
|
||||||
"tiny": "Tiny",
|
"tiny": "Tiny",
|
||||||
|
|
|
||||||
|
|
@ -68,9 +68,9 @@ export default class DHEnvironmentSettings extends DHBaseActorSettings {
|
||||||
*/
|
*/
|
||||||
static async #addCategory() {
|
static async #addCategory() {
|
||||||
await this.actor.update({
|
await this.actor.update({
|
||||||
[`system.potentialAdversaries.${foundry.utils.randomID()}.label`]: game.i18n.localize(
|
[`system.potentialAdversaries.${foundry.utils.randomID()}`]: {
|
||||||
'DAGGERHEART.ACTORS.Environment.newAdversary'
|
label: game.i18n.localize('DAGGERHEART.ACTORS.Environment.newAdversary')
|
||||||
)
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -138,4 +138,8 @@ export default class DHEnvironmentSettings extends DHBaseActorSettings {
|
||||||
this.render();
|
this.render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _onDropItem(event, item) {
|
||||||
|
console.log(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
export { default as DhMeasuredTemplate } from './measuredTemplate.mjs';
|
export { default as DhMeasuredTemplate } from './measuredTemplate.mjs';
|
||||||
export { default as DhRuler } from './ruler.mjs';
|
export { default as DhRuler } from './ruler.mjs';
|
||||||
|
export { default as DhRegion } from './region.mjs';
|
||||||
export { default as DhRegionLayer } from './regionLayer.mjs';
|
export { default as DhRegionLayer } from './regionLayer.mjs';
|
||||||
export { default as DhTokenPlaceable } from './token.mjs';
|
export { default as DhTokenPlaceable } from './token.mjs';
|
||||||
export { default as DhTokenRuler } from './tokenRuler.mjs';
|
export { default as DhTokenRuler } from './tokenRuler.mjs';
|
||||||
|
|
|
||||||
12
module/canvas/placeables/region.mjs
Normal file
12
module/canvas/placeables/region.mjs
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
import DhMeasuredTemplate from './measuredTemplate.mjs';
|
||||||
|
|
||||||
|
export default class DhRegion extends foundry.canvas.placeables.Region {
|
||||||
|
/**@inheritdoc */
|
||||||
|
_formatMeasuredDistance(distance) {
|
||||||
|
const range = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.variantRules).rangeMeasurement;
|
||||||
|
if (!range.enabled) return super._formatMeasuredDistance(distance);
|
||||||
|
|
||||||
|
const { distance: resultDistance, units } = DhMeasuredTemplate.getRangeLabels(distance, range);
|
||||||
|
return `${resultDistance} ${units}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -74,8 +74,8 @@ export const range = {
|
||||||
export const templateTypes = {
|
export const templateTypes = {
|
||||||
CIRCLE: 'circle',
|
CIRCLE: 'circle',
|
||||||
CONE: 'cone',
|
CONE: 'cone',
|
||||||
RECTANGLE: 'rect',
|
RECTANGLE: 'rectangle',
|
||||||
RAY: 'ray',
|
LINE: 'line',
|
||||||
EMANATION: 'emanation',
|
EMANATION: 'emanation',
|
||||||
INFRONT: 'inFront'
|
INFRONT: 'inFront'
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ export default class DhEnvironment extends BaseDataActor {
|
||||||
potentialAdversaries: new fields.TypedObjectField(
|
potentialAdversaries: new fields.TypedObjectField(
|
||||||
new fields.SchemaField({
|
new fields.SchemaField({
|
||||||
label: new fields.StringField(),
|
label: new fields.StringField(),
|
||||||
adversaries: new ForeignDocumentUUIDArrayField({ type: 'Actor' })
|
adversaries: new ForeignDocumentUUIDArrayField({ type: 'Actor' }, { required: false, initial: [] })
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
notes: new fields.HTMLField()
|
notes: new fields.HTMLField()
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ export default class ForeignDocumentUUIDArrayField extends foundry.data.fields.A
|
||||||
|
|
||||||
/** @inheritdoc */
|
/** @inheritdoc */
|
||||||
initialize(value, model, options = {}) {
|
initialize(value, model, options = {}) {
|
||||||
const v = super.initialize(value, model, options);
|
const v = super.initialize(value ?? [], model, options);
|
||||||
return () => {
|
return () => {
|
||||||
const data = v.map(entry => (typeof entry === 'function' ? entry() : entry));
|
const data = v.map(entry => (typeof entry === 'function' ? entry() : entry));
|
||||||
return this.options.prune ? data.filter(d => !!d) : data;
|
return this.options.prune ? data.filter(d => !!d) : data;
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,8 @@ export default function DhTemplateEnricher(match, _options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const renderMeasuredTemplate = async event => {
|
export const renderMeasuredTemplate = async event => {
|
||||||
|
const { LINE, RECTANGLE, INFRONT, CONE } = CONFIG.DH.GENERAL.templateTypes;
|
||||||
|
|
||||||
const button = event.currentTarget,
|
const button = event.currentTarget,
|
||||||
type = button.dataset.type,
|
type = button.dataset.type,
|
||||||
range = button.dataset.range,
|
range = button.dataset.range,
|
||||||
|
|
@ -57,13 +59,9 @@ export const renderMeasuredTemplate = async event => {
|
||||||
|
|
||||||
if (!type || !range || !game.canvas.scene) return;
|
if (!type || !range || !game.canvas.scene) return;
|
||||||
|
|
||||||
const usedType = type === 'inFront' ? 'cone' : type === 'emanation' ? 'circle' : type;
|
const usedType = type === 'inFront' ? 'cone' : type;
|
||||||
const usedAngle =
|
const usedAngle =
|
||||||
type === CONFIG.DH.GENERAL.templateTypes.CONE
|
type === CONE ? (angle ?? CONFIG.MeasuredTemplate.defaults.angle) : type === INFRONT ? '180' : undefined;
|
||||||
? (angle ?? CONFIG.MeasuredTemplate.defaults.angle)
|
|
||||||
: type === CONFIG.DH.GENERAL.templateTypes.INFRONT
|
|
||||||
? '180'
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
let baseDistance = range;
|
let baseDistance = range;
|
||||||
if (Number.isNaN(Number(range))) {
|
if (Number.isNaN(Number(range))) {
|
||||||
|
|
@ -71,16 +69,32 @@ export const renderMeasuredTemplate = async event => {
|
||||||
range
|
range
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
const distance = type === CONFIG.DH.GENERAL.templateTypes.EMANATION ? baseDistance + 2.5 : baseDistance;
|
|
||||||
const radius = (distance / game.scenes.active.grid.distance) * game.scenes.active.grid.size;
|
const dimensionConstant = game.scenes.active.grid.size / game.scenes.active.grid.distance;
|
||||||
|
|
||||||
|
baseDistance *= dimensionConstant;
|
||||||
|
|
||||||
|
const length = baseDistance;
|
||||||
|
const radius = length;
|
||||||
|
|
||||||
|
const shapeWidth = type === LINE ? 5 * dimensionConstant : type === RECTANGLE ? length : undefined;
|
||||||
|
|
||||||
const { width, height } = game.canvas.scene.dimensions;
|
const { width, height } = game.canvas.scene.dimensions;
|
||||||
const shapeData = {
|
const shapeData = {
|
||||||
x: width / 2,
|
x: width / 2,
|
||||||
y: height / 2,
|
y: height / 2,
|
||||||
|
base: {
|
||||||
|
type: 'token',
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
width: 1,
|
||||||
|
height: 1,
|
||||||
|
shape: game.canvas.grid.isHexagonal ? CONST.TOKEN_SHAPES.ELLIPSE_1 : CONST.TOKEN_SHAPES.RECTANGLE_1
|
||||||
|
},
|
||||||
t: usedType,
|
t: usedType,
|
||||||
distance: distance,
|
length: length,
|
||||||
width: type === CONFIG.DH.GENERAL.templateTypes.RAY ? 5 : undefined,
|
width: shapeWidth,
|
||||||
|
height: length,
|
||||||
angle: usedAngle,
|
angle: usedAngle,
|
||||||
radius: radius,
|
radius: radius,
|
||||||
direction: direction,
|
direction: direction,
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
"description": "An unofficial implementation of the Daggerheart system",
|
"description": "An unofficial implementation of the Daggerheart system",
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"compatibility": {
|
"compatibility": {
|
||||||
"minimum": "14.354",
|
"minimum": "14.355",
|
||||||
"verified": "14.354",
|
"verified": "14.355",
|
||||||
"maximum": "14"
|
"maximum": "14"
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue