mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
* Updated the background image for the system * Fixed so Weapon/Armor features are added again * Fixed so fear is available as a resource to be deducted by actions (#757) * Changed to use the config labels and src * Updated Weapons * Fixed so the decrease button of simple fear tracker is not visible when not hovered * Fixed so armor preUpdate doesn't fail if no system changes are made * Updated .gitignore and author details (#777) * Add author details and name mapping for chrisryan10 (#773) Co-authored-by: Chris Ryan <chrisr@blackhole> * Add build to ignore for my linux dev (#775) Co-authored-by: Chris Ryan <chrisr@blackhole> --------- Co-authored-by: Chris Ryan <chrisr@blackhole> * Corrected sneak attack active effect (#780) * Fixed a spelling error (#779) * Fix bardic rally showing in damage dialog when it should not (#783) * update spelling (#786) * Translating inventory descriptions (#782) * updated credits for 1.0.1 release (#797) * updated credits for 1.0.1 release * further updated artwork credits * Chagned handlebarhelper rollparsed to be more defensive (#794) * Added missing scene refreshType (#790) * Remove ability use buttons for not owned abilities (#795) * [Fix] PrayerDice Fixed (#799) * Fixed prayer dice, and wheelchair images * Fixed -settings data sources * Dragging features from one adversary to another (#788) * [Fix] Levelup Fixes (#787) * Fixed crash on experience selection. Fixed subclass error on multiclassing * Fixed so multiclasses do not gain the hope feature for the class * Fixed so Class/Subclass features are properly deleted on delevel * Removed automatic deletion of features on delevel when not using levelup auto * Fixed so custom domains can be selected in levelup when multiclassing * Changed so encounter countdowns is a button (#804) * Fixed so that dropping on class/subclass...creates the item on the character (#803) * [BUG] - Importing All Adversaries/Environments (#814) Fixes #774 Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com> * Bug/671 reaction roll chat title (#809) * Update Reaction Roll Chat Message Title * Removed console log --------- Co-authored-by: WBHarry <williambjrklund@gmail.com> * Improve Trait tooltip display (#817) Fixes #806 Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com> * [BUG] - Combat Tracker d12 logo not found (#812) Fixes #764 Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com> * Compendium Browser (#821) * Corrected timbending description localization (#816) * [Fix] Compendium Item (#810) * Corrected Emberwoven Armor * Fixed subclass regression * Fixed so character's with wildcard images don't break beastform (#815) * Fix roll result based duality damage (#822) --------- Co-authored-by: Chris Ryan <73275196+chrisryan10@users.noreply.github.com> Co-authored-by: Chris Ryan <chrisr@blackhole> Co-authored-by: Dapoulp <74197441+Dapoulp@users.noreply.github.com> Co-authored-by: IrkTheImp <41175833+IrkTheImp@users.noreply.github.com> Co-authored-by: CPTN_Cosmo <cptncosmo@gmail.com> Co-authored-by: Josh Q. <jshqntnr13@gmail.com> Co-authored-by: joaquinpereyra98 <24190917+joaquinpereyra98@users.noreply.github.com> Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com>
163 lines
8.4 KiB
JavaScript
163 lines
8.4 KiB
JavaScript
import BaseLevelUp from './levelup.mjs';
|
|
import { defaultCompanionTier, LevelOptionType } from '../../data/levelTier.mjs';
|
|
import { DhLevelup } from '../../data/levelup.mjs';
|
|
import { diceTypes, range } from '../../config/generalConfig.mjs';
|
|
|
|
export default class DhCompanionLevelUp extends BaseLevelUp {
|
|
constructor(actor) {
|
|
super(actor);
|
|
|
|
this.levelTiers = this.addBonusChoices(defaultCompanionTier);
|
|
const playerLevelupData = actor.system.levelData;
|
|
this.levelup = new DhLevelup(DhLevelup.initializeData(this.levelTiers, playerLevelupData));
|
|
}
|
|
|
|
async _preparePartContext(partId, context) {
|
|
await super._preparePartContext(partId, context);
|
|
|
|
const currentLevel = this.levelup.levels[this.levelup.currentLevel];
|
|
switch (partId) {
|
|
case 'selections':
|
|
const advancementChoices = Object.keys(currentLevel.choices).reduce((acc, choiceKey) => {
|
|
Object.keys(currentLevel.choices[choiceKey]).forEach(checkboxNr => {
|
|
const checkbox = currentLevel.choices[choiceKey][checkboxNr];
|
|
const data = {
|
|
...checkbox,
|
|
path: `levels.${this.levelup.currentLevel}.choices.${choiceKey}.${checkboxNr}`,
|
|
level: this.levelup.currentLevel
|
|
};
|
|
|
|
if (!acc[choiceKey]) acc[choiceKey] = [];
|
|
acc[choiceKey].push(data);
|
|
});
|
|
|
|
return acc;
|
|
}, {});
|
|
|
|
const experienceIncreases = Object.values(advancementChoices.experience ?? {});
|
|
const experienceIncreaseValues = experienceIncreases
|
|
.filter(exp => exp.data.length > 0)
|
|
.flatMap(exp =>
|
|
exp.data.map(data => {
|
|
const experience = Object.keys(this.actor.system.experiences)[data];
|
|
return this.actor.system.experiences[experience].name;
|
|
})
|
|
);
|
|
context.experienceIncreases = {
|
|
values: experienceIncreaseValues,
|
|
active: experienceIncreases.length > 0,
|
|
progress: {
|
|
selected: experienceIncreaseValues.length,
|
|
max: experienceIncreases.reduce((acc, exp) => acc + exp.amount, 0)
|
|
}
|
|
};
|
|
|
|
context.newExperiences = Object.keys(currentLevel.achievements.experiences).map(key => {
|
|
const experience = currentLevel.achievements.experiences[key];
|
|
return {
|
|
...experience,
|
|
level: this.levelup.currentLevel,
|
|
key: key
|
|
};
|
|
});
|
|
|
|
context.vicious = advancementChoices.vicious ? Object.values(advancementChoices.vicious) : null;
|
|
context.viciousChoices = {
|
|
damage: game.i18n.localize('DAGGERHEART.APPLICATIONS.Levelup.selections.viciousDamage'),
|
|
range: game.i18n.localize('DAGGERHEART.APPLICATIONS.Levelup.selections.viciousRange')
|
|
};
|
|
|
|
break;
|
|
case 'summary':
|
|
const levelKeys = Object.keys(this.levelup.levels);
|
|
const actorDamageDice = this.actor.system.attack.damage.parts[0].value.dice;
|
|
const actorRange = this.actor.system.attack.range;
|
|
const advancement = {};
|
|
for (var levelKey of levelKeys) {
|
|
const level = this.levelup.levels[levelKey];
|
|
if (Number(levelKey) < this.levelup.startLevel) continue;
|
|
|
|
for (var choiceKey of Object.keys(level.choices)) {
|
|
const choice = level.choices[choiceKey];
|
|
for (var checkbox of Object.values(choice)) {
|
|
switch (choiceKey) {
|
|
case 'stress':
|
|
case 'evasion':
|
|
advancement[choiceKey] = advancement[choiceKey]
|
|
? advancement[choiceKey] + Number(checkbox.value)
|
|
: Number(checkbox.value);
|
|
break;
|
|
case 'experience':
|
|
if (!advancement[choiceKey]) advancement[choiceKey] = [];
|
|
const data = checkbox.data.map(data => {
|
|
const experience = Object.keys(this.actor.system.experiences).find(
|
|
x => x === data
|
|
);
|
|
return this.actor.system.experiences[experience]?.name ?? '';
|
|
});
|
|
advancement[choiceKey].push({ data: data, value: checkbox.value });
|
|
break;
|
|
case 'vicious':
|
|
if (!advancement[choiceKey]) advancement[choiceKey] = { damage: null, range: null };
|
|
const isDamage = checkbox.data[0] === 'damage';
|
|
const options = isDamage ? diceTypes : range;
|
|
const keys = Object.keys(options);
|
|
const actorKey = keys.indexOf(isDamage ? actorDamageDice : actorRange);
|
|
const currentIndex = advancement[choiceKey][checkbox.data[0]]
|
|
? keys.indexOf(advancement[choiceKey][checkbox.data[0]])
|
|
: actorKey;
|
|
advancement[choiceKey][checkbox.data[0]] =
|
|
options[keys[Math.min(currentIndex + 1, keys.length - 1)]];
|
|
default:
|
|
if (!advancement.simple) advancement.simple = {};
|
|
advancement.simple[choiceKey] = game.i18n.localize(
|
|
LevelOptionType[checkbox.type].label
|
|
);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
context.advancements = {
|
|
statistics: {
|
|
stress: {
|
|
old: this.actor.system.resources.stress.max,
|
|
new: this.actor.system.resources.stress.max + (advancement.stress ?? 0)
|
|
},
|
|
evasion: {
|
|
old: this.actor.system.evasion,
|
|
new: this.actor.system.evasion + (advancement.evasion ?? 0)
|
|
}
|
|
},
|
|
experiences:
|
|
advancement.experience?.flatMap(x => x.data.map(data => ({ name: data, modifier: x.value }))) ??
|
|
[],
|
|
vicious: {
|
|
damage: advancement.vicious?.damage
|
|
? {
|
|
old: actorDamageDice,
|
|
new: advancement.vicious.damage
|
|
}
|
|
: null,
|
|
range: advancement.vicious?.range
|
|
? {
|
|
old: game.i18n.localize(`DAGGERHEART.CONFIG.Range.${actorRange}.name`),
|
|
new: game.i18n.localize(advancement.vicious.range.label)
|
|
}
|
|
: null
|
|
},
|
|
simple: advancement.simple ?? {}
|
|
};
|
|
|
|
context.advancements.statistics.stress.shown =
|
|
context.advancements.statistics.stress.new > context.advancements.statistics.stress.old;
|
|
context.advancements.statistics.evasion.shown =
|
|
context.advancements.statistics.evasion.new > context.advancements.statistics.evasion.old;
|
|
context.advancements.statistics.shown =
|
|
context.advancements.statistics.stress.shown || context.advancements.statistics.evasion.shown;
|
|
}
|
|
|
|
return context;
|
|
}
|
|
}
|