Refactor repository layer (and implement garage)

This commit is contained in:
Tau
2019-11-06 17:28:29 -05:00
parent f224e466c5
commit a4a6550abb
31 changed files with 452 additions and 238 deletions
+7 -6
View File
@@ -4,7 +4,7 @@ import { Profile } from "../model/profile";
import { Settings } from "../model/settings";
import { Story } from "../model/story";
import { Team } from "../model/team";
import { TimeAttackState } from "../model/timeAttack";
import { TimeAttackScore } from "../model/timeAttack";
import { Unlocks } from "../model/unlocks";
import { CreateProfileRequest } from "../request/createProfile";
import { GenericResponse } from "../response/generic";
@@ -14,9 +14,11 @@ export async function createProfile(
w: World,
req: CreateProfileRequest
): Promise<GenericResponse> {
const profileId = await w.profile().generateId();
const profile: Profile = {
id: 1 as Id<Profile>,
teamId: 2 as Id<Team>,
id: profileId,
teamId: 2 as Id<Team>, // TODO
name: req.name,
lv: 1,
exp: 0,
@@ -28,17 +30,16 @@ export async function createProfile(
const missions: MissionState = { team: [], solo: [] };
const settings: Settings = { music: 0, pack: 13640, paperCup: 0, gauges: 5 };
const story: Story = { x: 0, y: 0, rows: [] };
const timeAttack: TimeAttackState = { courses: [] };
const unlocks: Unlocks = { cup: 0, gauges: 0, music: 0 };
await Promise.all([
w.profile().save(profile.id, profile),
w.chara().save(profile.id, req.chara),
w.car().save(profile.id, req.car),
w.car().saveCar(profile.id, req.car),
w.car().saveSelection(profile.id, req.car.selector),
w.missions().save(profile.id, missions),
w.settings().save(profile.id, settings),
w.story().save(profile.id, story),
w.timeAttack().save(profile.id, timeAttack),
w.unlocks().save(profile.id, unlocks),
]);