Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Damaging Items to Override Graze Damage #108

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
306c5b2
feat(graze damage override): added initial data model and input field…
zithith Oct 23, 2024
365dd38
feat(graze damage): moved override input into the hasSkillRoll condit…
zithith Oct 25, 2024
98811bd
feat(graze damage): Added separate roll for graze damage when overridden
zithith Oct 28, 2024
b43b612
feat(graze damage): fixed item sheet display toggle
zithith Oct 28, 2024
e402daf
feat(graze damage): Added support for multiple damage rolls with attr…
zithith Nov 2, 2024
87b7747
Merge branch 'release-0.1.2' of https://github.com/zithith/cosmere-rp…
zithith Nov 2, 2024
3d7a6be
feat(graze damage): reverted base damage calculation to a simpler app…
zithith Nov 2, 2024
72f2ddb
chore: added missed null value check
zithith Nov 2, 2024
c735273
feat(graze damage): added hint description to graze override input
zithith Nov 3, 2024
ebcbb4c
feat(graze damage): spread the damage rolls sent to chat cards
zithith Nov 3, 2024
64961a6
feat(graze damage): new approach to building graze rolls.
zithith Nov 10, 2024
bf761c3
chore: removed old comment
zithith Nov 10, 2024
5cd9382
feat(graze overrides): updated damage roll class to account for exist…
zithith Nov 12, 2024
5da4e43
feat(graze damage): updated items to store damage.dice better and ali…
zithith Nov 12, 2024
d0a67ef
feat(graze damage): added ability for damage rolls to filter multiple…
zithith Nov 12, 2024
dd45443
chore: updated damaging items to use new filter function rather than …
zithith Nov 12, 2024
50edf61
feat(graze damage): streamlined a bit of the damage option calculatio…
zithith Nov 12, 2024
4447074
Update hint wording to reflect new variables
zithith Nov 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,11 @@
},
"Damage": {
"Title": "Damage",
"Formula": "Damage Formula"
"Formula": "Damage Formula",
"GrazeOverride": "Override Graze Damage Calculation",
"GrazeShow": "Show New Graze Damage Formula",
"GrazeHide": "Hide New Graze Damage Forumla",
"GrazeFormula": "New Formula"
},
"Modality": {
"Title": "Modality",
Expand Down
23 changes: 23 additions & 0 deletions src/style/sheets/item/module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,29 @@ app-item-properties {
}
}

app-item-details-damage {
.form-group-stacked {
.header {
display: flex;
align-items: center;

label {
font-weight: bold;
flex: 2;
}

span {
zithith marked this conversation as resolved.
Show resolved Hide resolved
flex: 3;
font-style: italic;
}

.controls {
margin-right: 0.5rem;
}
}
}
}

app-item-details-equip {
.form-group-stacked {
.header {
Expand Down
18 changes: 18 additions & 0 deletions src/system/applications/item/components/details-damage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ export class DetailsDamageComponent extends HandlebarsApplicationComponent<
static TEMPLATE =
'systems/cosmere-rpg/templates/item/components/details-damage.hbs';

/* eslint-disable @typescript-eslint/unbound-method */
static ACTIONS = {
'toggle-graze-collapsed': DetailsDamageComponent.onToggleGrazeCollapsed,
};
/* eslint-enable @typescript-eslint/unbound-method */
private grazeOverrideCollapsed = true;

/* --- Actions --- */

private static onToggleGrazeCollapsed(this: DetailsDamageComponent) {
this.grazeOverrideCollapsed = !this.grazeOverrideCollapsed;
void this.render();
}

/* --- Context --- */

public _prepareContext(params: never, context: BaseItemSheetRenderContext) {
Expand All @@ -34,6 +48,10 @@ export class DetailsDamageComponent extends HandlebarsApplicationComponent<
return {
hasSkillTest,
hasSkill,
grazeInputCollapsed:
this.grazeOverrideCollapsed ||
this.application.item.system.damage.grazeOverrideFormula !==
undefined,

typeSelectOptions: {
none: '—',
Expand Down
5 changes: 5 additions & 0 deletions src/system/data/item/mixins/damaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface DamagingItemData {
damage: {
formula?: string;
type?: DamageType;
grazeOverrideFormula?: string;
skill?: Skill;
attribute?: Attribute;
};
Expand All @@ -22,6 +23,10 @@ export function DamagingItemMixin<P extends CosmereItem>() {
nullable: true,
blank: false,
}),
grazeOverrideFormula:
new foundry.data.fields.StringField({
nullable: true,
}),
type: new foundry.data.fields.StringField({
nullable: true,
choices: Object.keys(CONFIG.COSMERE.damageTypes),
Expand Down
33 changes: 33 additions & 0 deletions src/templates/item/components/details-damage.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,37 @@
{{/if}}
</div>
{{/if}}

<div class="form-group-stacked">
<div class="header">
<label>{{localize "COSMERE.Item.Sheet.Damage.GrazeOverride"}}</label>
<div class="controls">
{{#if grazeInputCollapsed}}
<a data-action="toggle-graze-collapsed"
data-tooltip="COSMERE.Item.Sheet.Damage.GrazeShow"
>
<i class="fa-solid fa-chevron-left"></i>
</a>
{{else}}
<a data-action="toggle-graze-collapsed"
data-tooltip="COSMERE.Item.Sheet.Damage.GrazeHide"
>
<i class="fa-solid fa-chevron-down"></i>
</a>
{{/if}}
</div>
</div>
{{#if (not grazeInputCollapsed)}}
<div class="form-group formula">
<label>{{localize "COSMERE.Item.Sheet.Damage.GrazeFormula"}}</label>
<input name="system.damage.grazeOverrideFormula"
type="text"
value="{{item.system.damage.grazeOverrideFormula}}"
{{#if (not editable)}}
readonly
{{/if}}
>
</div>
{{/if}}
</div>
zithith marked this conversation as resolved.
Show resolved Hide resolved
{{/if}}