generated from maximegris/angular-electron
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
preliminary implementation of dynamic event chains
- Loading branch information
Showing
32 changed files
with
667 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { | ||
DynamicEventRarity, | ||
DynamicEventSuccessTypeType, | ||
IDynamicEventMeta, | ||
} from '../../interfaces'; | ||
import { id } from './id'; | ||
|
||
export const defaultEvent: () => IDynamicEventMeta = () => ({ | ||
_id: id(), | ||
cooldown: 0, | ||
description: '', | ||
duration: 0, | ||
endMessage: '', | ||
name: '', | ||
rarity: DynamicEventRarity.Common, | ||
startMessage: '', | ||
conflicts: [], | ||
extraData: {}, | ||
map: undefined as unknown as string, | ||
npc: undefined as unknown as string, | ||
|
||
requiresPreviousEvent: false, | ||
spawnEventOnFailure: undefined as unknown as string, | ||
spawnEventOnSuccess: undefined as unknown as string, | ||
|
||
successMetrics: { | ||
count: 0, | ||
killNPCs: [], | ||
type: undefined as unknown as DynamicEventSuccessTypeType, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/app/shared/components/input-event/input-event.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<div class="relative"> | ||
<ng-select class="form-control" [items]="values()" [(ngModel)]="event" groupBy="category" | ||
placeholder="Select event..." (change)="change.emit($event?.value)" [compareWith]="itemCompare" [searchFn]="search"> | ||
|
||
<ng-template ng-label-tmp let-item="item"> | ||
<div class="relative"> | ||
<div class="text-white"> | ||
{{ item.value }} | ||
</div> | ||
</div> | ||
</ng-template> | ||
|
||
<ng-template ng-option-tmp let-item="item"> | ||
<div class="relative"> | ||
<div class="text-white"> | ||
{{ item.value }} | ||
</div> | ||
|
||
<p class="text-white text-sm italic whitespace-break-spaces">{{ item.desc }}</p> | ||
</div> | ||
</ng-template> | ||
</ng-select> | ||
|
||
<app-input-floating-label>{{ label() }}</app-input-floating-label> | ||
</div> |
File renamed without changes.
72 changes: 72 additions & 0 deletions
72
src/app/shared/components/input-event/input-event.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { | ||
Component, | ||
computed, | ||
inject, | ||
input, | ||
model, | ||
OnInit, | ||
output, | ||
} from '@angular/core'; | ||
import { sortBy } from 'lodash'; | ||
import { IDynamicEventMeta } from '../../../../interfaces'; | ||
import { ModService } from '../../../services/mod.service'; | ||
|
||
@Component({ | ||
selector: 'app-input-event', | ||
templateUrl: './input-event.component.html', | ||
styleUrl: './input-event.component.scss', | ||
}) | ||
export class InputEventComponent implements OnInit { | ||
private modService = inject(ModService); | ||
|
||
public event = model<IDynamicEventMeta | undefined>(); | ||
public defaultValue = input<string>(); | ||
public label = input<string>('Event'); | ||
public change = output<string>(); | ||
|
||
public values = computed(() => { | ||
const mod = this.modService.mod(); | ||
const activeDependencies = this.modService.activeDependencies(); | ||
|
||
const myModEvents = mod.events.map((i) => ({ | ||
category: `${mod.meta.name} (Current)`, | ||
data: i, | ||
value: i.name, | ||
desc: i.description, | ||
index: 0, | ||
})); | ||
|
||
const depEvents = activeDependencies | ||
.map((dep, idx) => | ||
dep.events.map((i) => ({ | ||
category: dep.meta.name, | ||
data: i, | ||
value: i.name, | ||
desc: i.description, | ||
index: idx + 1, | ||
})) | ||
) | ||
.flat(); | ||
|
||
return [...sortBy([...myModEvents, ...depEvents], ['index', 'value'])]; | ||
}); | ||
|
||
ngOnInit() { | ||
const defaultItem = this.defaultValue(); | ||
if (defaultItem) { | ||
const foundItem = this.values().find((i) => i.value === defaultItem); | ||
this.event.set(foundItem as unknown as IDynamicEventMeta); | ||
} | ||
} | ||
|
||
public itemCompare( | ||
itemA: { value: string; desc: string }, | ||
itemB: { value: string; desc: string } | ||
): boolean { | ||
return itemA.value === itemB.value; | ||
} | ||
|
||
public search(term: string, item: { value: string }) { | ||
return item.value.toLowerCase().includes(term.toLowerCase()); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/app/shared/components/input-eventrarity/input-eventrarity.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div class="relative"> | ||
<ng-select class="form-control" [items]="values" [(ngModel)]="rarity" [clearable]="false" | ||
placeholder="Select event rarity..." (change)="change.emit($event)"></ng-select> | ||
|
||
<app-input-floating-label>Event Rarity</app-input-floating-label> | ||
</div> |
Empty file.
17 changes: 17 additions & 0 deletions
17
src/app/shared/components/input-eventrarity/input-eventrarity.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Component, model, output } from '@angular/core'; | ||
import { | ||
DynamicEventRarity, | ||
DynamicEventRarityType, | ||
} from '../../../../interfaces'; | ||
|
||
@Component({ | ||
selector: 'app-input-eventrarity', | ||
templateUrl: './input-eventrarity.component.html', | ||
styleUrl: './input-eventrarity.component.scss', | ||
}) | ||
export class InputEventRarityComponent { | ||
public rarity = model.required<DynamicEventRarityType | undefined>(); | ||
public change = output<DynamicEventRarityType>(); | ||
|
||
public values = [...Object.values(DynamicEventRarity).sort()]; | ||
} |
6 changes: 6 additions & 0 deletions
6
src/app/shared/components/input-eventsuccesstype/input-eventsuccesstype.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div class="relative"> | ||
<ng-select class="form-control" [items]="values" [(ngModel)]="successType" placeholder="Select success type..." | ||
(change)="change.emit($event?.value)"></ng-select> | ||
|
||
<app-input-floating-label>{{ label() }}</app-input-floating-label> | ||
</div> |
Empty file.
15 changes: 15 additions & 0 deletions
15
src/app/shared/components/input-eventsuccesstype/input-eventsuccesstype.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Component, input, model, output } from '@angular/core'; | ||
import { DynamicEventSuccessType } from '../../../../interfaces'; | ||
|
||
@Component({ | ||
selector: 'app-input-eventsuccesstype', | ||
templateUrl: './input-eventsuccesstype.component.html', | ||
styleUrl: './input-eventsuccesstype.component.scss', | ||
}) | ||
export class InputEventSuccessTypeComponent { | ||
public successType = model.required<string | undefined>(); | ||
public label = input<string>('Success Type'); | ||
public change = output<string>(); | ||
|
||
public values = [...Object.values(DynamicEventSuccessType)]; | ||
} |
23 changes: 0 additions & 23 deletions
23
src/app/shared/components/input-gameevent/input-gameevent.component.html
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
src/app/shared/components/input-gameevent/input-gameevent.component.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.