mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-07 14:36:13 +01:00
Merge 2123ae1965 into 17aa0680d2
This commit is contained in:
commit
374ef6040f
12 changed files with 335 additions and 181 deletions
|
|
@ -251,6 +251,7 @@
|
||||||
"InvalidOldCharacterImportTitle": "Old Character Import",
|
"InvalidOldCharacterImportTitle": "Old Character Import",
|
||||||
"InvalidOldCharacterImportText": "Character data exported prior to system version 1.1 will not generate a complete character. Do you wish to continue?",
|
"InvalidOldCharacterImportText": "Character data exported prior to system version 1.1 will not generate a complete character. Do you wish to continue?",
|
||||||
"cancelBeastform": "Cancel Beastform",
|
"cancelBeastform": "Cancel Beastform",
|
||||||
|
"sidebarFavoritesHint": "Drag items, features and domain cards from the sheet to here",
|
||||||
"resetCharacterConfirmationTitle": "Reset Character",
|
"resetCharacterConfirmationTitle": "Reset Character",
|
||||||
"resetCharacterConfirmationContent": "You are reseting all character data except name and portrait. Are you sure?"
|
"resetCharacterConfirmationContent": "You are reseting all character data except name and portrait. Are you sure?"
|
||||||
},
|
},
|
||||||
|
|
@ -2240,6 +2241,10 @@
|
||||||
"plural": "Experiences"
|
"plural": "Experiences"
|
||||||
},
|
},
|
||||||
"failure": "Failure",
|
"failure": "Failure",
|
||||||
|
"favorite": {
|
||||||
|
"single": "Favorite",
|
||||||
|
"plural": "Favorites"
|
||||||
|
},
|
||||||
"fate": "Fate",
|
"fate": "Fate",
|
||||||
"fateRoll": "Fate Roll",
|
"fateRoll": "Fate Roll",
|
||||||
"fear": "Fear",
|
"fear": "Fear",
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,10 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
{
|
{
|
||||||
dragSelector: '[data-item-id][draggable="true"], [data-item-id] [draggable="true"]',
|
dragSelector: '[data-item-id][draggable="true"], [data-item-id] [draggable="true"]',
|
||||||
dropSelector: null
|
dropSelector: null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dragSelector: null,
|
||||||
|
dropSelector: '.character-sidebar-sheet'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
contextMenus: [
|
contextMenus: [
|
||||||
|
|
@ -260,6 +264,9 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
*/
|
*/
|
||||||
async _prepareSidebarContext(context, _options) {
|
async _prepareSidebarContext(context, _options) {
|
||||||
context.isDeath = this.document.system.deathMoveViable;
|
context.isDeath = this.document.system.deathMoveViable;
|
||||||
|
context.sidebarFavoritesEmpty = this.document.system.sidebarFavorites.length === 0;
|
||||||
|
context.showfavorites = !context.sidebarFavoritesEmpty || this.document.system.usedUnarmed;
|
||||||
|
context.sidebarFavorites = this.document.system.sidebarFavorites.sort((a, b) => a.name.localeCompare(b.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -309,7 +316,9 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
icon: 'fa-solid fa-arrow-up',
|
icon: 'fa-solid fa-arrow-up',
|
||||||
condition: target => {
|
condition: target => {
|
||||||
const doc = getDocFromElementSync(target);
|
const doc = getDocFromElementSync(target);
|
||||||
return doc && doc.system.inVault;
|
const inCharacterSidebar =
|
||||||
|
this.document.type === 'character' && target.closest('.items-sidebar-list');
|
||||||
|
return doc && doc.system.inVault && !inCharacterSidebar;
|
||||||
},
|
},
|
||||||
callback: async target => {
|
callback: async target => {
|
||||||
const doc = await getDocFromElement(target);
|
const doc = await getDocFromElement(target);
|
||||||
|
|
@ -323,7 +332,9 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
icon: 'fa-solid fa-bolt-lightning',
|
icon: 'fa-solid fa-bolt-lightning',
|
||||||
condition: target => {
|
condition: target => {
|
||||||
const doc = getDocFromElementSync(target);
|
const doc = getDocFromElementSync(target);
|
||||||
return doc && doc.system.inVault;
|
const inCharacterSidebar =
|
||||||
|
this.document.type === 'character' && target.closest('.items-sidebar-list');
|
||||||
|
return doc && doc.system.inVault && !inCharacterSidebar;
|
||||||
},
|
},
|
||||||
callback: async (target, event) => {
|
callback: async (target, event) => {
|
||||||
const doc = await getDocFromElement(target);
|
const doc = await getDocFromElement(target);
|
||||||
|
|
@ -362,7 +373,9 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
icon: 'fa-solid fa-arrow-down',
|
icon: 'fa-solid fa-arrow-down',
|
||||||
condition: target => {
|
condition: target => {
|
||||||
const doc = getDocFromElementSync(target);
|
const doc = getDocFromElementSync(target);
|
||||||
return doc && !doc.system.inVault;
|
const inCharacterSidebar =
|
||||||
|
this.document.type === 'character' && target.closest('.items-sidebar-list');
|
||||||
|
return doc && !doc.system.inVault && !inCharacterSidebar;
|
||||||
},
|
},
|
||||||
callback: async target => (await getDocFromElement(target)).update({ 'system.inVault': true })
|
callback: async target => (await getDocFromElement(target)).update({ 'system.inVault': true })
|
||||||
}
|
}
|
||||||
|
|
@ -741,8 +754,6 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
await config.resourceUpdates.updateResources();
|
await config.resourceUpdates.updateResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: redo toggleEquipItem method
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggles the equipped state of an item (armor or weapon).
|
* Toggles the equipped state of an item (armor or weapon).
|
||||||
* @type {ApplicationClickAction}
|
* @type {ApplicationClickAction}
|
||||||
|
|
@ -750,32 +761,14 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
static async #toggleEquipItem(_event, button) {
|
static async #toggleEquipItem(_event, button) {
|
||||||
const item = await getDocFromElement(button);
|
const item = await getDocFromElement(button);
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
if (item.system.equipped) {
|
|
||||||
await item.update({ 'system.equipped': false });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (item.type) {
|
const changedData = await this.document.toggleEquipItem(item);
|
||||||
case 'armor':
|
const removedData = changedData.filter(x => !x.add);
|
||||||
const currentArmor = this.document.system.armor;
|
this.document.update({
|
||||||
if (currentArmor) {
|
'system.sidebarFavorites': [
|
||||||
await currentArmor.update({ 'system.equipped': false });
|
...this.document.system.sidebarFavorites.filter(x => removedData.every(r => r.item.id !== x.id))
|
||||||
}
|
]
|
||||||
|
});
|
||||||
await item.update({ 'system.equipped': true });
|
|
||||||
break;
|
|
||||||
case 'weapon':
|
|
||||||
if (this.document.effects.find(x => !x.disabled && x.type === 'beastform')) {
|
|
||||||
return ui.notifications.warn(
|
|
||||||
game.i18n.localize('DAGGERHEART.UI.Notifications.beastformEquipWeapon')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.document.system.constructor.unequipBeforeEquip.bind(this.document.system)(item);
|
|
||||||
|
|
||||||
await item.update({ 'system.equipped': true });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -835,12 +828,13 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
*/
|
*/
|
||||||
static async #toggleVault(_event, button) {
|
static async #toggleVault(_event, button) {
|
||||||
const doc = await getDocFromElement(button);
|
const doc = await getDocFromElement(button);
|
||||||
const { available } = this.document.system.loadoutSlot;
|
const changedData = await this.document.toggleDomainCardVault(doc);
|
||||||
if (doc.system.inVault && !available && !doc.system.loadoutIgnore) {
|
const removedData = changedData.filter(x => !x.add);
|
||||||
return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.loadoutMaxReached'));
|
this.document.update({
|
||||||
}
|
'system.sidebarFavorites': [
|
||||||
|
...this.document.system.sidebarFavorites.filter(x => removedData.every(r => r.item.id !== x.id))
|
||||||
await doc?.update({ 'system.inVault': !doc.system.inVault });
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -962,6 +956,11 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onDropItem(event, item) {
|
async _onDropItem(event, item) {
|
||||||
|
const sidebarDrop = event.target.closest('.character-sidebar-sheet');
|
||||||
|
if (sidebarDrop) {
|
||||||
|
return this._onSidebarDrop(event, item);
|
||||||
|
}
|
||||||
|
|
||||||
const setupCriticalItemTypes = ['class', 'subclass', 'ancestry', 'community'];
|
const setupCriticalItemTypes = ['class', 'subclass', 'ancestry', 'community'];
|
||||||
if (this.document.system.needsCharacterSetup && setupCriticalItemTypes.includes(item.type)) {
|
if (this.document.system.needsCharacterSetup && setupCriticalItemTypes.includes(item.type)) {
|
||||||
const confirmed = await foundry.applications.api.DialogV2.confirm({
|
const confirmed = await foundry.applications.api.DialogV2.confirm({
|
||||||
|
|
@ -1012,4 +1011,18 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
itemData = itemData instanceof Array ? itemData : [itemData];
|
itemData = itemData instanceof Array ? itemData : [itemData];
|
||||||
return this.document.createEmbeddedDocuments('Item', itemData);
|
return this.document.createEmbeddedDocuments('Item', itemData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _onSidebarDrop(event, item) {
|
||||||
|
if (!item.testUserPermission(game.user, 'OWNER')) return;
|
||||||
|
|
||||||
|
if (!(item instanceof game.system.api.documents.DHItem)) return;
|
||||||
|
if (!this.document.items.get(item.id)) return;
|
||||||
|
|
||||||
|
const allowedItemTypes = ['domainCard', 'feature', 'weapon', 'armor', 'loot', 'consumable'];
|
||||||
|
if (!allowedItemTypes.includes(item.type)) return;
|
||||||
|
|
||||||
|
if (this.document.system.sidebarFavorites.some(x => x.id === item.id)) return;
|
||||||
|
|
||||||
|
this.document.setFavoriteItem(item, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -532,6 +532,40 @@ export default function DHApplicationMixin(Base) {
|
||||||
callback: async target => (await getDocFromElement(target)).toChat(this.document.uuid)
|
callback: async target => (await getDocFromElement(target)).toChat(this.document.uuid)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
options.push({
|
||||||
|
name: 'Unfavorite',
|
||||||
|
icon: 'fa-regular fa-star',
|
||||||
|
condition: target => {
|
||||||
|
const doc = getDocFromElementSync(target);
|
||||||
|
const isFavorited = this.document.system.sidebarFavorites.some(x => x.id === doc.id);
|
||||||
|
return this.document.type === 'character' && isFavorited;
|
||||||
|
},
|
||||||
|
callback: async (target, _event) => {
|
||||||
|
const doc = await getDocFromElement(target);
|
||||||
|
this.document.update({
|
||||||
|
'system.sidebarFavorites': this.document.system.sidebarFavorites.filter(x => x.id !== doc.id)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
options.push({
|
||||||
|
name: 'Favorite',
|
||||||
|
icon: 'fa-solid fa-star',
|
||||||
|
condition: target => {
|
||||||
|
const doc = getDocFromElementSync(target);
|
||||||
|
const isFavorited = this.document.system.sidebarFavorites.some(x => x.id === doc.id);
|
||||||
|
return (
|
||||||
|
!(doc instanceof game.system.api.documents.DhActiveEffect) &&
|
||||||
|
this.document.type === 'character' &&
|
||||||
|
!isFavorited
|
||||||
|
);
|
||||||
|
},
|
||||||
|
callback: async (target, _event) => {
|
||||||
|
const doc = await getDocFromElement(target);
|
||||||
|
this.document.setFavoriteItem(doc, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (deletable)
|
if (deletable)
|
||||||
options.push({
|
options.push({
|
||||||
name: 'CONTROLS.CommonDelete',
|
name: 'CONTROLS.CommonDelete',
|
||||||
|
|
|
||||||
|
|
@ -518,7 +518,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 10,
|
severeThreshold: 10,
|
||||||
hp: 1,
|
hp: 1,
|
||||||
stress: 2,
|
stress: 2,
|
||||||
attack: 2,
|
attack: 2
|
||||||
},
|
},
|
||||||
3: {
|
3: {
|
||||||
difficulty: 2,
|
difficulty: 2,
|
||||||
|
|
@ -526,7 +526,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 15,
|
severeThreshold: 15,
|
||||||
hp: 1,
|
hp: 1,
|
||||||
stress: 0,
|
stress: 0,
|
||||||
attack: 2,
|
attack: 2
|
||||||
},
|
},
|
||||||
4: {
|
4: {
|
||||||
difficulty: 2,
|
difficulty: 2,
|
||||||
|
|
@ -534,7 +534,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 25,
|
severeThreshold: 25,
|
||||||
hp: 1,
|
hp: 1,
|
||||||
stress: 0,
|
stress: 0,
|
||||||
attack: 2,
|
attack: 2
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
horde: {
|
horde: {
|
||||||
|
|
@ -544,7 +544,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 8,
|
severeThreshold: 8,
|
||||||
hp: 2,
|
hp: 2,
|
||||||
stress: 0,
|
stress: 0,
|
||||||
attack: 0,
|
attack: 0
|
||||||
},
|
},
|
||||||
3: {
|
3: {
|
||||||
difficulty: 2,
|
difficulty: 2,
|
||||||
|
|
@ -552,7 +552,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 12,
|
severeThreshold: 12,
|
||||||
hp: 0,
|
hp: 0,
|
||||||
stress: 1,
|
stress: 1,
|
||||||
attack: 1,
|
attack: 1
|
||||||
},
|
},
|
||||||
4: {
|
4: {
|
||||||
difficulty: 2,
|
difficulty: 2,
|
||||||
|
|
@ -560,7 +560,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 15,
|
severeThreshold: 15,
|
||||||
hp: 2,
|
hp: 2,
|
||||||
stress: 0,
|
stress: 0,
|
||||||
attack: 0,
|
attack: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
leader: {
|
leader: {
|
||||||
|
|
@ -570,7 +570,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 10,
|
severeThreshold: 10,
|
||||||
hp: 0,
|
hp: 0,
|
||||||
stress: 0,
|
stress: 0,
|
||||||
attack: 1,
|
attack: 1
|
||||||
},
|
},
|
||||||
3: {
|
3: {
|
||||||
difficulty: 2,
|
difficulty: 2,
|
||||||
|
|
@ -578,7 +578,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 15,
|
severeThreshold: 15,
|
||||||
hp: 1,
|
hp: 1,
|
||||||
stress: 0,
|
stress: 0,
|
||||||
attack: 2,
|
attack: 2
|
||||||
},
|
},
|
||||||
4: {
|
4: {
|
||||||
difficulty: 2,
|
difficulty: 2,
|
||||||
|
|
@ -586,7 +586,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 25,
|
severeThreshold: 25,
|
||||||
hp: 1,
|
hp: 1,
|
||||||
stress: 1,
|
stress: 1,
|
||||||
attack: 3,
|
attack: 3
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
minion: {
|
minion: {
|
||||||
|
|
@ -596,7 +596,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 0,
|
severeThreshold: 0,
|
||||||
hp: 0,
|
hp: 0,
|
||||||
stress: 0,
|
stress: 0,
|
||||||
attack: 1,
|
attack: 1
|
||||||
},
|
},
|
||||||
3: {
|
3: {
|
||||||
difficulty: 2,
|
difficulty: 2,
|
||||||
|
|
@ -604,7 +604,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 0,
|
severeThreshold: 0,
|
||||||
hp: 0,
|
hp: 0,
|
||||||
stress: 1,
|
stress: 1,
|
||||||
attack: 1,
|
attack: 1
|
||||||
},
|
},
|
||||||
4: {
|
4: {
|
||||||
difficulty: 2,
|
difficulty: 2,
|
||||||
|
|
@ -612,7 +612,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 0,
|
severeThreshold: 0,
|
||||||
hp: 0,
|
hp: 0,
|
||||||
stress: 0,
|
stress: 0,
|
||||||
attack: 1,
|
attack: 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ranged: {
|
ranged: {
|
||||||
|
|
@ -622,7 +622,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 6,
|
severeThreshold: 6,
|
||||||
hp: 1,
|
hp: 1,
|
||||||
stress: 0,
|
stress: 0,
|
||||||
attack: 1,
|
attack: 1
|
||||||
},
|
},
|
||||||
3: {
|
3: {
|
||||||
difficulty: 2,
|
difficulty: 2,
|
||||||
|
|
@ -630,7 +630,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 14,
|
severeThreshold: 14,
|
||||||
hp: 1,
|
hp: 1,
|
||||||
stress: 1,
|
stress: 1,
|
||||||
attack: 2,
|
attack: 2
|
||||||
},
|
},
|
||||||
4: {
|
4: {
|
||||||
difficulty: 2,
|
difficulty: 2,
|
||||||
|
|
@ -638,7 +638,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 10,
|
severeThreshold: 10,
|
||||||
hp: 1,
|
hp: 1,
|
||||||
stress: 1,
|
stress: 1,
|
||||||
attack: 1,
|
attack: 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
skulk: {
|
skulk: {
|
||||||
|
|
@ -648,7 +648,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 8,
|
severeThreshold: 8,
|
||||||
hp: 1,
|
hp: 1,
|
||||||
stress: 1,
|
stress: 1,
|
||||||
attack: 1,
|
attack: 1
|
||||||
},
|
},
|
||||||
3: {
|
3: {
|
||||||
difficulty: 2,
|
difficulty: 2,
|
||||||
|
|
@ -656,7 +656,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 12,
|
severeThreshold: 12,
|
||||||
hp: 1,
|
hp: 1,
|
||||||
stress: 1,
|
stress: 1,
|
||||||
attack: 1,
|
attack: 1
|
||||||
},
|
},
|
||||||
4: {
|
4: {
|
||||||
difficulty: 2,
|
difficulty: 2,
|
||||||
|
|
@ -664,7 +664,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 10,
|
severeThreshold: 10,
|
||||||
hp: 1,
|
hp: 1,
|
||||||
stress: 1,
|
stress: 1,
|
||||||
attack: 1,
|
attack: 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
solo: {
|
solo: {
|
||||||
|
|
@ -674,7 +674,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 10,
|
severeThreshold: 10,
|
||||||
hp: 0,
|
hp: 0,
|
||||||
stress: 1,
|
stress: 1,
|
||||||
attack: 2,
|
attack: 2
|
||||||
},
|
},
|
||||||
3: {
|
3: {
|
||||||
difficulty: 2,
|
difficulty: 2,
|
||||||
|
|
@ -682,7 +682,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 15,
|
severeThreshold: 15,
|
||||||
hp: 2,
|
hp: 2,
|
||||||
stress: 1,
|
stress: 1,
|
||||||
attack: 2,
|
attack: 2
|
||||||
},
|
},
|
||||||
4: {
|
4: {
|
||||||
difficulty: 2,
|
difficulty: 2,
|
||||||
|
|
@ -690,7 +690,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 25,
|
severeThreshold: 25,
|
||||||
hp: 0,
|
hp: 0,
|
||||||
stress: 1,
|
stress: 1,
|
||||||
attack: 3,
|
attack: 3
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
standard: {
|
standard: {
|
||||||
|
|
@ -700,7 +700,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 8,
|
severeThreshold: 8,
|
||||||
hp: 0,
|
hp: 0,
|
||||||
stress: 0,
|
stress: 0,
|
||||||
attack: 1,
|
attack: 1
|
||||||
},
|
},
|
||||||
3: {
|
3: {
|
||||||
difficulty: 2,
|
difficulty: 2,
|
||||||
|
|
@ -708,7 +708,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 15,
|
severeThreshold: 15,
|
||||||
hp: 1,
|
hp: 1,
|
||||||
stress: 1,
|
stress: 1,
|
||||||
attack: 1,
|
attack: 1
|
||||||
},
|
},
|
||||||
4: {
|
4: {
|
||||||
difficulty: 2,
|
difficulty: 2,
|
||||||
|
|
@ -716,7 +716,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 15,
|
severeThreshold: 15,
|
||||||
hp: 0,
|
hp: 0,
|
||||||
stress: 1,
|
stress: 1,
|
||||||
attack: 1,
|
attack: 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
support: {
|
support: {
|
||||||
|
|
@ -726,7 +726,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 8,
|
severeThreshold: 8,
|
||||||
hp: 1,
|
hp: 1,
|
||||||
stress: 1,
|
stress: 1,
|
||||||
attack: 1,
|
attack: 1
|
||||||
},
|
},
|
||||||
3: {
|
3: {
|
||||||
difficulty: 2,
|
difficulty: 2,
|
||||||
|
|
@ -734,7 +734,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 12,
|
severeThreshold: 12,
|
||||||
hp: 0,
|
hp: 0,
|
||||||
stress: 0,
|
stress: 0,
|
||||||
attack: 1,
|
attack: 1
|
||||||
},
|
},
|
||||||
4: {
|
4: {
|
||||||
difficulty: 2,
|
difficulty: 2,
|
||||||
|
|
@ -742,7 +742,7 @@ export const adversaryScalingData = {
|
||||||
severeThreshold: 10,
|
severeThreshold: 10,
|
||||||
hp: 1,
|
hp: 1,
|
||||||
stress: 1,
|
stress: 1,
|
||||||
attack: 1,
|
attack: 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -753,16 +753,16 @@ export const adversaryScalingData = {
|
||||||
* We manually set tier 4 data to hopefully lead to better results
|
* We manually set tier 4 data to hopefully lead to better results
|
||||||
*/
|
*/
|
||||||
export const adversaryExpectedDamage = {
|
export const adversaryExpectedDamage = {
|
||||||
basic: {
|
basic: {
|
||||||
1: { mean: 7.321428571428571, deviation: 1.962519002770912 },
|
1: { mean: 7.321428571428571, deviation: 1.962519002770912 },
|
||||||
2: { mean: 12.444444444444445, deviation: 2.0631069425529676 },
|
2: { mean: 12.444444444444445, deviation: 2.0631069425529676 },
|
||||||
3: { mean: 15.722222222222221, deviation: 2.486565208464823 },
|
3: { mean: 15.722222222222221, deviation: 2.486565208464823 },
|
||||||
4: { mean: 26, deviation: 5.2 }
|
4: { mean: 26, deviation: 5.2 }
|
||||||
},
|
},
|
||||||
minion: {
|
minion: {
|
||||||
1: { mean: 2.142857142857143, deviation: 1.0690449676496976 },
|
1: { mean: 2.142857142857143, deviation: 1.0690449676496976 },
|
||||||
2: { mean: 5, deviation: 0.816496580927726 },
|
2: { mean: 5, deviation: 0.816496580927726 },
|
||||||
3: { mean: 6.5, deviation: 2.1213203435596424 },
|
3: { mean: 6.5, deviation: 2.1213203435596424 },
|
||||||
4: { mean: 11, deviation: 1 }
|
4: { mean: 11, deviation: 1 }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import DhCreature from './creature.mjs';
|
||||||
import { attributeField, resourceField, stressDamageReductionRule, bonusField } from '../fields/actorField.mjs';
|
import { attributeField, resourceField, stressDamageReductionRule, bonusField } from '../fields/actorField.mjs';
|
||||||
import { ActionField } from '../fields/actionField.mjs';
|
import { ActionField } from '../fields/actionField.mjs';
|
||||||
import DHCharacterSettings from '../../applications/sheets-configs/character-settings.mjs';
|
import DHCharacterSettings from '../../applications/sheets-configs/character-settings.mjs';
|
||||||
|
import ForeignDocumentUUIDArrayField from '../fields/foreignDocumentUUIDArrayField.mjs';
|
||||||
|
|
||||||
export default class DhCharacter extends DhCreature {
|
export default class DhCharacter extends DhCreature {
|
||||||
/**@override */
|
/**@override */
|
||||||
|
|
@ -317,7 +318,8 @@ export default class DhCharacter extends DhCreature {
|
||||||
hint: 'DAGGERHEART.ACTORS.Character.roll.guaranteedCritical.hint'
|
hint: 'DAGGERHEART.ACTORS.Character.roll.guaranteedCritical.hint'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
}),
|
||||||
|
sidebarFavorites: new ForeignDocumentUUIDArrayField({ type: 'Item' })
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -586,28 +588,6 @@ export default class DhCharacter extends DhCreature {
|
||||||
return diceTypes[attackDiceIndex];
|
return diceTypes[attackDiceIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
static async unequipBeforeEquip(itemToEquip) {
|
|
||||||
const primary = this.primaryWeapon,
|
|
||||||
secondary = this.secondaryWeapon;
|
|
||||||
if (itemToEquip.system.secondary) {
|
|
||||||
if (primary && primary.burden === CONFIG.DH.GENERAL.burden.twoHanded.value) {
|
|
||||||
await primary.update({ 'system.equipped': false });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (secondary) {
|
|
||||||
await secondary.update({ 'system.equipped': false });
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (secondary && itemToEquip.system.burden === CONFIG.DH.GENERAL.burden.twoHanded.value) {
|
|
||||||
await secondary.update({ 'system.equipped': false });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (primary) {
|
|
||||||
await primary.update({ 'system.equipped': false });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
prepareBaseData() {
|
prepareBaseData() {
|
||||||
this.evasion += this.class.value?.system?.evasion ?? 0;
|
this.evasion += this.class.value?.system?.evasion ?? 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -992,4 +992,111 @@ export default class DhpActor extends Actor {
|
||||||
|
|
||||||
return allTokens;
|
return allTokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async toggleDomainCardVault(card, options = { render: true }) {
|
||||||
|
const { render } = options;
|
||||||
|
const { available } = this.system.loadoutSlot;
|
||||||
|
|
||||||
|
if (card.system.inVault && !available && !card.system.loadoutIgnore) {
|
||||||
|
return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.loadoutMaxReached'));
|
||||||
|
}
|
||||||
|
|
||||||
|
const toVault = options.toVault ?? !card.system.inVault;
|
||||||
|
await card?.update({ 'system.inVault': toVault }, { render });
|
||||||
|
return [{ item: card, add: !toVault }];
|
||||||
|
}
|
||||||
|
|
||||||
|
async unequipBeforeEquip(itemToEquip, options = { render: true }) {
|
||||||
|
const { render } = options;
|
||||||
|
|
||||||
|
const primary = this.system.primaryWeapon,
|
||||||
|
secondary = this.system.secondaryWeapon;
|
||||||
|
let unequippedItems = [];
|
||||||
|
if (itemToEquip.system.secondary) {
|
||||||
|
if (primary && primary.system.burden === CONFIG.DH.GENERAL.burden.twoHanded.value) {
|
||||||
|
unequippedItems.push(primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (secondary) {
|
||||||
|
unequippedItems.push(secondary);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (secondary && itemToEquip.system.burden === CONFIG.DH.GENERAL.burden.twoHanded.value) {
|
||||||
|
unequippedItems.push(secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (primary) {
|
||||||
|
unequippedItems.push(primary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const item of unequippedItems) await item?.update({ 'system.equipped': false }, { render });
|
||||||
|
|
||||||
|
return unequippedItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
async toggleEquipItem(item, options = { render: true }) {
|
||||||
|
const { render } = options;
|
||||||
|
const changedItems = [];
|
||||||
|
const updateAndAddChangedItem = async (item, equip) => {
|
||||||
|
changedItems.push({ item, add: equip });
|
||||||
|
await item.update({ 'system.equipped': equip }, { render });
|
||||||
|
};
|
||||||
|
|
||||||
|
if (item.system.equipped && [undefined, false].includes(options.equip)) {
|
||||||
|
await updateAndAddChangedItem(item, false);
|
||||||
|
return changedItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (item.type) {
|
||||||
|
case 'armor':
|
||||||
|
const currentArmor = this.system.armor;
|
||||||
|
if (currentArmor) {
|
||||||
|
await updateAndAddChangedItem(currentArmor, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
await updateAndAddChangedItem(item, true);
|
||||||
|
break;
|
||||||
|
case 'weapon':
|
||||||
|
if (this.effects.find(x => !x.disabled && x.type === 'beastform')) {
|
||||||
|
return ui.notifications.warn(
|
||||||
|
game.i18n.localize('DAGGERHEART.UI.Notifications.beastformEquipWeapon')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const unequippedItems = await this.unequipBeforeEquip(item, { render: false });
|
||||||
|
changedItems.push(...unequippedItems.map(x => ({ item: x, add: false })));
|
||||||
|
await updateAndAddChangedItem(item, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return changedItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This is very convoluted, and there is almost certainly a better way to do it. I couldn't get it working any better way atm though. */
|
||||||
|
async setFavoriteItem(item, setFavorited) {
|
||||||
|
const favoritesToRemove = [];
|
||||||
|
const favoritesToAdd = [];
|
||||||
|
if (['weapon', 'armor'].includes(item.type)) {
|
||||||
|
const changedData = await this.toggleEquipItem(item, { render: false, equip: setFavorited });
|
||||||
|
for (const data of changedData) {
|
||||||
|
if (data.add) favoritesToAdd.push(data.item);
|
||||||
|
else favoritesToRemove.push(data.item);
|
||||||
|
}
|
||||||
|
} else if (item.type === 'domainCard') {
|
||||||
|
const changedData = await this.toggleDomainCardVault(item, { render: false, toVault: !setFavorited });
|
||||||
|
for (const data of changedData) {
|
||||||
|
if (data.add) favoritesToAdd.push(data.item);
|
||||||
|
else favoritesToRemove.push(data.item);
|
||||||
|
}
|
||||||
|
} else if (setFavorited) favoritesToAdd.push(item);
|
||||||
|
else favoritesToRemove.push(item);
|
||||||
|
|
||||||
|
this.update({
|
||||||
|
'system.sidebarFavorites': [
|
||||||
|
...this.system.sidebarFavorites.filter(x => favoritesToRemove.every(r => r.id !== x.id)),
|
||||||
|
...favoritesToAdd
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -229,5 +229,11 @@ export default class DHItem extends foundry.documents.Item {
|
||||||
|
|
||||||
async _preDelete() {
|
async _preDelete() {
|
||||||
this.deleteTriggers();
|
this.deleteTriggers();
|
||||||
|
|
||||||
|
if (this.parent?.type === 'character') {
|
||||||
|
const filteredFavorites = this.parent.system.sidebarFavorites.filter(x => x.id !== this.id);
|
||||||
|
if (this.parent.system.sidebarFavorites.length !== filteredFavorites.length)
|
||||||
|
this.parent.update({ 'system.sidebarFavorites': filteredFavorites });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -552,7 +552,6 @@
|
||||||
.shortcut-items-section {
|
.shortcut-items-section {
|
||||||
overflow-y: hidden;
|
overflow-y: hidden;
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
padding-bottom: 20px;
|
|
||||||
mask-image: linear-gradient(0deg, transparent 0%, black 5%);
|
mask-image: linear-gradient(0deg, transparent 0%, black 5%);
|
||||||
scrollbar-gutter: stable;
|
scrollbar-gutter: stable;
|
||||||
scrollbar-width: thin;
|
scrollbar-width: thin;
|
||||||
|
|
@ -561,6 +560,26 @@
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
scrollbar-color: light-dark(@dark-blue, @golden) transparent;
|
scrollbar-color: light-dark(@dark-blue, @golden) transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.empty-favorites {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border: 1px dashed light-dark(@dark-blue-50, @beige-50);
|
||||||
|
border-radius: 3px;
|
||||||
|
color: light-dark(@dark-blue-50, @beige-50);
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
margin-left: 4px;
|
||||||
|
padding: 4px 0;
|
||||||
|
|
||||||
|
span {
|
||||||
|
width: 250px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.equipment-section,
|
.equipment-section,
|
||||||
|
|
|
||||||
|
|
@ -143,10 +143,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.risk-it-all-button {
|
.risk-it-all-button {
|
||||||
width: -webkit-fill-available;
|
width: -webkit-fill-available;
|
||||||
margin: 0 8px;
|
margin: 0 8px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,63 +99,51 @@
|
||||||
<div class="equipment-section">
|
<div class="equipment-section">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<side-line-div class="invert"></side-line-div>
|
<side-line-div class="invert"></side-line-div>
|
||||||
<h3>{{localize "DAGGERHEART.GENERAL.equipment"}}</h3>
|
<h3>{{localize "DAGGERHEART.GENERAL.favorite.plural"}}</h3>
|
||||||
<side-line-div></side-line-div>
|
<side-line-div></side-line-div>
|
||||||
</div>
|
</div>
|
||||||
<ul class="items-sidebar-list">
|
<ul class="items-sidebar-list">
|
||||||
{{#if document.system.usedUnarmed}}
|
{{#if this.document.system.usedUnarmed}}
|
||||||
{{> 'daggerheart.inventory-item-compact'
|
{{> 'daggerheart.inventory-item-compact'
|
||||||
item=document.system.usedUnarmed
|
item=this.document.system.usedUnarmed
|
||||||
type='attack'
|
type="attack"
|
||||||
}}
|
}}
|
||||||
{{/if}}
|
|
||||||
{{#each document.items as |item|}}
|
|
||||||
{{#if item.system.equipped}}
|
|
||||||
{{> 'daggerheart.inventory-item-compact'
|
|
||||||
item=item
|
|
||||||
type=item.type
|
|
||||||
}}
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{#each sidebarFavorites as |item|}}
|
||||||
|
{{> 'daggerheart.inventory-item-compact'
|
||||||
|
item=item
|
||||||
|
type=item.type
|
||||||
|
}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
|
{{#if sidebarFavoritesEmpty}}
|
||||||
|
<div class="empty-favorites">
|
||||||
|
<span>{{localize "DAGGERHEART.ACTORS.Character.sidebarFavoritesHint"}}</span>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
<div class="loadout-section">
|
</div>
|
||||||
<div class="title">
|
|
||||||
<side-line-div class="invert"></side-line-div>
|
|
||||||
<h3>{{localize "DAGGERHEART.GENERAL.loadout"}}</h3>
|
|
||||||
<side-line-div></side-line-div>
|
|
||||||
</div>
|
|
||||||
<ul class="items-sidebar-list">
|
|
||||||
{{#each document.system.domainCards.loadout as |card|}}
|
|
||||||
{{> 'daggerheart.inventory-item-compact'
|
|
||||||
item=card
|
|
||||||
type='domainCard'
|
|
||||||
}}
|
|
||||||
|
|
||||||
{{/each}}
|
<div class="experience-section">
|
||||||
</ul>
|
<div class="title">
|
||||||
|
<side-line-div class="invert"></side-line-div>
|
||||||
|
<h3>{{localize "DAGGERHEART.GENERAL.experience.single"}}</h3>
|
||||||
|
<side-line-div></side-line-div>
|
||||||
</div>
|
</div>
|
||||||
<div class="experience-section">
|
<div class="experience-list">
|
||||||
<div class="title">
|
{{#each document.system.experiences as |experience id|}}
|
||||||
<side-line-div class="invert"></side-line-div>
|
<div class="experience-row" data-tooltip-text="{{experience.description}}">
|
||||||
<h3>{{localize "DAGGERHEART.GENERAL.experience.single"}}</h3>
|
<span class="experience-value">
|
||||||
<side-line-div></side-line-div>
|
{{numberFormat experience.value sign=true}}
|
||||||
</div>
|
</span>
|
||||||
<div class="experience-list">
|
<span class="experience-name">{{experience.name}}</span>
|
||||||
{{#each document.system.experiences as |experience id|}}
|
<div class="controls">
|
||||||
<div class="experience-row" data-tooltip-text="{{experience.description}}">
|
<a data-action="sendExpToChat" data-type="experience" data-id="{{id}}">
|
||||||
<span class="experience-value">
|
<i class="fa-regular fa-message"></i>
|
||||||
{{numberFormat experience.value sign=true}}
|
</a>
|
||||||
</span>
|
|
||||||
<span class="experience-name">{{experience.name}}</span>
|
|
||||||
<div class="controls">
|
|
||||||
<a data-action="sendExpToChat" data-type="experience" data-id="{{id}}">
|
|
||||||
<i class="fa-regular fa-message"></i>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
</div>
|
||||||
</div>
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
|
|
@ -58,11 +58,6 @@
|
||||||
data-tooltip="DAGGERHEART.UI.Tooltip.{{ifThen item.system.equipped 'unequip' 'equip' }}">
|
data-tooltip="DAGGERHEART.UI.Tooltip.{{ifThen item.system.equipped 'unequip' 'equip' }}">
|
||||||
<i class="fa-solid fa-fw fa-shield"></i>
|
<i class="fa-solid fa-fw fa-shield"></i>
|
||||||
</a>
|
</a>
|
||||||
{{else if (eq type 'domainCard')}}
|
|
||||||
<a data-action="toggleVault"
|
|
||||||
data-tooltip="DAGGERHEART.UI.Tooltip.{{ifThen item.system.inVault 'sendToLoadout' 'sendToVault' }}">
|
|
||||||
<i class="fa-solid fa-fw {{ifThen item.system.inVault 'fa-arrow-up' 'fa-arrow-down'}}"></i>
|
|
||||||
</a>
|
|
||||||
{{else if (eq type 'effect')}}
|
{{else if (eq type 'effect')}}
|
||||||
<a data-action="toggleEffect"
|
<a data-action="toggleEffect"
|
||||||
data-tooltip="DAGGERHEART.UI.Tooltip.{{ifThen item.disabled 'enableEffect' 'disableEffect' }}">
|
data-tooltip="DAGGERHEART.UI.Tooltip.{{ifThen item.disabled 'enableEffect' 'disableEffect' }}">
|
||||||
|
|
|
||||||
|
|
@ -5,38 +5,41 @@
|
||||||
* Maybe if future book monsters can be part of what we release, we can analyze those too.
|
* Maybe if future book monsters can be part of what we release, we can analyze those too.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import fs from "fs/promises";
|
import fs from 'fs/promises';
|
||||||
import path from "path";
|
import path from 'path';
|
||||||
|
|
||||||
const allData = [];
|
const allData = [];
|
||||||
|
|
||||||
// Read adversary pack data for average damage for attacks
|
// Read adversary pack data for average damage for attacks
|
||||||
const adversariesDirectory = path.join("src/packs/adversaries");
|
const adversariesDirectory = path.join('src/packs/adversaries');
|
||||||
for (const basefile of await fs.readdir(adversariesDirectory)) {
|
for (const basefile of await fs.readdir(adversariesDirectory)) {
|
||||||
if (!basefile.endsWith(".json")) continue;
|
if (!basefile.endsWith('.json')) continue;
|
||||||
const filepath = path.join(adversariesDirectory, basefile);
|
const filepath = path.join(adversariesDirectory, basefile);
|
||||||
const data = JSON.parse(await fs.readFile(filepath, "utf8"));
|
const data = JSON.parse(await fs.readFile(filepath, 'utf8'));
|
||||||
if (data?.type !== "adversary" || data.system.type === "social") continue;
|
if (data?.type !== 'adversary' || data.system.type === 'social') continue;
|
||||||
|
|
||||||
allData.push({
|
allData.push({
|
||||||
name: data.name,
|
name: data.name,
|
||||||
tier: data.system.tier,
|
tier: data.system.tier,
|
||||||
adversaryType: data.system.type,
|
adversaryType: data.system.type,
|
||||||
damage: parseDamage(data.system.attack.damage),
|
damage: parseDamage(data.system.attack.damage)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const adversaryTypes = new Set(allData.map(a => a.adversaryType));
|
const adversaryTypes = new Set(allData.map(a => a.adversaryType));
|
||||||
for (const type of [...adversaryTypes].toSorted()) {
|
for (const type of [...adversaryTypes].toSorted()) {
|
||||||
const perTier = Object.groupBy(allData.filter(a => a.adversaryType === type), a => a.tier);
|
const perTier = Object.groupBy(
|
||||||
console.log(`${type} per Tier: ${[1, 2, 3, 4].map(t => perTier[t]?.length ?? 0).join(" ")}`)
|
allData.filter(a => a.adversaryType === type),
|
||||||
|
a => a.tier
|
||||||
|
);
|
||||||
|
console.log(`${type} per Tier: ${[1, 2, 3, 4].map(t => perTier[t]?.length ?? 0).join(' ')}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = {
|
const result = {
|
||||||
basic: compileData(allData.filter(d => d.adversaryType !== "minion")),
|
basic: compileData(allData.filter(d => d.adversaryType !== 'minion')),
|
||||||
solos_and_bruisers: compileData(allData.filter(d => ["solo", "bruiser"].includes(d.adversaryType))),
|
solos_and_bruisers: compileData(allData.filter(d => ['solo', 'bruiser'].includes(d.adversaryType))),
|
||||||
leader_and_ranged: compileData(allData.filter(d => ["leader", "ranged"].includes(d.adversaryType))),
|
leader_and_ranged: compileData(allData.filter(d => ['leader', 'ranged'].includes(d.adversaryType))),
|
||||||
minion: compileData(allData.filter(d => d.adversaryType === "minion")),
|
minion: compileData(allData.filter(d => d.adversaryType === 'minion'))
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(result);
|
console.log(result);
|
||||||
|
|
@ -52,7 +55,7 @@ function compileData(entries) {
|
||||||
if (tier === 4) console.log(allDamage);
|
if (tier === 4) console.log(allDamage);
|
||||||
results[tier] = {
|
results[tier] = {
|
||||||
mean,
|
mean,
|
||||||
deviation: getStandardDeviation(allDamage, { mean }),
|
deviation: getStandardDeviation(allDamage, { mean })
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -64,7 +67,7 @@ function removeOutliers(data) {
|
||||||
const startIdx = Math.floor(data.length * 0.25);
|
const startIdx = Math.floor(data.length * 0.25);
|
||||||
const endIdx = Math.ceil(data.length * 0.75);
|
const endIdx = Math.ceil(data.length * 0.75);
|
||||||
const iqrBound = (data[endIdx] - data[startIdx]) * 1.25;
|
const iqrBound = (data[endIdx] - data[startIdx]) * 1.25;
|
||||||
return data.filter((d) => d >= data[startIdx] - iqrBound && d <= data[endIdx] + iqrBound);
|
return data.filter(d => d >= data[startIdx] - iqrBound && d <= data[endIdx] + iqrBound);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMedian(numbers) {
|
function getMedian(numbers) {
|
||||||
|
|
@ -84,7 +87,7 @@ function getMedianAverageDeviation(numbers, { median }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStandardDeviation(numbers, { mean }) {
|
function getStandardDeviation(numbers, { mean }) {
|
||||||
const deviations = numbers.map((r) => r - mean);
|
const deviations = numbers.map(r => r - mean);
|
||||||
return Math.sqrt(deviations.reduce((r, d) => r + d * d, 0) / (numbers.length - 1));
|
return Math.sqrt(deviations.reduce((r, d) => r + d * d, 0) / (numbers.length - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,8 +98,8 @@ function parseDamage(damage) {
|
||||||
p.value.custom.enabled
|
p.value.custom.enabled
|
||||||
? p.value.custom.formula
|
? p.value.custom.formula
|
||||||
: [p.value.flatMultiplier ? `${p.value.flatMultiplier}${p.value.dice}` : 0, p.value.bonus ?? 0]
|
: [p.value.flatMultiplier ? `${p.value.flatMultiplier}${p.value.dice}` : 0, p.value.bonus ?? 0]
|
||||||
.filter(p => !!p)
|
.filter(p => !!p)
|
||||||
.join('+')
|
.join('+')
|
||||||
)
|
)
|
||||||
.join('+');
|
.join('+');
|
||||||
return getExpectedDamage(formula);
|
return getExpectedDamage(formula);
|
||||||
|
|
@ -107,13 +110,17 @@ function parseDamage(damage) {
|
||||||
* All subtracted terms become negative terms.
|
* All subtracted terms become negative terms.
|
||||||
*/
|
*/
|
||||||
function getExpectedDamage(formula) {
|
function getExpectedDamage(formula) {
|
||||||
const terms = formula.replace("+", " + ").replace("-", " - ").split(" ").map(t => t.trim());
|
const terms = formula
|
||||||
|
.replace('+', ' + ')
|
||||||
|
.replace('-', ' - ')
|
||||||
|
.split(' ')
|
||||||
|
.map(t => t.trim());
|
||||||
let multiplier = 1;
|
let multiplier = 1;
|
||||||
return terms.reduce((total, term) => {
|
return terms.reduce((total, term) => {
|
||||||
if (term === "-") {
|
if (term === '-') {
|
||||||
multiplier = -1;
|
multiplier = -1;
|
||||||
return total;
|
return total;
|
||||||
} else if (term === "+") {
|
} else if (term === '+') {
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue