mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-21 15:03:37 +02:00
Finished
This commit is contained in:
parent
ca097c21a3
commit
e4b3f5d5bd
6 changed files with 59 additions and 12 deletions
|
|
@ -236,6 +236,8 @@
|
||||||
},
|
},
|
||||||
"defaultHopeDice": "Default Hope Dice",
|
"defaultHopeDice": "Default Hope Dice",
|
||||||
"defaultFearDice": "Default Fear Dice",
|
"defaultFearDice": "Default Fear Dice",
|
||||||
|
"defaultAdvantageDice": "Default Advantage Dice",
|
||||||
|
"defaultDisadvantageDice": "Default Disadvantage Dice",
|
||||||
"disadvantageSources": {
|
"disadvantageSources": {
|
||||||
"label": "Disadvantage Sources",
|
"label": "Disadvantage Sources",
|
||||||
"hint": "Add single words or short text as reminders and hints of what a character has disadvantage on."
|
"hint": "Add single words or short text as reminders and hints of what a character has disadvantage on."
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,10 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
context.advantage = this.config.roll?.advantage;
|
context.advantage = this.config.roll?.advantage;
|
||||||
context.disadvantage = this.config.roll?.disadvantage;
|
context.disadvantage = this.config.roll?.disadvantage;
|
||||||
context.diceOptions = CONFIG.DH.GENERAL.diceTypes;
|
context.diceOptions = CONFIG.DH.GENERAL.diceTypes;
|
||||||
|
context.diceFaces = CONFIG.DH.GENERAL.dieFaces.reduce((acc, face) => {
|
||||||
|
acc[face] = `d${face}`;
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
context.isLite = this.config.roll?.lite;
|
context.isLite = this.config.roll?.lite;
|
||||||
context.extraFormula = this.config.extraFormula;
|
context.extraFormula = this.config.extraFormula;
|
||||||
context.formula = this.roll.constructFormula(this.config);
|
context.formula = this.roll.constructFormula(this.config);
|
||||||
|
|
@ -153,7 +157,10 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
if (this.config.uses) this.config.uses = foundry.utils.mergeObject(this.config.uses, rest.uses);
|
if (this.config.uses) this.config.uses = foundry.utils.mergeObject(this.config.uses, rest.uses);
|
||||||
if (rest.roll?.dice) {
|
if (rest.roll?.dice) {
|
||||||
Object.entries(rest.roll.dice).forEach(([key, value]) => {
|
Object.entries(rest.roll.dice).forEach(([key, value]) => {
|
||||||
this.roll[key] = value;
|
if(key === 'advantageFaces')
|
||||||
|
this.roll[key] = Number.parseInt(value);
|
||||||
|
else
|
||||||
|
this.roll[key] = value;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (rest.hasOwnProperty('trait')) {
|
if (rest.hasOwnProperty('trait')) {
|
||||||
|
|
@ -173,6 +180,16 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
this.disadvantage = advantage === -1;
|
this.disadvantage = advantage === -1;
|
||||||
|
|
||||||
this.config.roll.advantage = this.config.roll.advantage === advantage ? 0 : advantage;
|
this.config.roll.advantage = this.config.roll.advantage === advantage ? 0 : advantage;
|
||||||
|
|
||||||
|
if(this.config.roll.advantage === 1 && this.config.data.rules.roll.defaultAdvantageDice) {
|
||||||
|
const faces = Number.parseInt(this.config.data.rules.roll.defaultAdvantageDice);
|
||||||
|
this.roll.advantageFaces = Number.isNaN(faces) ? this.roll.advantageFaces : faces;
|
||||||
|
}
|
||||||
|
else if(this.config.roll.advantage === -1 && this.config.data.rules.roll.defaultDisadvantageDice) {
|
||||||
|
const faces = Number.parseInt(this.config.data.rules.roll.defaultDisadvantageDice);
|
||||||
|
this.roll.advantageFaces = Number.isNaN(faces) ? this.roll.advantageFaces : faces;
|
||||||
|
}
|
||||||
|
|
||||||
this.render();
|
this.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -289,7 +289,23 @@ export default class DhCharacter extends DhCreature {
|
||||||
guaranteedCritical: new fields.BooleanField({
|
guaranteedCritical: new fields.BooleanField({
|
||||||
label: 'DAGGERHEART.ACTORS.Character.roll.guaranteedCritical.label',
|
label: 'DAGGERHEART.ACTORS.Character.roll.guaranteedCritical.label',
|
||||||
hint: 'DAGGERHEART.ACTORS.Character.roll.guaranteedCritical.hint'
|
hint: 'DAGGERHEART.ACTORS.Character.roll.guaranteedCritical.hint'
|
||||||
})
|
}),
|
||||||
|
defaultAdvantageDice: new fields.NumberField({
|
||||||
|
nullable: true,
|
||||||
|
required: true,
|
||||||
|
integer: true,
|
||||||
|
choices: CONFIG.DH.GENERAL.dieFaces,
|
||||||
|
initial: null,
|
||||||
|
label: 'DAGGERHEART.ACTORS.Character.defaultAdvantageDice'
|
||||||
|
}),
|
||||||
|
defaultDisadvantageDice: new fields.NumberField({
|
||||||
|
nullable: true,
|
||||||
|
required: true,
|
||||||
|
integer: true,
|
||||||
|
choices: CONFIG.DH.GENERAL.dieFaces,
|
||||||
|
initial: null,
|
||||||
|
label: 'DAGGERHEART.ACTORS.Character.defaultDisadvantageDice'
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,24 @@ export default class DhCompanion extends DhCreature {
|
||||||
initial: false,
|
initial: false,
|
||||||
label: 'DAGGERHEART.GENERAL.Rules.conditionImmunities.vulnerable'
|
label: 'DAGGERHEART.GENERAL.Rules.conditionImmunities.vulnerable'
|
||||||
})
|
})
|
||||||
|
}),
|
||||||
|
roll: new fields.SchemaField({
|
||||||
|
defaultAdvantageDice: new fields.NumberField({
|
||||||
|
nullable: true,
|
||||||
|
required: true,
|
||||||
|
integer: true,
|
||||||
|
choices: CONFIG.DH.GENERAL.dieFaces,
|
||||||
|
initial: null,
|
||||||
|
label: 'DAGGERHEART.ACTORS.Character.defaultAdvantageDice'
|
||||||
|
}),
|
||||||
|
defaultDisadvantageDice: new fields.NumberField({
|
||||||
|
nullable: true,
|
||||||
|
required: true,
|
||||||
|
integer: true,
|
||||||
|
choices: CONFIG.DH.GENERAL.dieFaces,
|
||||||
|
initial: null,
|
||||||
|
label: 'DAGGERHEART.ACTORS.Character.defaultDisadvantageDice'
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
attack: new ActionField({
|
attack: new ActionField({
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import D20Roll from './d20Roll.mjs';
|
||||||
import { parseRallyDice, setDiceSoNiceForDualityRoll } from '../helpers/utils.mjs';
|
import { parseRallyDice, setDiceSoNiceForDualityRoll } from '../helpers/utils.mjs';
|
||||||
|
|
||||||
export default class DualityRoll extends D20Roll {
|
export default class DualityRoll extends D20Roll {
|
||||||
_advantageFaces = 6;
|
|
||||||
_advantageNumber = 1;
|
_advantageNumber = 1;
|
||||||
_rallyIndex;
|
_rallyIndex;
|
||||||
|
|
||||||
|
|
@ -11,6 +10,9 @@ export default class DualityRoll extends D20Roll {
|
||||||
super(formula, data, options);
|
super(formula, data, options);
|
||||||
this.rallyChoices = this.setRallyChoices();
|
this.rallyChoices = this.setRallyChoices();
|
||||||
this.guaranteedCritical = options.guaranteedCritical;
|
this.guaranteedCritical = options.guaranteedCritical;
|
||||||
|
|
||||||
|
const advantageFaces = data.rules?.roll?.defaultAdvantageDice ? Number.parseInt(data.rules.roll.defaultAdvantageDice) : 6
|
||||||
|
this.advantageFaces = Number.isNaN(advantageFaces) ? 6 : advantageFaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
static messageType = 'dualityRoll';
|
static messageType = 'dualityRoll';
|
||||||
|
|
@ -51,14 +53,6 @@ export default class DualityRoll extends D20Roll {
|
||||||
return this.dice[2] instanceof game.system.api.dice.diceTypes.DisadvantageDie ? this.dice[2] : null;
|
return this.dice[2] instanceof game.system.api.dice.diceTypes.DisadvantageDie ? this.dice[2] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
get advantageFaces() {
|
|
||||||
return this._advantageFaces;
|
|
||||||
}
|
|
||||||
|
|
||||||
set advantageFaces(faces) {
|
|
||||||
this._advantageFaces = this.getFaces(faces);
|
|
||||||
}
|
|
||||||
|
|
||||||
get advantageNumber() {
|
get advantageNumber() {
|
||||||
return this._advantageNumber;
|
return this._advantageNumber;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@
|
||||||
{{/times}}
|
{{/times}}
|
||||||
</select>
|
</select>
|
||||||
<select name="roll.dice.advantageFaces"{{#unless advantage}} disabled{{/unless}}>
|
<select name="roll.dice.advantageFaces"{{#unless advantage}} disabled{{/unless}}>
|
||||||
{{selectOptions diceOptions selected=(concat 'd' @root.roll.advantageFaces)}}
|
{{selectOptions diceFaces selected=@root.roll.advantageFaces}}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
{{#if abilities}}
|
{{#if abilities}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue