Skip to content

Commit

Permalink
closes #28
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Aug 16, 2024
1 parent 4b3c916 commit 39edd23
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/app/tabs/items/items-editor/items-editor.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,36 @@
class="form-input" />
</div>
}

@if(editingData.itemClass === 'Trap') {
<hr class="my-4">

<div class="form-row">
<app-input-effect [defaultValue]="editingData.trapEffect!.name" (change)="editingData.trapEffect!.name = $event"
label="Trap Effect"></app-input-effect>
</div>
}

@if(editingData.trapEffect!.name) {
<div class="form-row">
<app-input-floating-label>Trap Potency</app-input-floating-label>
<input [(ngModel)]="editingData.trapEffect!.potency" type="number" min="0" placeholder="Enter potency..."
class="form-input" />
</div>

<div class="form-row">
<app-input-floating-label>Trap Range</app-input-floating-label>
<input [(ngModel)]="editingData.trapEffect!.range" type="number" min="0" placeholder="Enter range..."
class="form-input" />
</div>

<div class="form-row pl-1">
<label class="label cursor-pointer" floatUi="Positive effects apply to friendly creatures only.">
<input type="checkbox" [(ngModel)]="editingData.trapEffect!.extra!.isPositive" class="checkbox" />
<span class="label-text">Only hits friendly targets</span>
</label>
</div>
}
</div>

<div class="form-column">
Expand Down
12 changes: 12 additions & 0 deletions src/app/tabs/items/items-editor/items-editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ export class ItemsEditorComponent
item.useEffect ??= { name: '', potency: 0, duration: 0 };
item.equipEffect ??= { name: '', potency: 0 };
item.breakEffect ??= { name: '', potency: 0 };
item.trapEffect ??= {
name: '',
potency: 0,
uses: 1,
range: 0,
extra: { isPositive: false },
};

item.requirements ??= { baseClass: undefined, level: 0, quest: undefined };
item.cosmetic ??= { name: '', isPermanent: false };
item.trait ??= { name: '', level: 0 };
Expand Down Expand Up @@ -345,6 +353,10 @@ export class ItemsEditorComponent
delete item.breakEffect;
}

if (item.trapEffect && !item.trapEffect.name) {
delete item.trapEffect;
}

if (
item.requirements &&
!item.requirements.baseClass &&
Expand Down
3 changes: 3 additions & 0 deletions src/interfaces/effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export interface IItemEffectExtra {

// the stats given (food)
statChanges?: StatBlock;

// if the effect is positive
isPositive?: boolean;
}

export interface IItemEffect {
Expand Down

0 comments on commit 39edd23

Please sign in to comment.