idz: Support multiple major versions
Doesn't actually add support for any additional versions, but it does lay the groundwork.
This commit is contained in:
@@ -26,7 +26,9 @@ export async function _fixupPrevTeam(
|
||||
// (need to look up new leader's db id from aime id. ick)
|
||||
|
||||
const newLeader = remaining[remaining.length - 1];
|
||||
const newLeaderId = await w.profile().find(newLeader.profile.aimeId);
|
||||
const newLeaderId = await w
|
||||
.profile()
|
||||
.find(newLeader.profile.aimeId, newLeader.profile.version);
|
||||
|
||||
await w.teamMembers().makeLeader(prevTeamId, newLeaderId);
|
||||
}
|
||||
|
||||
@@ -44,9 +44,9 @@ export async function createAutoTeam(
|
||||
req: CreateAutoTeamRequest
|
||||
): Promise<CreateAutoTeamResponse> {
|
||||
const now = new Date();
|
||||
const { aimeId } = req;
|
||||
const { aimeId, version } = req;
|
||||
|
||||
const peek = await w.teamAuto().peek();
|
||||
const peek = await w.teamAuto().peek(version);
|
||||
let nextAuto: TeamAuto;
|
||||
|
||||
//
|
||||
@@ -100,6 +100,7 @@ export async function createAutoTeam(
|
||||
// Register the new team, make the requestor its leader
|
||||
|
||||
const spec = {
|
||||
version,
|
||||
name,
|
||||
nameBg: autoTeams[nameIdx].nameBg,
|
||||
nameFx: 0,
|
||||
|
||||
@@ -11,11 +11,12 @@ export async function createProfile(
|
||||
w: Repositories,
|
||||
req: CreateProfileRequest
|
||||
): Promise<GenericResponse> {
|
||||
const { aimeId, name } = req;
|
||||
const { aimeId, version, name } = req;
|
||||
const now = new Date();
|
||||
|
||||
const profile: Profile = {
|
||||
aimeId,
|
||||
version,
|
||||
name,
|
||||
lv: 1,
|
||||
exp: 0,
|
||||
|
||||
@@ -7,7 +7,7 @@ export async function createTeam(
|
||||
w: Repositories,
|
||||
req: CreateTeamRequest
|
||||
): Promise<CreateTeamResponse> {
|
||||
const profileId = await w.profile().find(req.aimeId);
|
||||
const profileId = await w.profile().find(req.aimeId, req.version);
|
||||
const prevTeamId = await w.teamMembers().findTeam(profileId);
|
||||
const now = new Date();
|
||||
|
||||
@@ -15,6 +15,7 @@ export async function createTeam(
|
||||
|
||||
const teamSpec = {
|
||||
name: req.teamName,
|
||||
version: req.version,
|
||||
nameBg: req.nameBg,
|
||||
nameFx: 0,
|
||||
registerTime: now,
|
||||
|
||||
@@ -6,7 +6,7 @@ export async function discoverProfile(
|
||||
w: Repositories,
|
||||
req: DiscoverProfileRequest
|
||||
): Promise<DiscoverProfileResponse> {
|
||||
const profileId = await w.profile().peek(req.aimeId);
|
||||
const profileId = await w.profile().peek(req.aimeId, req.version);
|
||||
|
||||
return {
|
||||
type: "discover_profile_res",
|
||||
|
||||
@@ -6,7 +6,7 @@ export async function loadGarage(
|
||||
w: Repositories,
|
||||
req: LoadGarageRequest
|
||||
): Promise<LoadGarageResponse> {
|
||||
const profileId = await w.profile().find(req.aimeId);
|
||||
const profileId = await w.profile().find(req.aimeId, req.version);
|
||||
|
||||
return {
|
||||
type: "load_garage_res",
|
||||
|
||||
@@ -6,9 +6,9 @@ export async function loadProfile(
|
||||
w: Repositories,
|
||||
req: LoadProfileRequest
|
||||
): Promise<LoadProfileResponse> {
|
||||
const { aimeId } = req;
|
||||
const { aimeId, version } = req;
|
||||
|
||||
const profileId = await w.profile().find(aimeId);
|
||||
const profileId = await w.profile().find(aimeId, version);
|
||||
const teamId = await w.teamMembers().findTeam(profileId);
|
||||
const leaderId = teamId && (await w.teamMembers().findLeader(teamId));
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ export async function loadStocker(
|
||||
w: Repositories,
|
||||
req: LoadStockerRequest
|
||||
): Promise<LoadStockerResponse> {
|
||||
const profileId = await w.profile().find(req.aimeId);
|
||||
const profileId = await w.profile().find(req.aimeId, req.version);
|
||||
const backgrounds = await w.backgrounds().loadAll(profileId);
|
||||
|
||||
return {
|
||||
|
||||
@@ -4,30 +4,29 @@ import { LoadTeamRequest } from "../request/loadTeam";
|
||||
import { LoadTeamResponse } from "../response/loadTeam";
|
||||
import { Repositories } from "../repo";
|
||||
|
||||
// Even if a profile does not belong to a team, a team must still be loaded
|
||||
// (and then ignored by the client).
|
||||
|
||||
const dummyResp: LoadTeamResponse = {
|
||||
type: "load_team_res",
|
||||
team: {
|
||||
extId: 0 as ExtId<Team>,
|
||||
name: "",
|
||||
nameBg: 0,
|
||||
nameFx: 0,
|
||||
registerTime: new Date(0),
|
||||
},
|
||||
members: [],
|
||||
};
|
||||
|
||||
export async function loadTeam(
|
||||
w: Repositories,
|
||||
req: LoadTeamRequest
|
||||
): Promise<LoadTeamResponse> {
|
||||
if (req.teamExtId === undefined) {
|
||||
return dummyResp;
|
||||
// Even if a profile does not belong to a team, a team must still be loaded
|
||||
// (and then ignored by the client).
|
||||
|
||||
return {
|
||||
type: "load_team_res",
|
||||
team: {
|
||||
extId: 0 as ExtId<Team>,
|
||||
version: req.version,
|
||||
name: "",
|
||||
nameBg: 0,
|
||||
nameFx: 0,
|
||||
registerTime: new Date(0),
|
||||
},
|
||||
members: [],
|
||||
};
|
||||
}
|
||||
|
||||
const teamId = await w.teams().find(req.teamExtId);
|
||||
const teamId = await w.teams().find(req.teamExtId, req.version);
|
||||
|
||||
return {
|
||||
type: "load_team_res",
|
||||
|
||||
@@ -6,7 +6,7 @@ export async function saveNewCar(
|
||||
w: Repositories,
|
||||
req: SaveNewCarRequest
|
||||
): Promise<SaveNewCarResponse> {
|
||||
const profileId = await w.profile().find(req.aimeId);
|
||||
const profileId = await w.profile().find(req.aimeId, req.version);
|
||||
|
||||
await w.car().saveCar(profileId, req.car);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ export async function saveProfile(
|
||||
req: SaveProfileRequest
|
||||
): Promise<GenericResponse> {
|
||||
const now = new Date();
|
||||
const profileId = await w.profile().find(req.aimeId);
|
||||
const profileId = await w.profile().find(req.aimeId, req.version);
|
||||
const profile = await w.profile().load(profileId);
|
||||
const chara = await w.chara().load(profileId);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ export async function saveSettings(
|
||||
w: Repositories,
|
||||
req: SaveSettingsRequest
|
||||
): Promise<GenericResponse> {
|
||||
const profileId = await w.profile().find(req.aimeId);
|
||||
const profileId = await w.profile().find(req.aimeId, req.version);
|
||||
|
||||
await w.settings().save(profileId, req.settings);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ export async function saveStocker(
|
||||
w: Repositories,
|
||||
req: SaveStockerRequest
|
||||
): Promise<GenericResponse> {
|
||||
const profileId = await w.profile().find(req.aimeId);
|
||||
const profileId = await w.profile().find(req.aimeId, req.version);
|
||||
|
||||
await Promise.all([
|
||||
w.backgrounds().saveAll(profileId, req.backgrounds),
|
||||
|
||||
@@ -6,7 +6,7 @@ export async function saveTeamBanner(
|
||||
w: Repositories,
|
||||
req: SaveTeamBannerRequest
|
||||
): Promise<GenericResponse> {
|
||||
const teamId = await w.teams().find(req.teamExtId);
|
||||
const teamId = await w.teams().find(req.teamExtId, req.version);
|
||||
const orig = await w.teams().load(teamId);
|
||||
|
||||
await w.teams().save(teamId, {
|
||||
|
||||
@@ -14,7 +14,7 @@ export async function saveTimeAttack(
|
||||
// avoidance time warping stuff
|
||||
|
||||
const now = new Date();
|
||||
const profileId = await w.profile().find(req.aimeId);
|
||||
const profileId = await w.profile().find(req.aimeId, req.version);
|
||||
|
||||
await w.timeAttack().save(profileId, { ...req.payload, timestamp: now });
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ export async function updateTeamLeader(
|
||||
w: Repositories,
|
||||
req: UpdateTeamLeaderRequest
|
||||
): Promise<UpdateTeamLeaderResponse> {
|
||||
const profileId = await w.profile().find(req.aimeId);
|
||||
const teamId = await w.teams().find(req.teamExtId);
|
||||
const profileId = await w.profile().find(req.aimeId, req.version);
|
||||
const teamId = await w.teams().find(req.teamExtId, req.version);
|
||||
|
||||
await w.teamMembers().makeLeader(teamId, profileId);
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ export async function updateTeamMember(
|
||||
req: UpdateTeamMemberRequest
|
||||
): Promise<UpdateTeamMemberResponse> {
|
||||
const now = new Date();
|
||||
const profileId = await w.profile().find(req.aimeId);
|
||||
const teamId = await w.teams().find(req.teamExtId);
|
||||
const profileId = await w.profile().find(req.aimeId, req.version);
|
||||
const teamId = await w.teams().find(req.teamExtId, req.version);
|
||||
|
||||
switch (req.action) {
|
||||
case "add":
|
||||
|
||||
Reference in New Issue
Block a user