idz: Tweak ProfileRepository interface
This commit is contained in:
@@ -1,26 +1,29 @@
|
||||
import { ExtId } from "../model/base";
|
||||
import { MissionState } from "../model/mission";
|
||||
import { Profile } from "../model/profile";
|
||||
import { Settings } from "../model/settings";
|
||||
import { Story } from "../model/story";
|
||||
import { Team } from "../model/team";
|
||||
import { Unlocks } from "../model/unlocks";
|
||||
import { CreateProfileRequest } from "../request/createProfile";
|
||||
import { GenericResponse } from "../response/generic";
|
||||
import { ProfileSpec, Repositories } from "../repo";
|
||||
import { Repositories } from "../repo";
|
||||
|
||||
export async function createProfile(
|
||||
w: Repositories,
|
||||
req: CreateProfileRequest
|
||||
): Promise<GenericResponse> {
|
||||
const { aimeId, name } = req;
|
||||
const now = new Date();
|
||||
const profile: ProfileSpec = {
|
||||
teamId: 2 as ExtId<Team>, // TODO
|
||||
name: req.name,
|
||||
|
||||
const profile: Profile = {
|
||||
aimeId,
|
||||
name,
|
||||
lv: 1,
|
||||
exp: 0,
|
||||
fame: 0,
|
||||
dpoint: 0,
|
||||
mileage: 0,
|
||||
accessTime: now,
|
||||
registerTime: now,
|
||||
};
|
||||
|
||||
const missions: MissionState = { team: [], solo: [] };
|
||||
@@ -33,7 +36,7 @@ export async function createProfile(
|
||||
lastMileageReward: 0,
|
||||
};
|
||||
|
||||
const profileId = await w.profile().create(req.aimeId, profile, now);
|
||||
const profileId = await w.profile().create(profile);
|
||||
|
||||
await w.chara().save(profileId, req.chara);
|
||||
await w.car().saveCar(profileId, req.car);
|
||||
@@ -46,6 +49,6 @@ export async function createProfile(
|
||||
|
||||
return {
|
||||
type: "generic_res",
|
||||
status: req.aimeId, // "Generic response" my fucking *ass*
|
||||
status: aimeId, // "Generic response" my fucking *ass*
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ export async function discoverProfile(
|
||||
w: Repositories,
|
||||
req: DiscoverProfileRequest
|
||||
): Promise<DiscoverProfileResponse> {
|
||||
const profileId = await w.profile().find(req.aimeId);
|
||||
const profileId = await w.profile().peek(req.aimeId);
|
||||
|
||||
return {
|
||||
type: "discover_profile_res",
|
||||
|
||||
@@ -36,7 +36,7 @@ export async function loadProfile(
|
||||
fame: profile.fame,
|
||||
dpoint: profile.dpoint,
|
||||
mileage: profile.mileage,
|
||||
teamId: profile.teamId,
|
||||
// teamId: TODO
|
||||
settings,
|
||||
chara,
|
||||
titles,
|
||||
|
||||
@@ -11,17 +11,15 @@ export async function saveProfile(
|
||||
const profile = await w.profile().load(profileId);
|
||||
const chara = await w.chara().load(profileId);
|
||||
|
||||
await w.profile().save(
|
||||
{
|
||||
...profile,
|
||||
lv: req.lv,
|
||||
exp: req.exp,
|
||||
fame: req.fame,
|
||||
dpoint: req.dpoint,
|
||||
mileage: req.mileage,
|
||||
},
|
||||
now
|
||||
);
|
||||
await w.profile().save(profileId, {
|
||||
...profile,
|
||||
lv: req.lv,
|
||||
exp: req.exp,
|
||||
fame: req.fame,
|
||||
dpoint: req.dpoint,
|
||||
mileage: req.mileage,
|
||||
accessTime: now,
|
||||
});
|
||||
|
||||
await w.chara().save(profileId, {
|
||||
...chara,
|
||||
|
||||
Reference in New Issue
Block a user