mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 15:39:02 +01:00
Temp solution for specific weapon feature
This commit is contained in:
parent
85982bac8c
commit
bf74596389
15 changed files with 158 additions and 94 deletions
|
|
@ -56,12 +56,15 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
|
|||
label,
|
||||
icon
|
||||
}));
|
||||
context.modifiers = this.config.modifiers;
|
||||
return context;
|
||||
}
|
||||
|
||||
static updateRollConfiguration(_event, _, formData) {
|
||||
const { ...rest } = foundry.utils.expandObject(formData.object);
|
||||
foundry.utils.mergeObject(this.config.roll, rest.roll);
|
||||
foundry.utils.mergeObject(this.config.modifiers, rest.modifiers);
|
||||
console.log(rest)
|
||||
this.config.selectedRollMode = rest.selectedRollMode;
|
||||
|
||||
this.render();
|
||||
|
|
|
|||
|
|
@ -1041,16 +1041,16 @@ export const weaponFeatures = {
|
|||
mode: 2,
|
||||
value: '-1'
|
||||
},
|
||||
{
|
||||
key: 'system.bonuses.damage.primaryWeapon.extraDice',
|
||||
mode: 2,
|
||||
value: '1'
|
||||
},
|
||||
{
|
||||
key: 'system.rules.weapon.dropLowestDamageDice',
|
||||
mode: 5,
|
||||
value: '1'
|
||||
}
|
||||
// {
|
||||
// key: 'system.bonuses.damage.primaryWeapon.extraDice',
|
||||
// mode: 2,
|
||||
// value: '1'
|
||||
// },
|
||||
// {
|
||||
// key: 'system.rules.weapon.dropLowestDamageDice',
|
||||
// mode: 5,
|
||||
// value: '1'
|
||||
// }
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
@ -1167,16 +1167,16 @@ export const weaponFeatures = {
|
|||
description: 'DAGGERHEART.CONFIG.WeaponFeature.powerful.effects.powerful.description',
|
||||
img: 'icons/magic/control/buff-flight-wings-runes-red-yellow.webp',
|
||||
changes: [
|
||||
{
|
||||
key: 'system.bonuses.damage.primaryWeapon.extraDice',
|
||||
mode: 2,
|
||||
value: '1'
|
||||
},
|
||||
{
|
||||
key: 'system.rules.weapon.dropLowestDamageDice',
|
||||
mode: 5,
|
||||
value: '1'
|
||||
}
|
||||
// {
|
||||
// key: 'system.bonuses.damage.primaryWeapon.extraDice',
|
||||
// mode: 2,
|
||||
// value: '1'
|
||||
// },
|
||||
// {
|
||||
// key: 'system.rules.weapon.dropLowestDamageDice',
|
||||
// mode: 5,
|
||||
// value: '1'
|
||||
// }
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
@ -1302,11 +1302,11 @@ export const weaponFeatures = {
|
|||
description: 'DAGGERHEART.CONFIG.WeaponFeature.selfCorrecting.effects.selfCorrecting.description',
|
||||
img: 'icons/weapons/ammunition/arrow-broadhead-glowing-orange.webp',
|
||||
changes: [
|
||||
{
|
||||
key: 'system.rules.damage.flipMinDiceValue',
|
||||
mode: 5,
|
||||
value: 1
|
||||
}
|
||||
// {
|
||||
// key: 'system.rules.damage.flipMinDiceValue',
|
||||
// mode: 5,
|
||||
// value: 1
|
||||
// }
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
@ -1320,11 +1320,11 @@ export const weaponFeatures = {
|
|||
description: 'DAGGERHEART.CONFIG.WeaponFeature.serrated.effects.serrated.description',
|
||||
img: 'icons/weapons/ammunition/arrow-broadhead-glowing-orange.webp',
|
||||
changes: [
|
||||
{
|
||||
key: 'system.rules.damage.flipMinDiceValue',
|
||||
mode: 5,
|
||||
value: 1
|
||||
}
|
||||
// {
|
||||
// key: 'system.rules.damage.flipMinDiceValue',
|
||||
// mode: 5,
|
||||
// value: 1
|
||||
// }
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -287,18 +287,18 @@ export default class DhCharacter extends BaseDataActor {
|
|||
})
|
||||
})
|
||||
}),
|
||||
weapon: new fields.SchemaField({
|
||||
/* Unimplemented
|
||||
-> Should remove the lowest damage dice from weapon damage
|
||||
-> Reflect this in the chat message somehow so players get feedback that their choice is helping them.
|
||||
*/
|
||||
dropLowestDamageDice: new fields.BooleanField({ initial: false }),
|
||||
/* Unimplemented
|
||||
-> Should flip any lowest possible dice rolls for weapon damage to highest
|
||||
-> Reflect this in the chat message somehow so players get feedback that their choice is helping them.
|
||||
*/
|
||||
flipMinDiceValue: new fields.BooleanField({ intial: false })
|
||||
}),
|
||||
// weapon: new fields.SchemaField({
|
||||
// /* Unimplemented
|
||||
// -> Should remove the lowest damage dice from weapon damage
|
||||
// -> Reflect this in the chat message somehow so players get feedback that their choice is helping them.
|
||||
// */
|
||||
// dropLowestDamageDice: new fields.BooleanField({ initial: false }),
|
||||
// /* Unimplemented
|
||||
// -> Should flip any lowest possible dice rolls for weapon damage to highest
|
||||
// -> Reflect this in the chat message somehow so players get feedback that their choice is helping them.
|
||||
// */
|
||||
// flipMinDiceValue: new fields.BooleanField({ intial: false })
|
||||
// }),
|
||||
runeWard: new fields.BooleanField({ initial: false }),
|
||||
burden: new fields.SchemaField({
|
||||
ignore: new fields.BooleanField()
|
||||
|
|
|
|||
|
|
@ -102,14 +102,14 @@ export default class DamageRoll extends DHRoll {
|
|||
}
|
||||
|
||||
constructFormula(config) {
|
||||
this.options.roll.forEach(part => {
|
||||
this.options.roll.forEach((part, index) => {
|
||||
part.roll = new Roll(Roll.replaceFormulaData(part.formula, config.data));
|
||||
this.constructFormulaPart(config, part);
|
||||
this.constructFormulaPart(config, part, index);
|
||||
});
|
||||
return this.options.roll;
|
||||
}
|
||||
|
||||
constructFormulaPart(config, part) {
|
||||
constructFormulaPart(config, part, index) {
|
||||
part.roll.terms = Roll.parse(part.roll.formula, config.data);
|
||||
|
||||
if (part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
|
||||
|
|
@ -120,6 +120,15 @@ export default class DamageRoll extends DHRoll {
|
|||
});
|
||||
}
|
||||
|
||||
/* To Remove When Reaction System */
|
||||
if(index === 0 && part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id && config.modifiers.rally?.value) {
|
||||
const rallyFaces = config.modifiers.rally.values.find(r => r.value === config.modifiers.rally.value)?.label;
|
||||
part.roll.terms.push(
|
||||
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
|
||||
...this.constructor.parse(`1${rallyFaces}`)
|
||||
);
|
||||
}
|
||||
|
||||
if (part.extraFormula) {
|
||||
part.roll.terms.push(
|
||||
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
|
||||
|
|
@ -132,6 +141,67 @@ export default class DamageRoll extends DHRoll {
|
|||
criticalBonus = tmpRoll.total - this.constructor.calculateTotalModifiers(tmpRoll);
|
||||
part.roll.terms.push(...this.formatModifier(criticalBonus));
|
||||
}
|
||||
|
||||
/* To Remove When Reaction System */
|
||||
if(index === 0 && part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
|
||||
if(config.modifiers.massive?.enabled) config.modifiers.massive.callback(part);
|
||||
if(config.modifiers.powerful?.enabled) config.modifiers.powerful.callback(part);
|
||||
}
|
||||
|
||||
return (part.roll._formula = this.constructor.getFormula(part.roll.terms));
|
||||
}
|
||||
|
||||
/* To Remove When Reaction System */
|
||||
static temporaryModifierBuilder(config) {
|
||||
const mods = {};
|
||||
|
||||
if(config.data?.parent) {
|
||||
if(config.data.parent.appliedEffects) {
|
||||
const effects = config.data.parent.appliedEffects;
|
||||
|
||||
// Bardic Rally
|
||||
mods.rally = {
|
||||
label: "DAGGERHEART.CLASS.Feature.rallyDice",
|
||||
values: config.data?.parent?.appliedEffects.reduce((a, c) => {
|
||||
const change = c.changes.find(ch => ch.key === 'system.bonuses.rally');
|
||||
if (change) a.push({ value: c.id, label: change.value });
|
||||
return a;
|
||||
}, []),
|
||||
value: null,
|
||||
callback: (...args) => {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const item = config.data.parent.items?.get(config.source.item);
|
||||
if(item) {
|
||||
// Massive (Weapon Feature)
|
||||
if(item.effects.has("cffkpiwGpEGhjiUC"))
|
||||
mods.massive = {
|
||||
label: item.effects.get("cffkpiwGpEGhjiUC").name,
|
||||
enabled: true,
|
||||
callback: (part) => {
|
||||
part.roll.terms[0].modifiers.push(`kh${part.roll.terms[0].number}`);
|
||||
part.roll.terms[0].number += 1;
|
||||
}
|
||||
};
|
||||
|
||||
// Powerful (Weapon Feature)
|
||||
if(item.effects.has("DCie5eR1dZH2Qvln"))
|
||||
mods.powerful = {
|
||||
label: item.effects.get("DCie5eR1dZH2Qvln").name,
|
||||
enabled: true,
|
||||
callback: (part) => {
|
||||
part.roll.terms[0].modifiers.push(`kh${part.roll.terms[0].number}`);
|
||||
part.roll.terms[0].number += 1;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
config.modifiers = mods;
|
||||
console.log(config)
|
||||
return mods;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ export default class DHRoll extends Roll {
|
|||
|
||||
this.applyKeybindings(config);
|
||||
|
||||
this.temporaryModifierBuilder(config);
|
||||
|
||||
let roll = new this(config.roll.formula, config.data, config);
|
||||
if (config.dialog.configure !== false) {
|
||||
// Open Roll Dialog
|
||||
|
|
@ -207,6 +209,11 @@ export default class DHRoll extends Roll {
|
|||
}
|
||||
return modifierTotal;
|
||||
}
|
||||
|
||||
static temporaryModifierBuilder(config) {
|
||||
const mods = new Map();
|
||||
return mods;
|
||||
}
|
||||
}
|
||||
|
||||
export const registerRollDiceHooks = () => {
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ export default class DualityRoll extends D20Roll {
|
|||
}
|
||||
if (this.rallyFaces)
|
||||
this.terms.push(
|
||||
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
|
||||
new foundry.dice.terms.OperatorTerm({ operator: this.hasDisadvantage ? '-' : '+' }),
|
||||
new foundry.dice.terms.Die({ faces: this.rallyFaces })
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
"parts": [
|
||||
{
|
||||
"value": {
|
||||
"dice": "d8",
|
||||
"dice": "d10",
|
||||
"bonus": 9,
|
||||
"multiplier": "prof",
|
||||
"flatMultiplier": 1,
|
||||
|
|
|
|||
|
|
@ -12,15 +12,7 @@
|
|||
"equipped": false,
|
||||
"secondary": false,
|
||||
"burden": "twoHanded",
|
||||
"weaponFeatures": [
|
||||
{
|
||||
"value": "cumbersome",
|
||||
"effectIds": [
|
||||
"hl0S2LrBY5Mg69q6"
|
||||
],
|
||||
"actionIds": []
|
||||
}
|
||||
],
|
||||
"weaponFeatures": [],
|
||||
"attack": {
|
||||
"name": "Attack",
|
||||
"img": "icons/skills/melee/blood-slash-foam-red.webp",
|
||||
|
|
@ -51,8 +43,8 @@
|
|||
"parts": [
|
||||
{
|
||||
"value": {
|
||||
"dice": "d10",
|
||||
"bonus": 8,
|
||||
"dice": "d8",
|
||||
"bonus": 9,
|
||||
"multiplier": "prof",
|
||||
"flatMultiplier": 1,
|
||||
"custom": {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
"parts": [
|
||||
{
|
||||
"value": {
|
||||
"dice": "d8",
|
||||
"dice": "d10",
|
||||
"bonus": 6,
|
||||
"multiplier": "prof",
|
||||
"flatMultiplier": 1,
|
||||
|
|
|
|||
|
|
@ -12,15 +12,7 @@
|
|||
"equipped": false,
|
||||
"secondary": false,
|
||||
"burden": "twoHanded",
|
||||
"weaponFeatures": [
|
||||
{
|
||||
"value": "cumbersome",
|
||||
"effectIds": [
|
||||
"8twXPJELZpvFWA5K"
|
||||
],
|
||||
"actionIds": []
|
||||
}
|
||||
],
|
||||
"weaponFeatures": [],
|
||||
"attack": {
|
||||
"name": "Attack",
|
||||
"img": "icons/skills/melee/blood-slash-foam-red.webp",
|
||||
|
|
@ -51,8 +43,8 @@
|
|||
"parts": [
|
||||
{
|
||||
"value": {
|
||||
"dice": "d10",
|
||||
"bonus": 5,
|
||||
"dice": "d8",
|
||||
"bonus": 6,
|
||||
"multiplier": "prof",
|
||||
"flatMultiplier": 1,
|
||||
"custom": {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
"parts": [
|
||||
{
|
||||
"value": {
|
||||
"dice": "d8",
|
||||
"dice": "d10",
|
||||
"bonus": 12,
|
||||
"multiplier": "prof",
|
||||
"flatMultiplier": 1,
|
||||
|
|
|
|||
|
|
@ -12,15 +12,7 @@
|
|||
"equipped": false,
|
||||
"secondary": false,
|
||||
"burden": "twoHanded",
|
||||
"weaponFeatures": [
|
||||
{
|
||||
"value": "cumbersome",
|
||||
"effectIds": [
|
||||
"f44KWDgCQeKYfccr"
|
||||
],
|
||||
"actionIds": []
|
||||
}
|
||||
],
|
||||
"weaponFeatures": [],
|
||||
"attack": {
|
||||
"name": "Attack",
|
||||
"img": "icons/skills/melee/blood-slash-foam-red.webp",
|
||||
|
|
@ -51,8 +43,8 @@
|
|||
"parts": [
|
||||
{
|
||||
"value": {
|
||||
"dice": "d10",
|
||||
"bonus": 11,
|
||||
"dice": "d8",
|
||||
"bonus": 12,
|
||||
"multiplier": "prof",
|
||||
"flatMultiplier": 1,
|
||||
"custom": {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
"parts": [
|
||||
{
|
||||
"value": {
|
||||
"dice": "d8",
|
||||
"dice": "d10",
|
||||
"bonus": 3,
|
||||
"multiplier": "prof",
|
||||
"flatMultiplier": 1,
|
||||
|
|
|
|||
|
|
@ -12,15 +12,7 @@
|
|||
"equipped": false,
|
||||
"secondary": false,
|
||||
"burden": "twoHanded",
|
||||
"weaponFeatures": [
|
||||
{
|
||||
"value": "cumbersome",
|
||||
"effectIds": [
|
||||
"Z5MnVI8EOOgzRdXC"
|
||||
],
|
||||
"actionIds": []
|
||||
}
|
||||
],
|
||||
"weaponFeatures": [],
|
||||
"attack": {
|
||||
"name": "Attack",
|
||||
"img": "icons/skills/melee/blood-slash-foam-red.webp",
|
||||
|
|
@ -51,8 +43,8 @@
|
|||
"parts": [
|
||||
{
|
||||
"value": {
|
||||
"dice": "d10",
|
||||
"bonus": 2,
|
||||
"dice": "d8",
|
||||
"bonus": 3,
|
||||
"multiplier": "prof",
|
||||
"flatMultiplier": 1,
|
||||
"custom": {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,22 @@
|
|||
<input type="text" value="{{extraFormula}}" name="roll.{{ @index }}.extraFormula" placeholder="Situational Bonus">
|
||||
</div>
|
||||
{{/each}}
|
||||
{{#if @root.modifiers}}
|
||||
<fieldset class="modifier-container two-columns">
|
||||
<legend>{{localize "DAGGERHEART.GENERAL.Modifier.plural"}}</legend>
|
||||
{{#each @root.modifiers}}
|
||||
<span class="formula-label">{{ localize label }}</span>
|
||||
{{#if (hasProperty this "values")}}
|
||||
<select name="modifiers.{{@key}}.value">
|
||||
{{selectOptions values blank="" selected=value}}
|
||||
</select>
|
||||
{{/if}}
|
||||
{{#if (hasProperty this "enabled")}}
|
||||
<input type="checkbox" name="modifiers.{{@key}}.enabled" {{ checked enabled }}>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</fieldset>
|
||||
{{/if}}
|
||||
<div class="damage-section-controls">
|
||||
{{#if directDamage}}
|
||||
<select class="roll-mode-select" name="selectedRollMode">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue