mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 07:59:03 +01:00
Filter types choices
This commit is contained in:
parent
0512e4cad0
commit
18aed3a9f0
5 changed files with 44 additions and 21 deletions
|
|
@ -108,9 +108,11 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
|||
context.hasBaseDamage = !!this.action.parent.attack;
|
||||
context.getEffectDetails = this.getEffectDetails.bind(this);
|
||||
context.costOptions = this.getCostOptions();
|
||||
context.getRollTypeOptions = this.getRollTypeOptions();
|
||||
context.disableOption = this.disableOption.bind(this);
|
||||
context.isNPC = this.action.actor?.isNPC;
|
||||
context.baseSaveDifficulty = this.action.actor?.baseSaveDifficulty;
|
||||
context.baseAttackBonus = this.action.actor?.system.attack?.damage.parts[0].value.bonus;
|
||||
context.hasRoll = this.action.hasRoll;
|
||||
|
||||
const settingsTiers = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LevelTiers).tiers;
|
||||
|
|
@ -139,6 +141,15 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
|||
return options;
|
||||
}
|
||||
|
||||
getRollTypeOptions() {
|
||||
const types = foundry.utils.deepClone(CONFIG.DH.GENERAL.rollTypes);
|
||||
if(!this.action.actor) return types;
|
||||
Object.values(types).forEach(t => {
|
||||
if(this.action.actor.type !== 'character' && t.playerOnly) delete types[t.id];
|
||||
})
|
||||
return types;
|
||||
}
|
||||
|
||||
disableOption(index, costOptions, choices) {
|
||||
const filtered = foundry.utils.deepClone(costOptions);
|
||||
Object.keys(filtered).forEach(o => {
|
||||
|
|
|
|||
|
|
@ -473,11 +473,13 @@ export const rollTypes = {
|
|||
},
|
||||
spellcast: {
|
||||
id: 'spellcast',
|
||||
label: 'DAGGERHEART.CONFIG.RollTypes.spellcast.name'
|
||||
label: 'DAGGERHEART.CONFIG.RollTypes.spellcast.name',
|
||||
playerOnly: true
|
||||
},
|
||||
trait: {
|
||||
id: 'trait',
|
||||
label: 'DAGGERHEART.CONFIG.RollTypes.trait.name'
|
||||
label: 'DAGGERHEART.CONFIG.RollTypes.trait.name',
|
||||
playerOnly: true
|
||||
},
|
||||
diceSet: {
|
||||
id: 'diceSet',
|
||||
|
|
|
|||
|
|
@ -37,11 +37,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
|
||||
this.extraSchemas.forEach(s => {
|
||||
let clsField;
|
||||
if ((clsField = this.getActionField(s))) schemaFields[s] = new clsField(
|
||||
{
|
||||
type: this
|
||||
}
|
||||
);
|
||||
if ((clsField = this.getActionField(s))) schemaFields[s] = new clsField();
|
||||
});
|
||||
|
||||
return schemaFields;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ export class DHActionRollData extends foundry.abstract.DataModel {
|
|||
/** @override */
|
||||
static defineSchema() {
|
||||
return {
|
||||
type: new fields.StringField({ nullable: true, initial: null, choices: this.getRollTypes() }),
|
||||
type: new fields.StringField({ nullable: true, initial: null, choices: CONFIG.DH.GENERAL.rollTypes }),
|
||||
trait: new fields.StringField({ nullable: true, initial: null, choices: CONFIG.DH.ACTOR.abilities }),
|
||||
difficulty: new fields.NumberField({ nullable: true, initial: null, integer: true, min: 0 }),
|
||||
bonus: new fields.NumberField({ nullable: true, initial: null, integer: true }),
|
||||
|
|
@ -45,15 +45,6 @@ export class DHActionRollData extends foundry.abstract.DataModel {
|
|||
};
|
||||
}
|
||||
|
||||
static getRollTypes() {
|
||||
console.log(this.parent, this._source)
|
||||
return CONFIG.DH.GENERAL.rollTypes;
|
||||
}
|
||||
|
||||
_configure() {
|
||||
console.log(this)
|
||||
}
|
||||
|
||||
getFormula() {
|
||||
if (!this.type) return;
|
||||
let formula = '';
|
||||
|
|
@ -80,6 +71,5 @@ export class DHActionRollData extends foundry.abstract.DataModel {
|
|||
export default class RollField extends fields.EmbeddedDataField {
|
||||
constructor(options, context = {}) {
|
||||
super(DHActionRollData, options, context);
|
||||
console.log(this)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue