mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-16 13:41:07 +01:00
Fix Adversary attack multiplier
This commit is contained in:
parent
e1dd59454c
commit
b7b4722f7c
10 changed files with 36 additions and 80 deletions
|
|
@ -38,6 +38,8 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static CLEAN_ARRAYS = ["damage.parts", "cost", "effects"];
|
||||||
|
|
||||||
_getTabs() {
|
_getTabs() {
|
||||||
const tabs = {
|
const tabs = {
|
||||||
base: { active: true, cssClass: '', group: 'primary', id: 'base', icon: null, label: 'Base' },
|
base: { active: true, cssClass: '', group: 'primary', id: 'base', icon: null, label: 'Base' },
|
||||||
|
|
@ -64,7 +66,6 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
||||||
context.getRealIndex = this.getRealIndex.bind(this);
|
context.getRealIndex = this.getRealIndex.bind(this);
|
||||||
context.disableOption = this.disableOption.bind(this);
|
context.disableOption = this.disableOption.bind(this);
|
||||||
context.isNPC = this.action.actor.type !== 'character';
|
context.isNPC = this.action.actor.type !== 'character';
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -88,6 +89,19 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
||||||
|
|
||||||
_prepareSubmitData(event, formData) {
|
_prepareSubmitData(event, formData) {
|
||||||
const submitData = foundry.utils.expandObject(formData.object);
|
const submitData = foundry.utils.expandObject(formData.object);
|
||||||
|
for ( const keyPath of this.constructor.CLEAN_ARRAYS ) {
|
||||||
|
const data = foundry.utils.getProperty(submitData, keyPath);
|
||||||
|
if ( data ) foundry.utils.setProperty(submitData, keyPath, Object.values(data));
|
||||||
|
/* const data = foundry.utils.getProperty(submitData, keyPath),
|
||||||
|
originalData = foundry.utils.getProperty(this.action.toObject(), keyPath);
|
||||||
|
if ( data ) {
|
||||||
|
const aData = Object.values(data);
|
||||||
|
originalData.forEach((v,i) => {
|
||||||
|
aData[i] = {...originalData[i], ...aData[i]};
|
||||||
|
})
|
||||||
|
foundry.utils.setProperty(submitData, keyPath, aData);
|
||||||
|
} */
|
||||||
|
}
|
||||||
// this.element.querySelectorAll("fieldset[disabled] :is(input, select)").forEach(input => {
|
// this.element.querySelectorAll("fieldset[disabled] :is(input, select)").forEach(input => {
|
||||||
// foundry.utils.setProperty(submitData, input.name, input.value);
|
// foundry.utils.setProperty(submitData, input.name, input.value);
|
||||||
// });
|
// });
|
||||||
|
|
@ -96,7 +110,7 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
||||||
|
|
||||||
static async updateForm(event, _, formData) {
|
static async updateForm(event, _, formData) {
|
||||||
const submitData = this._prepareSubmitData(event, formData),
|
const submitData = this._prepareSubmitData(event, formData),
|
||||||
data = foundry.utils.expandObject(foundry.utils.mergeObject(this.action.toObject(), submitData)),
|
data = foundry.utils.mergeObject(this.action.toObject(), submitData),
|
||||||
container = foundry.utils.getProperty(this.action.parent, this.action.systemPath);
|
container = foundry.utils.getProperty(this.action.parent, this.action.systemPath);
|
||||||
let newActions;
|
let newActions;
|
||||||
if(Array.isArray(container)) {
|
if(Array.isArray(container)) {
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,6 @@ export class DHRoll extends Roll {
|
||||||
user: game.user.id,
|
user: game.user.id,
|
||||||
sound: config.mute ? null : CONFIG.sounds.dice,
|
sound: config.mute ? null : CONFIG.sounds.dice,
|
||||||
system: config,
|
system: config,
|
||||||
// content: this.messageTemplate,
|
|
||||||
content: await this.messageTemplate(config),
|
content: await this.messageTemplate(config),
|
||||||
rolls: [roll]
|
rolls: [roll]
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,6 @@ export default class AdversarySheet extends DaggerheartSheet(ActorSheetV2) {
|
||||||
context.tabs = super._getTabs(this.constructor.TABS);
|
context.tabs = super._getTabs(this.constructor.TABS);
|
||||||
context.systemFields.attack.fields = this.document.system.attack.schema.fields;
|
context.systemFields.attack.fields = this.document.system.attack.schema.fields;
|
||||||
context.isNPC = true;
|
context.isNPC = true;
|
||||||
console.log(context)
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
|
||||||
selectSubclass: this.selectSubclass,
|
selectSubclass: this.selectSubclass,
|
||||||
selectAncestry: this.selectAncestry,
|
selectAncestry: this.selectAncestry,
|
||||||
selectCommunity: this.selectCommunity,
|
selectCommunity: this.selectCommunity,
|
||||||
viewObject: this.viewObject,
|
// viewObject: this.viewObject,
|
||||||
useItem: this.useItem,
|
useItem: this.useItem,
|
||||||
useFeature: this.useFeature,
|
useFeature: this.useFeature,
|
||||||
takeShortRest: this.takeShortRest,
|
takeShortRest: this.takeShortRest,
|
||||||
|
|
@ -537,7 +537,7 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
|
||||||
item.use(event);
|
item.use(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async viewObject(_, button) {
|
/* static async viewObject(_, button) {
|
||||||
const object = await fromUuid(button.dataset.value);
|
const object = await fromUuid(button.dataset.value);
|
||||||
if (!object) return;
|
if (!object) return;
|
||||||
|
|
||||||
|
|
@ -547,7 +547,7 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
|
||||||
if (object.sheet.editMode) object.sheet.editMode = false;
|
if (object.sheet.editMode) object.sheet.editMode = false;
|
||||||
|
|
||||||
object.sheet.render(true);
|
object.sheet.render(true);
|
||||||
}
|
} */
|
||||||
|
|
||||||
editItem(event) {
|
editItem(event) {
|
||||||
const uuid = event.target.closest('[data-item-id]').dataset.itemId,
|
const uuid = event.target.closest('[data-item-id]').dataset.itemId,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
import DhpItem from '../../documents/item.mjs';
|
|
||||||
import ActionField from '../fields/actionField.mjs';
|
import ActionField from '../fields/actionField.mjs';
|
||||||
import DHWeapon from '../item/weapon.mjs';
|
|
||||||
import BaseDataActor from './base.mjs';
|
import BaseDataActor from './base.mjs';
|
||||||
|
|
||||||
const resourceField = () =>
|
const resourceField = () =>
|
||||||
|
|
@ -42,39 +40,6 @@ export default class DhpAdversary extends BaseDataActor {
|
||||||
hitPoints: resourceField(),
|
hitPoints: resourceField(),
|
||||||
stress: resourceField()
|
stress: resourceField()
|
||||||
}),
|
}),
|
||||||
/* attack: new fields.SchemaField({
|
|
||||||
name: new fields.StringField({}),
|
|
||||||
modifier: new fields.NumberField({ required: true, integer: true, initial: 0 }),
|
|
||||||
range: new fields.StringField({
|
|
||||||
required: true,
|
|
||||||
choices: SYSTEM.GENERAL.range,
|
|
||||||
initial: SYSTEM.GENERAL.range.melee.id
|
|
||||||
}),
|
|
||||||
damage: new fields.SchemaField({
|
|
||||||
value: new fields.StringField(),
|
|
||||||
type: new fields.StringField({
|
|
||||||
required: true,
|
|
||||||
choices: SYSTEM.GENERAL.damageTypes,
|
|
||||||
initial: SYSTEM.GENERAL.damageTypes.physical.id
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}), */
|
|
||||||
/* attack: new fields.EmbeddedDocumentField(DhpItem,
|
|
||||||
{
|
|
||||||
// type: 'weapon'
|
|
||||||
// initial: new DhpItem(
|
|
||||||
// {
|
|
||||||
// name: 'Attack',
|
|
||||||
// type: 'weapon'
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// parent: this.parent,
|
|
||||||
// parentCollection: 'items'
|
|
||||||
// }
|
|
||||||
// )
|
|
||||||
// initial: {type: 'weapon'}
|
|
||||||
}
|
|
||||||
), */
|
|
||||||
attack: new ActionField({
|
attack: new ActionField({
|
||||||
initial: {
|
initial: {
|
||||||
name: 'Attack',
|
name: 'Attack',
|
||||||
|
|
@ -91,7 +56,10 @@ export default class DhpAdversary extends BaseDataActor {
|
||||||
},
|
},
|
||||||
damage: {
|
damage: {
|
||||||
parts: [{
|
parts: [{
|
||||||
multiplier: 'flat'
|
multiplier: 'flat',
|
||||||
|
dice: 'd20',
|
||||||
|
bonus: 2,
|
||||||
|
flatMultiplier: 3
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -102,24 +70,6 @@ export default class DhpAdversary extends BaseDataActor {
|
||||||
value: new fields.NumberField({ required: true, integer: true, initial: 1 })
|
value: new fields.NumberField({ required: true, integer: true, initial: 1 })
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
/* Features waiting on pseudo-document data model addition */
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareBaseData() {
|
|
||||||
// console.log(this.attack)
|
|
||||||
/* if(!this.attack) {
|
|
||||||
this.attack = new DhpItem(
|
|
||||||
{
|
|
||||||
name: 'Attack',
|
|
||||||
type: 'weapon',
|
|
||||||
_id: foundry.utils.randomID()
|
|
||||||
},
|
|
||||||
{
|
|
||||||
parent: this.parent,
|
|
||||||
parentCollection: 'items'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
} */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -265,7 +265,8 @@ export default class DhpActor extends Actor {
|
||||||
* @param {object} [config.costs]
|
* @param {object} [config.costs]
|
||||||
*/
|
*/
|
||||||
async diceRoll(config, action) {
|
async diceRoll(config, action) {
|
||||||
config.source = {...(config.source ?? {}), actor: this._id};
|
// config.source = {...(config.source ?? {}), actor: this._id};
|
||||||
|
config.source = {...(config.source ?? {}), actor: this.uuid};
|
||||||
config.data = this.getRollData()
|
config.data = this.getRollData()
|
||||||
const roll = await CONFIG.Dice.daggerheart[this.type === 'character' ? 'DualityRoll' : 'D20Roll'].build(config)
|
const roll = await CONFIG.Dice.daggerheart[this.type === 'character' ? 'DualityRoll' : 'D20Roll'].build(config)
|
||||||
return config;
|
return config;
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,9 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
||||||
super.close(options);
|
super.close(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
getActor(id) {
|
async getActor(id) {
|
||||||
return game.actors.get(id);
|
// return game.actors.get(id);
|
||||||
|
return await fromUuid(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAction(actor, itemId, actionId) {
|
getAction(actor, itemId, actionId) {
|
||||||
|
|
@ -72,7 +73,7 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
||||||
|
|
||||||
onRollDamage = async (event, message) => {
|
onRollDamage = async (event, message) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
const actor = this.getActor(message.system.source.actor);
|
const actor = await this.getActor(message.system.source.actor);
|
||||||
if (!actor || !game.user.isGM) return true;
|
if (!actor || !game.user.isGM) return true;
|
||||||
if(message.system.source.item && message.system.source.action) {
|
if(message.system.source.item && message.system.source.action) {
|
||||||
const action = this.getAction(actor, message.system.source.item, message.system.source.action);
|
const action = this.getAction(actor, message.system.source.item, message.system.source.action);
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@
|
||||||
<div>
|
<div>
|
||||||
<fieldset class="action-category">
|
<fieldset class="action-category">
|
||||||
<legend class="action-category-label" data-action="toggleSection" data-section="range">
|
<legend class="action-category-label" data-action="toggleSection" data-section="range">
|
||||||
<div>Bonus</div>
|
<div>Bonus to Hit</div>
|
||||||
</legend>
|
</legend>
|
||||||
<div class="action-category-data open">
|
<div class="action-category-data open">
|
||||||
{{formField systemFields.attack.fields.roll.fields.bonus value=source.system.attack.roll.bonus name="system.attack.roll.bonus"}}
|
{{formField systemFields.attack.fields.roll.fields.bonus value=source.system.attack.roll.bonus name="system.attack.roll.bonus"}}
|
||||||
|
|
@ -75,17 +75,6 @@
|
||||||
<div style="grid-column: 1 / -1;">
|
<div style="grid-column: 1 / -1;">
|
||||||
{{> 'systems/daggerheart/templates/views/actionTypes/effect.hbs'}}
|
{{> 'systems/daggerheart/templates/views/actionTypes/effect.hbs'}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{{!-- <legend>{{localize "DAGGERHEART.Sheets.Adversary.Attack"}}</legend>
|
|
||||||
|
|
||||||
{{formGroup systemFields.attack.fields.name value=source.system.attack.name}}
|
|
||||||
<button data-action="attackRoll">Attack</button>
|
|
||||||
{{formGroup systemFields.attack.fields.modifier value=source.system.attack.modifier}}
|
|
||||||
{{formGroup systemFields.attack.fields.range value=source.system.attack.range localize=true}}
|
|
||||||
{{formGroup systemFields.attack.fields.damage.fields.value value=source.system.attack.damage.value}}
|
|
||||||
{{formGroup systemFields.attack.fields.damage.fields.type value=source.system.attack.damage.type localize=true}} --}}
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<li class="inventory-item">
|
<li class="inventory-item" data-item-id="{{item.uuid}}">
|
||||||
<img src="{{item.img}}" data-action="viewObject" data-value="{{item.uuid}}" class="item-img" />
|
<img src="{{item.img}}" data-action="useItem" class="item-img" />
|
||||||
<div class="item-label">
|
<div class="item-label">
|
||||||
<div class="item-name">{{item.name}}</div>
|
<div class="item-name">{{item.name}}</div>
|
||||||
{{#if (eq type 'weapon')}}
|
{{#if (eq type 'weapon')}}
|
||||||
|
|
|
||||||
|
|
@ -16,15 +16,18 @@
|
||||||
{{#each source.parts as |dmg index|}}
|
{{#each source.parts as |dmg index|}}
|
||||||
{{#if @root.isNPC}}
|
{{#if @root.isNPC}}
|
||||||
{{formField ../fields.custom.fields.enabled value=dmg.custom.enabled name=(concat ../path "damage.parts." index ".custom.enabled")}}
|
{{formField ../fields.custom.fields.enabled value=dmg.custom.enabled name=(concat ../path "damage.parts." index ".custom.enabled")}}
|
||||||
|
{{!-- {{formField ../fields.multiplier value=dmg.multiplier name=(concat ../path "damage.parts." index ".multiplier") localize=true}} --}}
|
||||||
|
<input type="hidden" name="{{../path}}damage.parts.{{index}}.multiplier" value="{{dmg.multiplier}}">
|
||||||
{{#if dmg.custom.enabled}}
|
{{#if dmg.custom.enabled}}
|
||||||
{{formField ../fields.custom.fields.formula value=dmg.custom.formula name=(concat ../path "damage.parts." index ".custom.formula") localize=true}}
|
{{formField ../fields.custom.fields.formula value=dmg.custom.formula name=(concat ../path "damage.parts." index ".custom.formula") localize=true}}
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="multi-display">
|
<div class="multi-display">
|
||||||
{{formField ../fields.flatMultiplier value=dmg.flatMultiplier name=(concat "damage.parts." realIndex ".flatMultiplier") label="Multiplier" }}
|
{{formField ../fields.flatMultiplier value=dmg.flatMultiplier name=(concat ../path "damage.parts." index ".flatMultiplier") label="Multiplier" }}
|
||||||
{{formField ../fields.dice value=dmg.dice name=(concat ../path "damage.parts." index ".dice")}}
|
{{formField ../fields.dice value=dmg.dice name=(concat ../path "damage.parts." index ".dice")}}
|
||||||
{{formField ../fields.bonus value=dmg.bonus name=(concat ../path "damage.parts." index ".bonus") localize=true}}
|
{{formField ../fields.bonus value=dmg.bonus name=(concat ../path "damage.parts." index ".bonus") localize=true}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{formField ../fields.type value=dmg.type name=(concat ../path "damage.parts." index ".type") localize=true}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#with (@root.getRealIndex index) as | realIndex |}}
|
{{#with (@root.getRealIndex index) as | realIndex |}}
|
||||||
<fieldset{{#if dmg.base}} disabled{{/if}}>
|
<fieldset{{#if dmg.base}} disabled{{/if}}>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue