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.Region.objectClass = placeables.DhRegion;
|
||||
|
||||
CONFIG.RollTable.documentClass = documents.DhRollTable;
|
||||
CONFIG.RollTable.resultTemplate = 'systems/daggerheart/templates/ui/chat/table-result.hbs';
|
||||
|
||||
|
|
|
|||
|
|
@ -1222,8 +1222,8 @@
|
|||
"cone": "Cone",
|
||||
"emanation": "Emanation",
|
||||
"inFront": "In Front",
|
||||
"rect": "Rectangle",
|
||||
"ray": "Ray"
|
||||
"rectangle": "Rectangle",
|
||||
"line": "Line"
|
||||
},
|
||||
"TokenSize": {
|
||||
"tiny": "Tiny",
|
||||
|
|
|
|||
|
|
@ -68,9 +68,9 @@ export default class DHEnvironmentSettings extends DHBaseActorSettings {
|
|||
*/
|
||||
static async #addCategory() {
|
||||
await this.actor.update({
|
||||
[`system.potentialAdversaries.${foundry.utils.randomID()}.label`]: game.i18n.localize(
|
||||
'DAGGERHEART.ACTORS.Environment.newAdversary'
|
||||
)
|
||||
[`system.potentialAdversaries.${foundry.utils.randomID()}`]: {
|
||||
label: game.i18n.localize('DAGGERHEART.ACTORS.Environment.newAdversary')
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -138,4 +138,8 @@ export default class DHEnvironmentSettings extends DHBaseActorSettings {
|
|||
this.render();
|
||||
}
|
||||
}
|
||||
|
||||
async _onDropItem(event, item) {
|
||||
console.log(item);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
export { default as DhMeasuredTemplate } from './measuredTemplate.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 DhTokenPlaceable } from './token.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 = {
|
||||
CIRCLE: 'circle',
|
||||
CONE: 'cone',
|
||||
RECTANGLE: 'rect',
|
||||
RAY: 'ray',
|
||||
RECTANGLE: 'rectangle',
|
||||
LINE: 'line',
|
||||
EMANATION: 'emanation',
|
||||
INFRONT: 'inFront'
|
||||
};
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ export default class DhEnvironment extends BaseDataActor {
|
|||
potentialAdversaries: new fields.TypedObjectField(
|
||||
new fields.SchemaField({
|
||||
label: new fields.StringField(),
|
||||
adversaries: new ForeignDocumentUUIDArrayField({ type: 'Actor' })
|
||||
adversaries: new ForeignDocumentUUIDArrayField({ type: 'Actor' }, { required: false, initial: [] })
|
||||
})
|
||||
),
|
||||
notes: new fields.HTMLField()
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ export default class ForeignDocumentUUIDArrayField extends foundry.data.fields.A
|
|||
|
||||
/** @inheritdoc */
|
||||
initialize(value, model, options = {}) {
|
||||
const v = super.initialize(value, model, options);
|
||||
const v = super.initialize(value ?? [], model, options);
|
||||
return () => {
|
||||
const data = v.map(entry => (typeof entry === 'function' ? entry() : entry));
|
||||
return this.options.prune ? data.filter(d => !!d) : data;
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ export default function DhTemplateEnricher(match, _options) {
|
|||
}
|
||||
|
||||
export const renderMeasuredTemplate = async event => {
|
||||
const { LINE, RECTANGLE, INFRONT, CONE } = CONFIG.DH.GENERAL.templateTypes;
|
||||
|
||||
const button = event.currentTarget,
|
||||
type = button.dataset.type,
|
||||
range = button.dataset.range,
|
||||
|
|
@ -57,13 +59,9 @@ export const renderMeasuredTemplate = async event => {
|
|||
|
||||
if (!type || !range || !game.canvas.scene) return;
|
||||
|
||||
const usedType = type === 'inFront' ? 'cone' : type === 'emanation' ? 'circle' : type;
|
||||
const usedType = type === 'inFront' ? 'cone' : type;
|
||||
const usedAngle =
|
||||
type === CONFIG.DH.GENERAL.templateTypes.CONE
|
||||
? (angle ?? CONFIG.MeasuredTemplate.defaults.angle)
|
||||
: type === CONFIG.DH.GENERAL.templateTypes.INFRONT
|
||||
? '180'
|
||||
: undefined;
|
||||
type === CONE ? (angle ?? CONFIG.MeasuredTemplate.defaults.angle) : type === INFRONT ? '180' : undefined;
|
||||
|
||||
let baseDistance = range;
|
||||
if (Number.isNaN(Number(range))) {
|
||||
|
|
@ -71,16 +69,32 @@ export const renderMeasuredTemplate = async event => {
|
|||
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 shapeData = {
|
||||
x: width / 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,
|
||||
distance: distance,
|
||||
width: type === CONFIG.DH.GENERAL.templateTypes.RAY ? 5 : undefined,
|
||||
length: length,
|
||||
width: shapeWidth,
|
||||
height: length,
|
||||
angle: usedAngle,
|
||||
radius: radius,
|
||||
direction: direction,
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
"description": "An unofficial implementation of the Daggerheart system",
|
||||
"version": "2.0.0",
|
||||
"compatibility": {
|
||||
"minimum": "14.354",
|
||||
"verified": "14.354",
|
||||
"minimum": "14.355",
|
||||
"verified": "14.355",
|
||||
"maximum": "14"
|
||||
},
|
||||
"authors": [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue