Skip to content

Commit

Permalink
6.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Plushtoast committed Oct 30, 2024
1 parent cbd4f13 commit 4e88456
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 76 deletions.
38 changes: 19 additions & 19 deletions bundle/modules/dsa5.js

Large diffs are not rendered by default.

Binary file added icons/categories/enchantment.webp
Binary file not shown.
7 changes: 2 additions & 5 deletions modules/actor/actor-dsa5.js
Original file line number Diff line number Diff line change
Expand Up @@ -1597,10 +1597,7 @@ export default class Actordsa5 extends Actor {
this.setupWeapon(range, 'attack', options, tokenId).then(async (setupData) => {
if (!hasWeaponThrow) {
setupData.testData.source.dmgMultipliers ||= [];
setupData.testData.source.dmgMultipliers.push({
name: 'LocalizedIDs.Throwing Weapons',
val: '0.5',
});
DSA5_Utility.pushOnlyIfUnique(setupData.testData.source.dmgMultipliers, { name: 'LocalizedIDs.Throwing Weapons', val: '0.5', });
}
await this.basicTest(setupData);
});
Expand Down Expand Up @@ -2468,7 +2465,7 @@ export default class Actordsa5 extends Actor {
const oneHanded = game.i18n.localize('wrongGrip.oneHanded');
item.gripDamageText = ` (${oneHanded} * 0.5)`;
item.dmgMultipliers ||= [];
item.dmgMultipliers.push({ name: oneHanded, val: '0.5' });
DSA5_Utility.pushOnlyIfUnique(item.dmgMultipliers, { name: oneHanded, val: '0.5' });
}
break;
default:
Expand Down
36 changes: 18 additions & 18 deletions modules/status/status_effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,24 +320,24 @@ export default class DSA5StatusEffects {
});
}
}

for (const ef of actor.effects) {
if (ef.disabled) continue;

const coreId = [...ef.statuses][0];
if (finishedCoreIds.includes(coreId)) continue;

const effectClass = game.dsa5.config.statusEffectClasses[coreId] || DSA5StatusEffects;
const value = effectClass.calculateRollModifier(ef, actor, item, options);

if (value != 0) {
result.push({
name: ef.name,
value,
selected: effectClass.ModifierIsSelected(item, options, actor),
source,
});
}
}

for (const ef of actor.effects) {
if (ef.disabled) continue;

const coreId = [...ef.statuses][0];
if (finishedCoreIds.includes(coreId)) continue;

const effectClass = game.dsa5.config.statusEffectClasses[coreId] || DSA5StatusEffects;
const value = effectClass.calculateRollModifier(ef, actor, item, options);

if (value != 0) {
result.push({
name: ef.name,
value,
selected: effectClass.ModifierIsSelected(item, options, actor),
source,
});
}
}
const playerOwned = actor.hasPlayerOwner;
Expand Down
5 changes: 1 addition & 4 deletions modules/system/dice-dsa5.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,10 +614,7 @@ export default class DiceDSA5 {
if (val.armorPen) armorPen.push(val.armorPen);
if (val.damageBonus) {
if (/^\*/.test(val.damageBonus)) {
dmgMultipliers.push({
name: val.name,
val: Number(val.damageBonus.replace('*', '')),
});
DSA5_Utility.pushOnlyIfUnique(dmgMultipliers, { name: val.name, val: Number(val.damageBonus.replace('*', '')) });
continue;
}
const isOverride = /^=/.test(val.damageBonus);
Expand Down
49 changes: 28 additions & 21 deletions modules/system/hotbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ export default class DSA5Hotbar extends Hotbar {
break;
case 'effect':
const effect = this.token.actor?.effects.get(data.id);
if (effect) {
description = game.i18n.has(effect.description) ? game.i18n.localize(effect.description) : effect.description;
}
if (effect) description = game.i18n.has(effect.description) ? game.i18n.localize(effect.description) : effect.description;

break;
case 'onUse':
Expand All @@ -161,26 +159,33 @@ export default class DSA5Hotbar extends Hotbar {
case 'weapon':
case 'spell':
item = this.token.actor?.items.get(data.id);

description = $(
await renderTemplate(`systems/dsa5/templates/items/browse/${item.type}.html`, {
isGM: game.user.isGM,
...(await item.sheet.getData()),
document: item,
skipHeader: true,
hint: true,
}),
)
.find('.groupbox')
.html();

const itemData = await item.sheet.getData()

if(!game.user.isGM && itemData.item.system.obfuscation?.details) {
description = await renderTemplate('systems/dsa5/templates/items/obfuscatedItem.html', itemData)
} else {
description = $(
await renderTemplate(`systems/dsa5/templates/items/browse/${item.type}.html`, {
isGM: game.user.isGM,
...itemData,
document: item,
skipHeader: true,
hint: true,
}),
).find('.groupbox').html();
}
break;
case 'enchantment':
const ids = data.id.split('_');
item = this.token.actor?.items.get(ids[0]);
const enchantment = item.getFlag('dsa5', 'enchantments').find((x) => x.id == ids[1]);
data.name = enchantment.name;
description = await renderTemplate('systems/dsa5/templates/items/enchantment-preview.html', { enchantment, document: item });
if(item.system.obfuscation?.enchantment) {
description = await renderTemplate('systems/dsa5/templates/items/obfuscatedItem.html', item)
data.name = `${game.i18n.localize('enchantment')} (${item.name})`
} else {
const enchantment = item.getFlag('dsa5', 'enchantments').find((x) => x.id == ids[1]);
data.name = `${enchantment.name} (${item.name})`;
description = await renderTemplate('systems/dsa5/templates/items/enchantment-preview.html', { enchantment, document: item });
}
break;
default:
return;
Expand Down Expand Up @@ -344,10 +349,10 @@ export default class DSA5Hotbar extends Hotbar {
);
}
if (x.getFlag('dsa5', 'enchantments')) {
if (!groups.skills[x.type]) groups.skills[x.type] = [];
if (!groups.skills['enchantment']) groups.skills['enchantment'] = [];

for (let enchantment of x.getFlag('dsa5', 'enchantments')) {
groups.skills[x.type].push(this.tokenHotbar._enchantmentEntry(enchantment, 'enchantment', x, { subfunction: 'enchantment' }));
groups.skills['enchantment'].push(this.tokenHotbar._enchantmentEntry(enchantment, 'enchantment', x, { subfunction: 'enchantment' }));
}
}
break;
Expand All @@ -369,10 +374,12 @@ export default class DSA5Hotbar extends Hotbar {
const fallbacks = {
gm: 'systems/dsa5/icons/categories/DSA-Auge.webp',
skillgm: 'systems/dsa5/icons/categories/Skill.webp',
enchantment: 'systems/dsa5/icons/categories/enchantment.webp',
};
const fallbackNames = {
gm: 'gmMenu',
skillgm: 'TYPES.Item.skill',
enchantment: 'enchantment'
};

for (let key of Object.keys(groups.skills)) {
Expand Down
4 changes: 2 additions & 2 deletions modules/system/initializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,12 @@ export default class DSA5Initializer extends foundry.applications.api.DialogV2 {
let head = await this.getFolderForType('JournalEntry');
let headReplace = json.folders[0].name;
if (head) {
this.folders[head.data.name] = head;
this.folders[head.name] = head;
json.folders.shift();
}
let createdFolders = await Folder.create(foldersToCreate);
if (!Array.isArray(createdFolders)) createdFolders = [createdFolders];
for (let folder of createdFolders) this.folders[folder.data.name] = folder;
for (let folder of createdFolders) this.folders[folder.name] = folder;

const updates = [];
for (let folder in this.folders) {
Expand Down
8 changes: 8 additions & 0 deletions modules/system/utility-dsa5.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,14 @@ export default class DSA5_Utility {
});
}

static pushOnlyIfUnique(array, object) {
if (!array.find((x) => DSA5_Utility.shallowEquals(x, object))) array.push(object);
}

static shallowEquals(a, b) {
return JSON.stringify(a) == JSON.stringify(b);
}

static escapeRegex(input) {
const source = typeof input === 'string' || input instanceof String ? input : '';
return source.replace(/[-[/\]{}()*+?.,\\^$|#\s]/g, '\\$&');
Expand Down
2 changes: 1 addition & 1 deletion styles/css/dsa5.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion styles/css/dsa5.css.map

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions styles/scss/dsa5.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@use "sass:meta";

:root {
--border-color:#736953a6;
Expand Down Expand Up @@ -4542,6 +4543,6 @@
}
}

@import "./immersive.scss";
@import "./legacy.scss";
@import "./applefix.scss";
@include meta.load-css("immersive.scss");
@include meta.load-css("legacy.scss");
@include meta.load-css("applefix.scss");
4 changes: 2 additions & 2 deletions system.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"id": "dsa5",
"title": "Das Schwarze Auge/The Dark Eye (5th Edition)",
"description": "The \"Das Schwarze Auge\" system for Foundry VTT. Includes all relevant mechanisms to play in the wonderous world of Aventuria and Das Schwarze Auge/The Dark Eye.",
"version": "6.1.4",
"download": "https://github.com/Plushtoast/dsa5-foundryVTT/releases/download/6.1.4/dsa5-foundryVTT-6.1.4.zip",
"version": "6.1.5",
"download": "https://github.com/Plushtoast/dsa5-foundryVTT/releases/download/6.1.5/dsa5-foundryVTT-6.1.5.zip",
"authors": [
{
"name": "Plushtoast"
Expand Down
6 changes: 6 additions & 0 deletions templates/items/enchantment-preview.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ <h4>{{localize 'enchantment'}}</h4>
<div class="col">
<i class="fas fa-{{ifThen enchantment.permanent 'check' 'close'}}"></i>
</div>
<div class="col table-title noBorder">
{{localize "source"}}
</div>
<div class="col">
{{document.name}}
</div>
</div>

0 comments on commit 4e88456

Please sign in to comment.