Skip to content

Commit

Permalink
fix(lib:LootTable): constructor can't handle number[]
Browse files Browse the repository at this point in the history
  • Loading branch information
PFiS1737 committed Jul 14, 2024
1 parent a517ce8 commit 99724ab
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/lib/wrapper/LootTable.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ export interface ILootTableItemConfig<T> {
}

export class LootTable<T = number> {
constructor(items: Array<ILootTableItemConfig<T>>) {
constructor(items: Array<ILootTableItemConfig<T>> | number[]) {
if (items) {
for (const item of items) this.addItem(item)
for (const item of items) {
if (typeof item === "number")
this.addItem({
weight: 1,
// @ts-ignore
value: item,
})
else this.addItem(item)
}
}
}

Expand Down

0 comments on commit 99724ab

Please sign in to comment.