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.hasBaseDamage = !!this.action.parent.attack;
|
||||||
context.getEffectDetails = this.getEffectDetails.bind(this);
|
context.getEffectDetails = this.getEffectDetails.bind(this);
|
||||||
context.costOptions = this.getCostOptions();
|
context.costOptions = this.getCostOptions();
|
||||||
|
context.getRollTypeOptions = this.getRollTypeOptions();
|
||||||
context.disableOption = this.disableOption.bind(this);
|
context.disableOption = this.disableOption.bind(this);
|
||||||
context.isNPC = this.action.actor?.isNPC;
|
context.isNPC = this.action.actor?.isNPC;
|
||||||
context.baseSaveDifficulty = this.action.actor?.baseSaveDifficulty;
|
context.baseSaveDifficulty = this.action.actor?.baseSaveDifficulty;
|
||||||
|
context.baseAttackBonus = this.action.actor?.system.attack?.damage.parts[0].value.bonus;
|
||||||
context.hasRoll = this.action.hasRoll;
|
context.hasRoll = this.action.hasRoll;
|
||||||
|
|
||||||
const settingsTiers = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LevelTiers).tiers;
|
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;
|
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) {
|
disableOption(index, costOptions, choices) {
|
||||||
const filtered = foundry.utils.deepClone(costOptions);
|
const filtered = foundry.utils.deepClone(costOptions);
|
||||||
Object.keys(filtered).forEach(o => {
|
Object.keys(filtered).forEach(o => {
|
||||||
|
|
|
||||||
|
|
@ -473,11 +473,13 @@ export const rollTypes = {
|
||||||
},
|
},
|
||||||
spellcast: {
|
spellcast: {
|
||||||
id: 'spellcast',
|
id: 'spellcast',
|
||||||
label: 'DAGGERHEART.CONFIG.RollTypes.spellcast.name'
|
label: 'DAGGERHEART.CONFIG.RollTypes.spellcast.name',
|
||||||
|
playerOnly: true
|
||||||
},
|
},
|
||||||
trait: {
|
trait: {
|
||||||
id: 'trait',
|
id: 'trait',
|
||||||
label: 'DAGGERHEART.CONFIG.RollTypes.trait.name'
|
label: 'DAGGERHEART.CONFIG.RollTypes.trait.name',
|
||||||
|
playerOnly: true
|
||||||
},
|
},
|
||||||
diceSet: {
|
diceSet: {
|
||||||
id: 'diceSet',
|
id: 'diceSet',
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
||||||
|
|
||||||
this.extraSchemas.forEach(s => {
|
this.extraSchemas.forEach(s => {
|
||||||
let clsField;
|
let clsField;
|
||||||
if ((clsField = this.getActionField(s))) schemaFields[s] = new clsField(
|
if ((clsField = this.getActionField(s))) schemaFields[s] = new clsField();
|
||||||
{
|
|
||||||
type: this
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return schemaFields;
|
return schemaFields;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ export class DHActionRollData extends foundry.abstract.DataModel {
|
||||||
/** @override */
|
/** @override */
|
||||||
static defineSchema() {
|
static defineSchema() {
|
||||||
return {
|
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 }),
|
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 }),
|
difficulty: new fields.NumberField({ nullable: true, initial: null, integer: true, min: 0 }),
|
||||||
bonus: new fields.NumberField({ nullable: true, initial: null, integer: true }),
|
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() {
|
getFormula() {
|
||||||
if (!this.type) return;
|
if (!this.type) return;
|
||||||
let formula = '';
|
let formula = '';
|
||||||
|
|
@ -80,6 +71,5 @@ export class DHActionRollData extends foundry.abstract.DataModel {
|
||||||
export default class RollField extends fields.EmbeddedDataField {
|
export default class RollField extends fields.EmbeddedDataField {
|
||||||
constructor(options, context = {}) {
|
constructor(options, context = {}) {
|
||||||
super(DHActionRollData, options, context);
|
super(DHActionRollData, options, context);
|
||||||
console.log(this)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,31 @@
|
||||||
Roll
|
Roll
|
||||||
{{#if @root.hasBaseDamage}}{{formInput fields.useDefault name="roll.useDefault" value=source.useDefault dataset=(object tooltip="Use default Item values" tooltipDirection="UP")}}{{/if}}
|
{{#if @root.hasBaseDamage}}{{formInput fields.useDefault name="roll.useDefault" value=source.useDefault dataset=(object tooltip="Use default Item values" tooltipDirection="UP")}}{{/if}}
|
||||||
</legend>
|
</legend>
|
||||||
{{#if @root.isNPC}}
|
|
||||||
|
{{formField fields.type label="Type" name="roll.type" value=source.type localize=true choices=@root.getRollTypeOptions}}
|
||||||
|
{{#if (eq source.type "diceSet")}}
|
||||||
|
<div class="nest-inputs">
|
||||||
|
{{formField fields.diceRolling.fields.multiplier name="roll.diceRolling.multiplier" value=source.diceRolling.multiplier localize=true}}
|
||||||
|
{{#if (eq source.diceRolling.multiplier 'flat')}}{{formField fields.diceRolling.fields.flatMultiplier value=source.diceRolling.flatMultiplier name="roll.diceRolling.flatMultiplier" localize=true }}{{/if}}
|
||||||
|
{{formField fields.diceRolling.fields.dice name="roll.diceRolling.dice" value=source.diceRolling.dice localize=true}}
|
||||||
|
{{formField fields.diceRolling.fields.compare name="roll.diceRolling.compare" value=source.diceRolling.compare localize=true blank=""}}
|
||||||
|
{{formField fields.diceRolling.fields.treshold name="roll.diceRolling.treshold" value=source.diceRolling.treshold localize=true}}
|
||||||
|
</div>
|
||||||
|
{{else}}
|
||||||
|
<div class="nest-inputs">
|
||||||
|
{{#unless (eq source.type 'spellcast')}}
|
||||||
|
{{#if @root.isNPC}}
|
||||||
|
{{formField fields.bonus label="Bonus" name="roll.bonus" value=source.bonus placeholder=@root.baseAttackBonus disabled=(not source.type)}}
|
||||||
|
{{else}}
|
||||||
|
{{formField fields.trait label="Trait" name="roll.trait" value=source.trait localize=true disabled=(not source.type)}}
|
||||||
|
{{/if}}
|
||||||
|
{{/unless}}
|
||||||
|
{{formField fields.difficulty label="Difficulty" name="roll.difficulty" value=source.difficulty disabled=(not source.type)}}
|
||||||
|
{{formField fields.advState label= "Advantage State" name="roll.advState" value=source.advState localize=true disabled=(not source.type)}}
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{!-- {{#if @root.isNPC}}
|
||||||
{{formField fields.bonus label="Bonus" name="roll.bonus" value=source.bonus}}
|
{{formField fields.bonus label="Bonus" name="roll.bonus" value=source.bonus}}
|
||||||
{{formField fields.advState label= "Advantage State" name="roll.advState" value=source.advState localize=true}}
|
{{formField fields.advState label= "Advantage State" name="roll.advState" value=source.advState localize=true}}
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
@ -18,10 +42,10 @@
|
||||||
</div>
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="nest-inputs">
|
<div class="nest-inputs">
|
||||||
{{formField fields.trait label="Trait" name="roll.trait" value=source.trait localize=true disabled=(not source.type)}}
|
{{#unless (eq source.type 'spellcast')}}{{formField fields.trait label="Trait" name="roll.trait" value=source.trait localize=true disabled=(not source.type)}}{{/unless}}
|
||||||
{{formField fields.difficulty label="Difficulty" name="roll.difficulty" value=source.difficulty disabled=(not source.type)}}
|
{{formField fields.difficulty label="Difficulty" name="roll.difficulty" value=source.difficulty disabled=(not source.type)}}
|
||||||
{{formField fields.advState label= "Advantage State" name="roll.advState" value=source.advState localize=true}}
|
{{formField fields.advState label= "Advantage State" name="roll.advState" value=source.advState localize=true}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}} --}}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue