initial commit
This commit is contained in:
commit
803205ee7f
59 changed files with 3437 additions and 0 deletions
41
src/lib/Quest.ts
Normal file
41
src/lib/Quest.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import { type Slug, Slugs } from "@/lib/slug";
|
||||
import { Model, table, column, loadInterceptor } from "@/lib/Model";
|
||||
import { Questline } from "@/lib/Questline";
|
||||
|
||||
@table("quests")
|
||||
export class Quest extends Model {
|
||||
@column() public name!: string;
|
||||
@column() public completed!: boolean;
|
||||
@column() public claimed!: boolean;
|
||||
@column("sort_order") public sortOrder: number | undefined;
|
||||
@column("coins_reward") public coinsReward!: number;
|
||||
@column("questline_id") public questlineId!: DbId;
|
||||
|
||||
public readonly slug: Slug;
|
||||
public constructor(id: DbId) {
|
||||
super(id);
|
||||
this.slug = Slugs.encode(this.id);
|
||||
}
|
||||
|
||||
public get questline() {
|
||||
return new Questline(this.questlineId);
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
static load(id: DbId): Quest {
|
||||
return new Proxy<Quest>(new Quest(id), loadInterceptor);
|
||||
}
|
||||
|
||||
static requiredFields: {
|
||||
name: string;
|
||||
coinsReward: number;
|
||||
questlineId: DbId;
|
||||
completed: boolean;
|
||||
claimed: boolean;
|
||||
} | null = null;
|
||||
|
||||
static build(obj: Exclude<typeof Quest.requiredFields, null>) {
|
||||
return Model.builder(this, obj);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue