idz: Remove profile ext id

Turns out (while researching team creation) the profile ext id
is just the aime id. After creating a team a profile discovery
request is immediately issued with the "profile id" in the field
that holds the aime id during initial profile load.
This commit is contained in:
Tau 2019-05-26 20:05:01 -04:00
parent 7c96253160
commit c2b0bcabc4
70 changed files with 238 additions and 341 deletions

View File

@ -12,7 +12,6 @@ create table "idz"."profile" (
references "aime"."player"("id")
on delete cascade,
-- TODO shop_id
"ext_id" integer not null,
"name" text not null,
"lv" smallint not null,
"exp" integer not null,
@ -21,8 +20,7 @@ create table "idz"."profile" (
"mileage" integer not null,
"register_time" timestamp not null,
"access_time" timestamp not null,
constraint "profile_player_uq" unique ("player_id"),
constraint "profile_ext_id_uq" unique ("ext_id")
constraint "profile_player_uq" unique ("player_id")
);
create table "idz"."chara" (

View File

@ -1,2 +1,2 @@
create table "meta" ("schemaver" integer not null);
insert into "meta" values (1);
insert into "meta" values (2);

View File

@ -0,0 +1,3 @@
alter table "idz"."profile" drop column "ext_id";
update "meta" set "schemaver" = 1;

View File

@ -3,7 +3,7 @@ import { Pool, PoolClient } from "pg";
export type Id<T> = bigint & { __id: T };
const currentSchemaVer = 0;
const currentSchemaVer = 1;
const pool = new Pool();
const fence = testConnection();

View File

@ -1,25 +0,0 @@
import * as sql from "sql-bricks";
import { ClientBase } from "pg";
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { Id } from "../../db";
export async function _findProfile(
conn: ClientBase,
extId: ExtId<Profile>
): Promise<Id<Profile>> {
const lookupSql = sql
.select("r.id")
.from("idz.profile r")
.where("r.ext_id", extId)
.toParams();
const { rows } = await conn.query(lookupSql);
if (rows.length > 0) {
return rows[0].id as Id<Profile>;
} else {
throw new Error("Profile not found");
}
}

View File

@ -1,22 +1,21 @@
import { ClientBase } from "pg";
import * as sql from "sql-bricks";
import { _findProfile } from "./_util";
import { BackgroundCode, ExtId } from "../model/base";
import { BackgroundCode } from "../model/base";
import { Profile } from "../model/profile";
import { FlagRepository } from "../repo";
import { generateId } from "../../db";
import { generateId, Id } from "../../db";
export class SqlBackgroundsRepository
implements FlagRepository<BackgroundCode> {
constructor(private readonly _conn: ClientBase) {}
async loadAll(extId: ExtId<Profile>): Promise<Set<BackgroundCode>> {
async loadAll(id: Id<Profile>): Promise<Set<BackgroundCode>> {
const loadSql = sql
.select("bg.background_no")
.from("idz.background_unlock bg")
.join("idz.profile p", { "bg.profile_id": "p.id" })
.where("p.ext_id", extId)
.where("p.id", id)
.toParams();
const { rows } = await this._conn.query(loadSql);
@ -30,11 +29,10 @@ export class SqlBackgroundsRepository
}
async saveAll(
extId: ExtId<Profile>,
profileId: Id<Profile>,
flags: Set<BackgroundCode>
): Promise<void> {
const profileId = await _findProfile(this._conn, extId);
const existing = await this.loadAll(extId);
const existing = await this.loadAll(profileId);
for (const flag of flags) {
if (existing.has(flag)) {

View File

@ -1,12 +1,10 @@
import { ClientBase } from "pg";
import * as sql from "sql-bricks-postgres";
import { _findProfile } from "./_util";
import { ExtId } from "../model/base";
import { Car, CarSelector } from "../model/car";
import { Profile } from "../model/profile";
import { CarRepository } from "../repo";
import { generateId } from "../../db";
import { generateId, Id } from "../../db";
function _extractRow(row: any): Car {
return {
@ -31,12 +29,11 @@ function _extractRow(row: any): Car {
export class SqlCarRepository implements CarRepository {
constructor(private readonly _conn: ClientBase) {}
async countCars(extId: ExtId<Profile>): Promise<number> {
async countCars(profileId: Id<Profile>): Promise<number> {
const countSql = sql
.select("count(*) result")
.from("idz.car c")
.join("idz.profile p", { "c.profile_id": "p.id" })
.where("p.ext_id", extId)
.where("c.profile_id", profileId)
.toParams();
const { rows } = await this._conn.query(countSql);
@ -45,12 +42,11 @@ export class SqlCarRepository implements CarRepository {
return parseInt(row.result, 10);
}
async loadAllCars(extId: ExtId<Profile>): Promise<Car[]> {
async loadAllCars(profileId: Id<Profile>): Promise<Car[]> {
const loadSql = sql
.select("c.*")
.from("idz.car c")
.join("idz.profile p", { "c.profile_id": "p.id" })
.where("p.ext_id", extId)
.where("c.profile_id", profileId)
.toParams();
const { rows } = await this._conn.query(loadSql);
@ -58,13 +54,12 @@ export class SqlCarRepository implements CarRepository {
return rows.map(_extractRow);
}
async loadSelectedCar(extId: ExtId<Profile>): Promise<Car> {
async loadSelectedCar(profileId: Id<Profile>): Promise<Car> {
const loadSql = sql
.select("c.*")
.from("idz.car c")
.join("idz.car_selection s", { "c.id": "s.car_id" })
.join("idz.profile p", { "s.id": "p.id" })
.where("p.ext_id", extId)
.where("s.id", profileId)
.toParams();
const { rows } = await this._conn.query(loadSql);
@ -72,11 +67,11 @@ export class SqlCarRepository implements CarRepository {
return _extractRow(rows[0]);
}
async saveCar(extId: ExtId<Profile>, car: Car): Promise<void> {
async saveCar(profileId: Id<Profile>, car: Car): Promise<void> {
const saveSql = sql
.insert("idz.car", {
id: generateId(),
profile_id: await _findProfile(this._conn, extId),
profile_id: profileId,
selector: car.selector,
field_00: car.field_00,
field_02: car.field_02,
@ -116,11 +111,9 @@ export class SqlCarRepository implements CarRepository {
}
async saveSelection(
extId: ExtId<Profile>,
profileId: Id<Profile>,
selector: CarSelector
): Promise<void> {
const profileId = await _findProfile(this._conn, extId);
const findSql = sql
.select("c.id")
.from("idz.car c")

View File

@ -1,21 +1,19 @@
import { ClientBase } from "pg";
import * as sql from "sql-bricks-postgres";
import { _findProfile } from "./_util";
import { ExtId } from "../model/base";
import { Chara } from "../model/chara";
import { Profile } from "../model/profile";
import { FacetRepository } from "../repo";
import { Id } from "../../db";
export class SqlCharaRepository implements FacetRepository<Chara> {
constructor(private readonly _conn: ClientBase) {}
async load(extId: ExtId<Profile>): Promise<Chara> {
async load(profileId: Id<Profile>): Promise<Chara> {
const loadSql = sql
.select("c.*")
.from("idz.profile p")
.join("idz.chara c", { "p.id": "c.id" })
.where("p.ext_id", extId)
.from("idz.chara c")
.where("c.id", profileId)
.toParams();
const { rows } = await this._conn.query(loadSql);
@ -35,9 +33,7 @@ export class SqlCharaRepository implements FacetRepository<Chara> {
};
}
async save(extId: ExtId<Profile>, chara: Chara): Promise<void> {
const profileId = await _findProfile(this._conn, extId);
async save(profileId: Id<Profile>, chara: Chara): Promise<void> {
const saveSql = sql
.insert("idz.chara", {
id: profileId,

View File

@ -1,21 +1,19 @@
import { ClientBase } from "pg";
import * as sql from "sql-bricks-postgres";
import { _findProfile } from "./_util";
import { CourseNo, ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { CoursePlaysRepository } from "../repo";
import { generateId } from "../../db";
import { generateId, Id } from "../../db";
export class SqlCoursePlaysRepository implements CoursePlaysRepository {
constructor(private readonly _conn: ClientBase) {}
async loadAll(extId: ExtId<Profile>): Promise<Map<CourseNo, number>> {
async loadAll(profileId: Id<Profile>): Promise<Map<CourseNo, number>> {
const loadSql = sql
.select("cp.course_no", "cp.count")
.from("idz.course_plays cp")
.join("idz.profile p", { "cp.profile_id": "p.id" })
.where("p.ext_id", extId)
.where("cp.profile_id", profileId)
.toParams();
const { rows } = await this._conn.query(loadSql);
@ -29,11 +27,9 @@ export class SqlCoursePlaysRepository implements CoursePlaysRepository {
}
async saveAll(
extId: ExtId<Profile>,
profileId: Id<Profile>,
plays: Map<CourseNo, number>
): Promise<void> {
const profileId = await _findProfile(this._conn, extId);
for (const [k, v] of plays) {
const saveSql = sql
.insert("idz.course_plays", {

View File

@ -1,8 +1,6 @@
import { ClientBase } from "pg";
import * as sql from "sql-bricks-postgres";
import { _findProfile } from "./_util";
import { ExtId } from "../model/base";
import { MissionGrid, MissionState } from "../model/mission";
import { Profile } from "../model/profile";
import { FacetRepository } from "../repo";
@ -11,9 +9,7 @@ import { generateId, Id } from "../../db";
export class SqlMissionsRepository implements FacetRepository<MissionState> {
constructor(private readonly _conn: ClientBase) {}
private async _load(
extId: ExtId<Profile>
): Promise<[MissionState, Id<Profile>]> {
async load(profileId: Id<Profile>): Promise<MissionState> {
const result: MissionState = {
solo: new Array<MissionGrid>(),
team: new Array<MissionGrid>(),
@ -32,8 +28,6 @@ export class SqlMissionsRepository implements FacetRepository<MissionState> {
result.team.push(teamGrid);
}
const profileId = await _findProfile(this._conn, extId);
const loadSoloSql = sql
.select("sm.*")
.from("idz.solo_mission_state sm")
@ -46,17 +40,11 @@ export class SqlMissionsRepository implements FacetRepository<MissionState> {
result.solo[row.grid_no].cells[row.cell_no] = row.value;
}
return [result, profileId];
return result;
}
async load(extId: ExtId<Profile>): Promise<MissionState> {
const [mission] = await this._load(extId);
return mission;
}
async save(extId: ExtId<Profile>, mission: MissionState): Promise<void> {
const [existing, profileId] = await this._load(extId);
async save(profileId: Id<Profile>, mission: MissionState): Promise<void> {
const existing = await this.load(profileId);
for (let i = 0; i < mission.solo.length; i++) {
const exGrid = existing.solo[i].cells;

View File

@ -1,17 +1,16 @@
import * as sql from "sql-bricks";
import { ClientBase } from "pg";
import { _findProfile } from "./_util";
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { Team } from "../model/team";
import { ProfileSpec, ProfileRepository } from "../repo";
import { generateExtId, generateId, Id } from "../../db";
import { generateId, Id } from "../../db";
import { AimeId } from "../../model";
function _extractRow(row: any): Profile {
function _extractProfile(row: any): Profile {
return {
id: row.ext_id,
aimeId: row.ext_id,
teamId: 2 as ExtId<Team>, // TODO
name: row.name,
lv: row.lv,
@ -25,11 +24,19 @@ function _extractRow(row: any): Profile {
export class SqlProfileRepository implements ProfileRepository {
constructor(private readonly _conn: ClientBase) {}
private async _tryLoadByAimeId(
aimeId: AimeId
): Promise<Profile | undefined> {
async find(aimeId: AimeId): Promise<Id<Profile>> {
const profileId = await this.peek(aimeId);
if (profileId === undefined) {
throw new Error(`Profile not found for Aime ID ${aimeId}`);
}
return profileId;
}
async peek(aimeId: AimeId): Promise<Id<Profile> | undefined> {
const lookupSql = sql
.select("p.*")
.select("p.id")
.from("idz.profile p")
.join("aime.player r", { "p.player_id": "r.id" })
.where("r.ext_id", aimeId)
@ -42,35 +49,19 @@ export class SqlProfileRepository implements ProfileRepository {
return undefined;
}
return _extractRow(row);
return row.id;
}
async discoverByAimeId(aimeId: AimeId): Promise<boolean> {
const result = await this._tryLoadByAimeId(aimeId);
return result !== undefined;
}
async loadByAimeId(aimeId: AimeId): Promise<Profile> {
const result = await this._tryLoadByAimeId(aimeId);
if (result === undefined) {
throw new Error("Profile not found for Aime ID");
}
return result;
}
async load(extId: ExtId<Profile>): Promise<Profile> {
async load(id: Id<Profile>): Promise<Profile> {
const loadSql = sql
.select("p.*")
.from("idz.profile p")
.where("ext_id", extId)
.where("id", id)
.toParams();
const { rows } = await this._conn.query(loadSql);
return _extractRow(rows[0]);
return _extractProfile(rows[0]);
}
async save(profile: Profile, timestamp: Date): Promise<void> {
@ -83,7 +74,7 @@ export class SqlProfileRepository implements ProfileRepository {
mileage: profile.mileage,
access_time: timestamp,
})
.where("ext_id", profile.id)
.where("id", profile.aimeId)
.toParams();
await this._conn.query(saveSql);
@ -93,7 +84,7 @@ export class SqlProfileRepository implements ProfileRepository {
aimeId: AimeId,
profile: ProfileSpec,
timestamp: Date
): Promise<ExtId<Profile>> {
): Promise<Id<Profile>> {
const findSql = sql
.select("r.id")
.from("aime.player r")
@ -108,14 +99,12 @@ export class SqlProfileRepository implements ProfileRepository {
}
const id = generateId();
const extId = generateExtId() as ExtId<Profile>;
const playerId = row.id;
const createSql = sql
.insert("idz.profile", {
id: id,
player_id: playerId,
ext_id: extId,
name: profile.name,
lv: profile.lv,
exp: profile.exp,
@ -129,6 +118,6 @@ export class SqlProfileRepository implements ProfileRepository {
await this._conn.query(createSql);
return extId;
return id as Id<Profile>;
}
}

View File

@ -1,21 +1,19 @@
import { ClientBase } from "pg";
import * as sql from "sql-bricks-postgres";
import { _findProfile } from "./_util";
import { ExtId } from "../model/base";
import { Settings } from "../model/settings";
import { Profile } from "../model/profile";
import { FacetRepository } from "../repo";
import { Id } from "../../db";
export class SqlSettingsRepository implements FacetRepository<Settings> {
constructor(private readonly _conn: ClientBase) {}
async load(extId: ExtId<Profile>): Promise<Settings> {
async load(profileId: Id<Profile>): Promise<Settings> {
const loadSql = sql
.select("s.*")
.from("idz.profile p")
.join("idz.settings s", { "p.id": "s.id" })
.where("p.ext_id", extId)
.from("idz.settings s")
.where("s.id", profileId)
.toParams();
const { rows } = await this._conn.query(loadSql);
@ -29,9 +27,7 @@ export class SqlSettingsRepository implements FacetRepository<Settings> {
};
}
async save(extId: ExtId<Profile>, settings: Settings): Promise<void> {
const profileId = await _findProfile(this._conn, extId);
async save(profileId: Id<Profile>, settings: Settings): Promise<void> {
const saveSql = sql
.insert("idz.settings", {
id: profileId,

View File

@ -1,8 +1,6 @@
import { ClientBase } from "pg";
import * as sql from "sql-bricks-postgres";
import { _findProfile } from "./_util";
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { Story, StoryRow, StoryCell } from "../model/story";
import { FacetRepository } from "../repo";
@ -11,9 +9,7 @@ import { generateId, Id } from "../../db";
export class SqlStoryRepository implements FacetRepository<Story> {
constructor(private readonly _conn: ClientBase) {}
private async _load(extId: ExtId<Profile>): Promise<[Story, Id<Profile>]> {
const profileId = await _findProfile(this._conn, extId);
async load(profileId: Id<Profile>): Promise<Story> {
const loadSql = sql
.select("s.*")
.from("idz.story_state s")
@ -56,17 +52,11 @@ export class SqlStoryRepository implements FacetRepository<Story> {
cell.b = row.b;
}
return [result, profileId];
return result;
}
async load(extId: ExtId<Profile>): Promise<Story> {
const [story] = await this._load(extId);
return story;
}
async save(extId: ExtId<Profile>, story: Story): Promise<void> {
const [existing, profileId] = await this._load(extId);
async save(profileId: Id<Profile>, story: Story): Promise<void> {
const existing = await this.load(profileId);
const headSql = sql
.insert("idz.story_state", {

View File

@ -1,23 +1,21 @@
import { ClientBase } from "pg";
import * as sql from "sql-bricks-postgres";
import { _findProfile } from "./_util";
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { Tickets } from "../model/tickets";
import { FacetRepository } from "../repo";
import { Id } from "../../db";
// TODO free continue
export class SqlTicketsRepository implements FacetRepository<Tickets> {
constructor(private readonly _conn: ClientBase) {}
async load(extId: ExtId<Profile>): Promise<Tickets> {
async load(profileId: Id<Profile>): Promise<Tickets> {
const loadSql = sql
.select("fc.*")
.from("idz.profile p")
.join("idz.free_car fc", { "p.id": "fc.id" })
.where("p.ext_id", extId)
.from("idz.free_car fc")
.where("fc.id", profileId)
.toParams();
const { rows } = await this._conn.query(loadSql);
@ -30,8 +28,7 @@ export class SqlTicketsRepository implements FacetRepository<Tickets> {
};
}
async save(extId: ExtId<Profile>, tickets: Tickets): Promise<void> {
const profileId = await _findProfile(this._conn, extId);
async save(profileId: Id<Profile>, tickets: Tickets): Promise<void> {
const { freeCar } = tickets;
if (!freeCar) {

View File

@ -1,12 +1,11 @@
import { ClientBase } from "pg";
import * as sql from "sql-bricks-postgres";
import { _findProfile } from "./_util";
import { ExtId, RouteNo } from "../model/base";
import { RouteNo } from "../model/base";
import { Profile } from "../model/profile";
import { TimeAttackScore } from "../model/timeAttack";
import { TimeAttackRepository, TopTenResult } from "../repo";
import { generateId } from "../../db";
import { generateId, Id } from "../../db";
export class SqlTimeAttackRepository implements TimeAttackRepository {
constructor(private readonly _conn: ClientBase) {}
@ -41,12 +40,11 @@ export class SqlTimeAttackRepository implements TimeAttackRepository {
}));
}
async loadAll(extId: ExtId<Profile>): Promise<TimeAttackScore[]> {
async loadAll(profileId: Id<Profile>): Promise<TimeAttackScore[]> {
const loadSql = sql
.select("ta.*")
.from("idz.ta_best ta")
.join("idz.profile p", { "ta.profile_id": "p.id" })
.where("p.ext_id", extId)
.where("ta.profile_id", profileId)
.toParams();
const { rows } = await this._conn.query(loadSql);
@ -62,9 +60,7 @@ export class SqlTimeAttackRepository implements TimeAttackRepository {
}));
}
async save(extId: ExtId<Profile>, score: TimeAttackScore): Promise<void> {
const profileId = await _findProfile(this._conn, extId);
async save(profileId: Id<Profile>, score: TimeAttackScore): Promise<void> {
const logSql = sql
.insert("idz.ta_result", {
id: generateId(),

View File

@ -1,21 +1,19 @@
import { ClientBase } from "pg";
import * as sql from "sql-bricks";
import { _findProfile } from "./_util";
import { TitleCode, ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { FlagRepository } from "../repo";
import { generateId } from "../../db";
import { generateId, Id } from "../../db";
export class SqlTitlesRepository implements FlagRepository<TitleCode> {
constructor(private readonly _conn: ClientBase) {}
async loadAll(extId: ExtId<Profile>): Promise<Set<TitleCode>> {
async loadAll(profileId: Id<Profile>): Promise<Set<TitleCode>> {
const loadSql = sql
.select("t.title_no")
.from("idz.title_unlock t")
.join("idz.profile p", { "t.profile_id": "p.id" })
.where("p.ext_id", extId)
.where("t.profile_id", profileId)
.toParams();
const { rows } = await this._conn.query(loadSql);
@ -28,9 +26,8 @@ export class SqlTitlesRepository implements FlagRepository<TitleCode> {
return result;
}
async saveAll(extId: ExtId<Profile>, flags: Set<TitleCode>): Promise<void> {
const profileId = await _findProfile(this._conn, extId);
const existing = await this.loadAll(extId);
async saveAll(profileId: Id<Profile>, flags: Set<TitleCode>): Promise<void> {
const existing = await this.loadAll(profileId);
for (const flag of flags) {
if (existing.has(flag)) {

View File

@ -1,21 +1,20 @@
import { ClientBase } from "pg";
import * as sql from "sql-bricks-postgres";
import { _findProfile } from "./_util";
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { Unlocks } from "../model/unlocks";
import { FacetRepository } from "../repo";
import { Id } from "../../db";
export class SqlUnlocksRepository implements FacetRepository<Unlocks> {
constructor(private readonly _conn: ClientBase) {}
async load(extId: ExtId<Profile>): Promise<Unlocks> {
async load(profileId: Id<Profile>): Promise<Unlocks> {
const loadSql = sql
.select("u.*")
.from("idz.profile p")
.join("idz.unlocks u", { "p.id": "u.id" })
.where("p.ext_id", extId)
.from("idz.unlocks u")
.where("u.id", profileId)
.toParams();
const { rows } = await this._conn.query(loadSql);
@ -29,9 +28,7 @@ export class SqlUnlocksRepository implements FacetRepository<Unlocks> {
};
}
async save(extId: ExtId<Profile>, unlocks: Unlocks): Promise<void> {
const profileId = await _findProfile(this._conn, extId);
async save(profileId: Id<Profile>, unlocks: Unlocks): Promise<void> {
const saveSql = sql
.insert("idz.unlocks", {
id: profileId,

View File

@ -1,9 +1,8 @@
import iconv = require("iconv-lite");
import { RequestCode } from "./_defs";
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { CreateTeamRequest } from "../request/createTeam";
import { AimeId } from "../../model";
createTeam.msgCode = 0x0071 as RequestCode;
createTeam.msgLen = 0x0050;
@ -11,7 +10,7 @@ createTeam.msgLen = 0x0050;
export function createTeam(buf: Buffer): CreateTeamRequest {
return {
type: "create_team_req",
profileId: buf.readUInt32LE(0x0004) as ExtId<Profile>,
aimeId: buf.readUInt32LE(0x0004) as AimeId,
teamName: iconv.decode(
buf.slice(0x0008, buf.indexOf("\0", 0x0008)),
"shift_jis"

View File

@ -1,8 +1,8 @@
import { RequestCode } from "./_defs";
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { Team } from "../model/team";
import { Load2on2Request1, Load2on2Request2 } from "../request/load2on2";
import { AimeId } from "../../model";
load2on2_v1.msgCode = 0x00b0 as RequestCode;
load2on2_v1.msgLen = 0x0010;
@ -12,7 +12,7 @@ export function load2on2_v1(buf: Buffer): Load2on2Request1 {
type: "load_2on2_req",
format: 1,
field_0002: buf.readUInt16LE(0x0002),
profileId: buf.readUInt32LE(0x0004) as ExtId<Profile>,
aimeId: buf.readUInt32LE(0x0004) as AimeId,
teamId: buf.readUInt32LE(0x0008) as ExtId<Team>,
};
}
@ -25,7 +25,7 @@ export function load2on2_v2(buf: Buffer): Load2on2Request2 {
type: "load_2on2_req",
format: 2,
field_0002: buf.readUInt16LE(0x0002),
profileId: buf.readUInt32LE(0x0004) as ExtId<Profile>,
aimeId: buf.readUInt32LE(0x0004) as AimeId,
teamId: buf.readUInt32LE(0x0008) as ExtId<Team>,
};
}

View File

@ -1,7 +1,6 @@
import { RequestCode } from "./_defs";
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { LoadEventInfoRequest } from "../request/loadEventInfo";
import { AimeId } from "../../model";
loadEventInfo.msgCode = 0x00be as RequestCode;
loadEventInfo.msgLen = 0x0010;
@ -9,6 +8,6 @@ loadEventInfo.msgLen = 0x0010;
export function loadEventInfo(buf: Buffer): LoadEventInfoRequest {
return {
type: "load_event_info_req",
profileId: buf.readUInt32LE(0x0004) as ExtId<Profile>,
aimeId: buf.readUInt32LE(0x0004) as AimeId,
};
}

View File

@ -1,7 +1,6 @@
import { RequestCode } from "./_defs";
import { LoadGachaRequest } from "../request/loadGacha";
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { AimeId } from "../../model";
loadGacha.msgCode = 0x00c1 as RequestCode;
loadGacha.msgLen = 0x0010;
@ -9,6 +8,6 @@ loadGacha.msgLen = 0x0010;
export function loadGacha(buf: Buffer): LoadGachaRequest {
return {
type: "load_gacha_req",
profileId: buf.readUInt32LE(0x0004) as ExtId<Profile>,
aimeId: buf.readUInt32LE(0x0004) as AimeId,
};
}

View File

@ -1,7 +1,6 @@
import { RequestCode } from "./_defs";
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { LoadGarageRequest } from "../request/loadGarage";
import { AimeId } from "../../model";
loadGarage.msgCode = 0x0090 as RequestCode;
loadGarage.msgLen = 0x0010;
@ -9,7 +8,7 @@ loadGarage.msgLen = 0x0010;
export function loadGarage(buf: Buffer): LoadGarageRequest {
return {
type: "load_garage_req",
profileId: buf.readUInt32LE(0x0004) as ExtId<Profile>,
aimeId: buf.readUInt32LE(0x0004) as AimeId,
fetchOffset: buf.readUInt8(0x0008),
field_000A: buf.readUInt16LE(0x000a),
};

View File

@ -1,10 +1,9 @@
import { RequestCode } from "./_defs";
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import {
LoadGeneralRewardRequest1,
LoadGeneralRewardRequest2,
} from "../request/loadGeneralReward";
import { AimeId } from "../../model";
loadGeneralReward1.msgCode = 0x009c as RequestCode;
loadGeneralReward1.msgLen = 0x0010;
@ -13,7 +12,7 @@ export function loadGeneralReward1(buf: Buffer): LoadGeneralRewardRequest1 {
return {
type: "load_general_reward_req",
format: 1,
profileId: buf.readUInt32LE(0x0004) as ExtId<Profile>,
aimeId: buf.readUInt32LE(0x0004) as AimeId,
};
}
@ -24,6 +23,6 @@ export function loadGeneralReward2(buf: Buffer): LoadGeneralRewardRequest2 {
return {
type: "load_general_reward_req",
format: 2,
profileId: buf.readUInt32LE(0x0004) as ExtId<Profile>,
aimeId: buf.readUInt32LE(0x0004) as AimeId,
};
}

View File

@ -1,7 +1,6 @@
import { RequestCode } from "./_defs";
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { LoadStockerRequest } from "../request/loadStocker";
import { AimeId } from "../../model";
loadStocker.msgCode = 0x00a7 as RequestCode;
loadStocker.msgLen = 0x0010;
@ -9,6 +8,6 @@ loadStocker.msgLen = 0x0010;
export function loadStocker(buf: Buffer): LoadStockerRequest {
return {
type: "load_stocker_req",
profileId: buf.readUInt32LE(0x0004) as ExtId<Profile>,
aimeId: buf.readUInt32LE(0x0004) as AimeId,
};
}

View File

@ -7,7 +7,7 @@ loadTeam.msgLen = 0x0010;
export function loadTeam(buf: Buffer): LoadTeamRequest {
return {
type: "load_team_req",
profileId: buf.readUInt32LE(0x0004),
aimeId: buf.readUInt32LE(0x0004),
teamId: buf.readUInt32LE(0x0008),
};
}

View File

@ -1,11 +1,11 @@
import { RequestCode } from "./_defs";
import { ExtId, RouteNo } from "../model/base";
import { Profile } from "../model/profile";
import { Team } from "../model/team";
import {
LoadTopTenRequest,
LoadTopTenRequestSelector,
} from "../request/loadTopTen";
import { AimeId } from "../../model";
loadTopTen1.msgCode = 0x00b5 as RequestCode;
loadTopTen1.msgLen = 0x00e0;
@ -30,7 +30,7 @@ export function loadTopTen1(buf: Buffer): LoadTopTenRequest {
field_C4: buf.readUInt8(0x00c4), // Boolean, true if profile ID is set
field_C5: buf.readUInt8(0x00c5), // Always zero
field_C6: buf.readUInt16LE(0x00c6),
profileId: profileId !== 0 ? (profileId as ExtId<Profile>) : undefined,
aimeId: profileId !== 0 ? (profileId as AimeId) : undefined,
teamId: teamId !== 0xffffffff ? (teamId as ExtId<Team>) : undefined,
};
}

View File

@ -1,11 +1,11 @@
import { RequestCode } from "./_defs";
import { ExtId, RouteNo } from "../model/base";
import { Profile } from "../model/profile";
import { Team } from "../model/team";
import {
LoadTopTenRequest,
LoadTopTenRequestSelector,
} from "../request/loadTopTen";
import { AimeId } from "../../model";
loadTopTen2.msgCode = 0x012c as RequestCode;
loadTopTen2.msgLen = 0x0110;
@ -30,7 +30,7 @@ export function loadTopTen2(buf: Buffer): LoadTopTenRequest {
field_C4: buf.readUInt8(0x00f4), // Boolean, true if profile ID is set
field_C5: buf.readUInt8(0x00f5), // Always zero
field_C6: buf.readUInt16LE(0x00f6),
profileId: profileId !== 0 ? (profileId as ExtId<Profile>) : undefined,
aimeId: profileId !== 0 ? (profileId as AimeId) : undefined,
teamId: teamId !== 0xffffffff ? (teamId as ExtId<Team>) : undefined,
};
}

View File

@ -7,7 +7,7 @@ lockProfile.msgLen = 0x0020;
export function lockProfile(buf: Buffer): LockProfileRequest {
return {
type: "lock_profile_req",
profileId: buf.readUInt32LE(0x0004),
aimeId: buf.readUInt32LE(0x0004),
pcbId: buf.slice(0x0008, buf.indexOf("\0", 0x0008)).toString("ascii"),
field_0018: buf.readUInt16LE(0x0018),
};

View File

@ -1,7 +1,6 @@
import { RequestCode } from "./_defs";
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { LockProfileExtendRequest } from "../request/lockProfileExtend";
import { AimeId } from "../../model";
lockProfileExtend.msgCode = 0x006d as RequestCode;
lockProfileExtend.msgLen = 0x0020;
@ -9,7 +8,7 @@ lockProfileExtend.msgLen = 0x0020;
export function lockProfileExtend(buf: Buffer): LockProfileExtendRequest {
return {
type: "lock_profile_extend_req",
profileId: buf.readUInt32LE(0x0004) as ExtId<Profile>,
aimeId: buf.readUInt32LE(0x0004) as AimeId,
luid: buf.slice(0x0008, buf.indexOf("\0")).toString("ascii"),
};
}

View File

@ -14,7 +14,7 @@ export function saveGarage(buf: Buffer): SaveGarageRequest {
return {
type: "save_garage_req",
profileId: buf.readUInt32LE(0x0004),
aimeId: buf.readUInt32LE(0x0004),
payload: car(buf.slice(0x0008, 0x0068)),
field_0068,
field_0080: buf.readUInt8(0x0080),

View File

@ -1,8 +1,7 @@
import { car } from "./_car";
import { RequestCode } from "./_defs";
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { SaveNewCarRequest } from "../request/saveNewCar";
import { AimeId } from "../../model";
saveNewCar.msgCode = 0x0079 as RequestCode;
saveNewCar.msgLen = 0x0090;
@ -10,7 +9,7 @@ saveNewCar.msgLen = 0x0090;
export function saveNewCar(buf: Buffer): SaveNewCarRequest {
return {
type: "save_new_car_req",
profileId: buf.readUInt32LE(0x0004) as ExtId<Profile>,
aimeId: buf.readUInt32LE(0x0004) as AimeId,
luid: buf.slice(0x0008, buf.indexOf(0, 0x0008)).toString("ascii"),
car: car(buf.slice(0x0020, 0x0080)),
field_0080: buf.readUInt32LE(0x0080),

View File

@ -2,9 +2,9 @@ import { car } from "./_car";
import { mission } from "./_mission";
import { RequestCode } from "./_defs";
import { BackgroundCode, CourseNo, ExtId, TitleCode } from "../model/base";
import { Profile } from "../model/profile";
import { SaveProfileRequest2 } from "../request/saveProfile";
import { bitmap } from "./_bitmap";
import { AimeId } from "../../model";
saveProfile2.msgCode = 0x0068 as RequestCode;
saveProfile2.msgLen = 0x0940;
@ -47,7 +47,7 @@ export function saveProfile2(buf: Buffer): SaveProfileRequest2 {
return {
type: "save_profile_req",
format: 2,
profileId: buf.readUInt32LE(0x0004) as ExtId<Profile>,
aimeId: buf.readUInt32LE(0x0004) as AimeId,
lv: buf.readUInt16LE(0x0026),
exp: buf.readUInt32LE(0x0028),
fame: buf.readUInt32LE(0x0468),

View File

@ -1,10 +1,10 @@
import { car } from "./_car";
import { mission } from "./_mission";
import { RequestCode } from "./_defs";
import { BackgroundCode, CourseNo, ExtId, TitleCode } from "../model/base";
import { Profile } from "../model/profile";
import { BackgroundCode, CourseNo, TitleCode } from "../model/base";
import { SaveProfileRequest2 } from "../request/saveProfile";
import { bitmap } from "./_bitmap";
import { AimeId } from "../../model";
saveProfile3.msgCode = 0x0138 as RequestCode;
saveProfile3.msgLen = 0x0a70;
@ -49,7 +49,7 @@ export function saveProfile3(buf: Buffer): SaveProfileRequest2 {
return {
type: "save_profile_req",
format: 2,
profileId: buf.readUInt32LE(0x0004) as ExtId<Profile>,
aimeId: buf.readUInt32LE(0x0004) as AimeId,
lv: buf.readUInt16LE(0x0026),
exp: buf.readUInt32LE(0x0028),
fame: buf.readUInt32LE(0x04fc),

View File

@ -1,7 +1,6 @@
import { RequestCode } from "./_defs";
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { SaveSettingsRequest } from "../request/saveSettings";
import { AimeId } from "../../model";
saveSettings.msgCode = 0x00a5 as RequestCode;
saveSettings.msgLen = 0x0020;
@ -13,7 +12,7 @@ export function saveSettings(buf: Buffer): SaveSettingsRequest {
return {
type: "save_settings_req",
profileId: buf.readUInt32LE(0x0004) as ExtId<Profile>,
aimeId: buf.readUInt32LE(0x0004) as AimeId,
dpoint: buf.readUInt32LE(0x0008),
settings: {
music: buf.readUInt16LE(0x0002),

View File

@ -1,10 +1,9 @@
import { bitmap } from "./_bitmap";
import { chara } from "./_chara";
import { RequestCode } from "./_defs";
import { BackgroundCode, ExtId } from "../model/base";
import { CarSelector } from "../model/car";
import { Profile } from "../model/profile";
import { SaveStockerRequest } from "../request/saveStocker";
import { AimeId } from "../../model";
saveStocker.msgCode = 0x00a6 as RequestCode;
saveStocker.msgLen = 0x00c0;
@ -12,7 +11,7 @@ saveStocker.msgLen = 0x00c0;
export function saveStocker(buf: Buffer): SaveStockerRequest {
return {
type: "save_stocker_req",
profileId: buf.readUInt32LE(0x0004) as ExtId<Profile>,
aimeId: buf.readUInt32LE(0x0004) as AimeId,
backgrounds: bitmap(buf.slice(0x0008, 0x002c)),
selectedCar: buf.readUInt16LE(0x009c) as CarSelector,

View File

@ -1,13 +1,13 @@
import { RequestCode } from "./_defs";
import { ExtId, RouteNo } from "../model/base";
import { RouteNo } from "../model/base";
import { CarSelector } from "../model/car";
import { Profile } from "../model/profile";
import { SaveTimeAttackRequest } from "../request/saveTimeAttack";
import { AimeId } from "../../model";
function saveTimeAttack(buf: Buffer): SaveTimeAttackRequest {
return {
type: "save_time_attack_req",
profileId: buf.readUInt32LE(0x0004) as ExtId<Profile>,
aimeId: buf.readUInt32LE(0x0004) as AimeId,
dayNight: buf.readUInt8(0x0054) & 1,
payload: {
routeNo: (buf.readUInt8(0x0054) >> 1) as RouteNo,

View File

@ -7,7 +7,7 @@ unlockProfile.msgLen = 0x0020;
export function unlockProfile(buf: Buffer): UnlockProfileRequest {
return {
type: "unlock_profile_req",
profileId: buf.readUInt32LE(0x0004),
aimeId: buf.readUInt32LE(0x0004),
pcbId: buf.slice(0x0008, buf.indexOf("\0", 0x0008)).toString("ascii"),
};
}

View File

@ -78,7 +78,7 @@ export function loadProfile2(res: LoadProfileResponse2) {
buf.writeUInt16LE(0, 0x037c); // Team leader
mission(res.missions.team).copy(buf, 0x038a);
buf.writeUInt16LE(0xffff, 0x0388); // [1]
buf.writeUInt32LE(res.profileId, 0x03b8);
buf.writeUInt32LE(res.aimeId, 0x03b8);
buf.writeUInt32LE(res.mileage, 0x03bc);
buf.writeUInt16LE(res.settings.music, 0x03c8);
buf.writeUInt16LE(res.lv, 0x03cc);

View File

@ -78,7 +78,7 @@ export function loadProfile3(res: LoadProfileResponse3) {
buf.writeUInt16LE(0, 0x0456); // Team leader
mission(res.missions.team).copy(buf, 0x0460);
buf.writeUInt16LE(0xffff, 0x0462); // [1]
buf.writeUInt32LE(res.profileId, 0x0494);
buf.writeUInt32LE(res.aimeId, 0x0494);
buf.writeUInt32LE(res.mileage, 0x0498);
buf.writeUInt16LE(res.settings.music, 0x04a4);
buf.writeUInt16LE(res.lv, 0x04a8);

View File

@ -46,6 +46,6 @@ export async function createProfile(
return {
type: "generic_res",
status: profileId, // "Generic response" my fucking *ass*
status: req.aimeId, // "Generic response" my fucking *ass*
};
}

View File

@ -6,8 +6,10 @@ export async function discoverProfile(
w: Repositories,
req: DiscoverProfileRequest
): Promise<DiscoverProfileResponse> {
const profileId = await w.profile().find(req.aimeId);
return {
type: "discover_profile_res",
exists: await w.profile().discoverByAimeId(req.aimeId),
exists: profileId !== undefined,
};
}

View File

@ -6,8 +6,10 @@ export async function loadGarage(
w: Repositories,
req: LoadGarageRequest
): Promise<LoadGarageResponse> {
const profileId = await w.profile().find(req.aimeId);
return {
type: "load_garage_res",
cars: await w.car().loadAllCars(req.profileId),
cars: await w.car().loadAllCars(profileId),
};
}

View File

@ -6,27 +6,31 @@ export async function loadProfile(
w: Repositories,
req: LoadProfileRequest
): Promise<LoadProfileResponse> {
const { aimeId } = req;
const profileId = await w.profile().find(aimeId);
// Promise.all would be messy here, who cares anyway this isn't supposed to
// be a high-performance server.
const profile = await w.profile().loadByAimeId(req.aimeId);
const settings = await w.settings().load(profile.id);
const chara = await w.chara().load(profile.id);
const titles = await w.titles().loadAll(profile.id);
const coursePlays = await w.coursePlays().loadAll(profile.id);
const missions = await w.missions().load(profile.id);
const car = await w.car().loadSelectedCar(profile.id);
const carCount = await w.car().countCars(profile.id);
const story = await w.story().load(profile.id);
const timeAttack = await w.timeAttack().loadAll(profile.id);
const unlocks = await w.unlocks().load(profile.id);
const tickets = await w.tickets().load(profile.id);
const profile = await w.profile().load(profileId);
const settings = await w.settings().load(profileId);
const chara = await w.chara().load(profileId);
const titles = await w.titles().loadAll(profileId);
const coursePlays = await w.coursePlays().loadAll(profileId);
const missions = await w.missions().load(profileId);
const car = await w.car().loadSelectedCar(profileId);
const carCount = await w.car().countCars(profileId);
const story = await w.story().load(profileId);
const timeAttack = await w.timeAttack().loadAll(profileId);
const unlocks = await w.unlocks().load(profileId);
const tickets = await w.tickets().load(profileId);
return {
type: "load_profile_res",
format: req.format as any, // TS fart
name: profile.name,
profileId: profile.id,
aimeId,
lv: profile.lv,
exp: profile.exp,
fame: profile.fame,

View File

@ -6,7 +6,8 @@ export async function loadStocker(
w: Repositories,
req: LoadStockerRequest
): Promise<LoadStockerResponse> {
const backgrounds = await w.backgrounds().loadAll(req.profileId);
const profileId = await w.profile().find(req.aimeId);
const backgrounds = await w.backgrounds().loadAll(profileId);
return {
type: "load_stocker_res",

View File

@ -6,7 +6,9 @@ export async function saveNewCar(
w: Repositories,
req: SaveNewCarRequest
): Promise<SaveNewCarResponse> {
await w.car().saveCar(req.profileId, req.car);
const profileId = await w.profile().find(req.aimeId);
await w.car().saveCar(profileId, req.car);
return {
type: "save_new_car_res",

View File

@ -7,8 +7,9 @@ export async function saveProfile(
req: SaveProfileRequest
): Promise<GenericResponse> {
const now = new Date();
const profile = await w.profile().load(req.profileId);
const chara = await w.chara().load(req.profileId);
const profileId = await w.profile().find(req.aimeId);
const profile = await w.profile().load(profileId);
const chara = await w.chara().load(profileId);
await w.profile().save(
{
@ -22,20 +23,20 @@ export async function saveProfile(
now
);
await w.chara().save(req.profileId, {
await w.chara().save(profileId, {
...chara,
title: req.title,
background: req.background,
});
await w.car().saveCar(req.profileId, req.car);
await w.coursePlays().saveAll(req.profileId, req.coursePlays);
await w.missions().save(req.profileId, req.missions);
await w.story().save(req.profileId, req.story);
await w.titles().saveAll(req.profileId, req.titles);
await w.unlocks().save(req.profileId, req.unlocks);
await w.settings().save(req.profileId, req.settings);
await w.tickets().save(req.profileId, req.tickets);
await w.car().saveCar(profileId, req.car);
await w.coursePlays().saveAll(profileId, req.coursePlays);
await w.missions().save(profileId, req.missions);
await w.story().save(profileId, req.story);
await w.titles().saveAll(profileId, req.titles);
await w.unlocks().save(profileId, req.unlocks);
await w.settings().save(profileId, req.settings);
await w.tickets().save(profileId, req.tickets);
return {
type: "generic_res",

View File

@ -6,7 +6,9 @@ export async function saveSettings(
w: Repositories,
req: SaveSettingsRequest
): Promise<GenericResponse> {
await w.settings().save(req.profileId, req.settings);
const profileId = await w.profile().find(req.aimeId);
await w.settings().save(profileId, req.settings);
return { type: "generic_res" };
}

View File

@ -6,10 +6,12 @@ export async function saveStocker(
w: Repositories,
req: SaveStockerRequest
): Promise<GenericResponse> {
const profileId = await w.profile().find(req.aimeId);
await Promise.all([
w.backgrounds().saveAll(req.profileId, req.backgrounds),
w.chara().save(req.profileId, req.chara),
w.car().saveSelection(req.profileId, req.selectedCar),
w.backgrounds().saveAll(profileId, req.backgrounds),
w.chara().save(profileId, req.chara),
w.car().saveSelection(profileId, req.selectedCar),
]);
return { type: "generic_res" };

View File

@ -13,9 +13,10 @@ export async function saveTimeAttack(
// Override client time since we might be doing some maintenance window
// avoidance time warping stuff
await w
.timeAttack()
.save(req.profileId, { ...req.payload, timestamp: new Date() });
const now = new Date();
const profileId = await w.profile().find(req.aimeId);
await w.timeAttack().save(profileId, { ...req.payload, timestamp: now });
}
return {

View File

@ -1,8 +1,9 @@
import { ExtId } from "./base";
import { Team } from "./team";
import { AimeId } from "../../model";
export interface Profile {
id: ExtId<Profile>;
aimeId: AimeId;
teamId?: ExtId<Team>;
name: string;
lv: number;

View File

@ -2,59 +2,52 @@ import { Subtract } from "utility-types";
import * as Model from "./model";
import { AimeId } from "../model";
import { Id } from "../db";
export type ProfileSpec = Subtract<
Model.Profile,
{ id: Model.ExtId<Model.Profile> }
>;
export type ProfileSpec = Subtract<Model.Profile, { aimeId: AimeId }>;
export interface CarRepository {
countCars(profileId: Model.ExtId<Model.Profile>): Promise<number>;
countCars(profileId: Id<Model.Profile>): Promise<number>;
loadAllCars(profileId: Model.ExtId<Model.Profile>): Promise<Model.Car[]>;
loadAllCars(profileId: Id<Model.Profile>): Promise<Model.Car[]>;
loadSelectedCar(profileId: Model.ExtId<Model.Profile>): Promise<Model.Car>;
loadSelectedCar(profileId: Id<Model.Profile>): Promise<Model.Car>;
saveCar(
profileId: Model.ExtId<Model.Profile>,
car: Model.Car
): Promise<void>;
saveCar(profileId: Id<Model.Profile>, car: Model.Car): Promise<void>;
saveSelection(
profileId: Model.ExtId<Model.Profile>,
profileId: Id<Model.Profile>,
selector: Model.CarSelector
): Promise<void>;
}
export interface CoursePlaysRepository {
loadAll(
profileId: Model.ExtId<Model.Profile>
): Promise<Map<Model.CourseNo, number>>;
loadAll(profileId: Id<Model.Profile>): Promise<Map<Model.CourseNo, number>>;
saveAll(
profileId: Model.ExtId<Model.Profile>,
profileId: Id<Model.Profile>,
counts: Map<Model.CourseNo, number>
): Promise<void>;
}
export interface FacetRepository<T> {
load(profileId: Model.ExtId<Model.Profile>): Promise<T>;
load(profileId: Id<Model.Profile>): Promise<T>;
save(profileId: Model.ExtId<Model.Profile>, facet: T): Promise<void>;
save(profileId: Id<Model.Profile>, facet: T): Promise<void>;
}
export interface FlagRepository<T extends number> {
loadAll(profileId: Model.ExtId<Model.Profile>): Promise<Set<T>>;
loadAll(profileId: Id<Model.Profile>): Promise<Set<T>>;
saveAll(profileId: Model.ExtId<Model.Profile>, items: Set<T>): Promise<void>;
saveAll(profileId: Id<Model.Profile>, items: Set<T>): Promise<void>;
}
export interface ProfileRepository {
discoverByAimeId(id: AimeId): Promise<boolean>;
find(aimeId: AimeId): Promise<Id<Model.Profile>>;
loadByAimeId(id: AimeId): Promise<Model.Profile>;
peek(aimeId: AimeId): Promise<Id<Model.Profile> | undefined>;
load(id: Model.ExtId<Model.Profile>): Promise<Model.Profile>;
load(id: Id<Model.Profile>): Promise<Model.Profile>;
save(profile: Model.Profile, timestamp: Date): Promise<void>;
@ -62,7 +55,7 @@ export interface ProfileRepository {
aimeId: AimeId,
profile: ProfileSpec,
timestamp: Date
): Promise<Model.ExtId<Model.Profile>>;
): Promise<Id<Model.Profile>>;
}
// TODO extend and factorize
@ -77,12 +70,10 @@ export interface TimeAttackRepository {
minTimestamp: Date
): Promise<TopTenResult[]>;
loadAll(
profileId: Model.ExtId<Model.Profile>
): Promise<Model.TimeAttackScore[]>;
loadAll(profileId: Id<Model.Profile>): Promise<Model.TimeAttackScore[]>;
save(
profileId: Model.ExtId<Model.Profile>,
profileId: Id<Model.Profile>,
score: Model.TimeAttackScore
): Promise<void>;
}

View File

@ -1,9 +1,8 @@
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { AimeId } from "../../model";
export interface CreateTeamRequest {
type: "create_team_req";
profileId: ExtId<Profile>; // u32
aimeId: AimeId;
teamName: string; // len 0x20
field_0028: number; // u16
field_002C: number; // u32 (but only holds a u8)

View File

@ -1,11 +1,11 @@
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { Team } from "../model/team";
import { AimeId } from "../../model";
interface Load2on2RequestBase {
type: "load_2on2_req";
field_0002: number;
profileId: ExtId<Profile>;
aimeId: AimeId;
teamId: ExtId<Team>;
}

View File

@ -1,7 +1,6 @@
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { AimeId } from "../../model";
export interface LoadEventInfoRequest {
type: "load_event_info_req";
profileId: ExtId<Profile>;
aimeId: AimeId;
}

View File

@ -1,7 +1,6 @@
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { AimeId } from "../../model";
export interface LoadGachaRequest {
type: "load_gacha_req";
profileId: ExtId<Profile>;
aimeId: AimeId;
}

View File

@ -1,9 +1,8 @@
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { AimeId } from "../../model";
export interface LoadGarageRequest {
type: "load_garage_req";
profileId: ExtId<Profile>;
aimeId: AimeId;
fetchOffset: number;
field_000A: number;
}

View File

@ -1,9 +1,8 @@
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { AimeId } from "../../model";
interface LoadGeneralRewardRequestBase {
type: "load_general_reward_req";
profileId: ExtId<Profile>;
aimeId: AimeId;
}
export interface LoadGeneralRewardRequest1

View File

@ -1,7 +1,6 @@
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { AimeId } from "../../model";
export interface LoadStockerRequest {
type: "load_stocker_req";
profileId: ExtId<Profile>;
aimeId: AimeId;
}

View File

@ -1,5 +1,5 @@
export interface LoadTeamRequest {
type: "load_team_req";
profileId: number;
aimeId: number;
teamId: number;
}

View File

@ -1,6 +1,6 @@
import { ExtId, RouteNo } from "../model/base";
import { Profile } from "../model/profile";
import { Team } from "../model/team";
import { AimeId } from "../../model";
export interface LoadTopTenRequestSelector {
routeNo: RouteNo;
@ -14,6 +14,6 @@ export interface LoadTopTenRequest {
field_C4: number;
field_C5: number;
field_C6: number;
profileId?: ExtId<Profile>;
aimeId?: AimeId;
teamId?: ExtId<Team>;
}

View File

@ -1,6 +1,6 @@
export interface LockProfileRequest {
type: "lock_profile_req";
profileId: number;
aimeId: number;
pcbId: string;
field_0018: number;
}

View File

@ -1,8 +1,7 @@
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { AimeId } from "../../model";
export interface LockProfileExtendRequest {
type: "lock_profile_extend_req";
profileId: ExtId<Profile>;
aimeId: AimeId;
luid: string;
}

View File

@ -2,7 +2,7 @@ import { Car } from "../model/car";
export interface SaveGarageRequest {
type: "save_garage_req";
profileId: number;
aimeId: number;
payload: Car;
field_0068: number[];
field_0080: number;

View File

@ -1,10 +1,9 @@
import { ExtId } from "../model/base";
import { Car } from "../model/car";
import { Profile } from "../model/profile";
import { AimeId } from "../../model";
export interface SaveNewCarRequest {
type: "save_new_car_req";
profileId: ExtId<Profile>;
aimeId: AimeId;
luid: string;
car: Car;
field_0080: number;

View File

@ -1,15 +1,15 @@
import { BackgroundCode, CourseNo, ExtId, TitleCode } from "../model/base";
import { Car } from "../model/car";
import { MissionState } from "../model/mission";
import { Profile } from "../model/profile";
import { Settings } from "../model/settings";
import { Story } from "../model/story";
import { Tickets } from "../model/tickets";
import { Unlocks } from "../model/unlocks";
import { AimeId } from "../../model";
interface SaveProfileRequestBase {
type: "save_profile_req";
profileId: ExtId<Profile>;
aimeId: AimeId;
lv: number;
exp: number;
fame: number;

View File

@ -1,10 +1,9 @@
import { ExtId } from "../model/base";
import { Profile } from "../model/profile";
import { Settings } from "../model/settings";
import { AimeId } from "../../model";
export interface SaveSettingsRequest {
type: "save_settings_req";
profileId: ExtId<Profile>;
aimeId: AimeId;
dpoint: number; // ?? why
settings: Settings;
field_0010: number;

View File

@ -1,11 +1,11 @@
import { BackgroundCode, ExtId } from "../model/base";
import { BackgroundCode } from "../model/base";
import { CarSelector } from "../model/car";
import { Chara } from "../model/chara";
import { Profile } from "../model/profile";
import { AimeId } from "../../model";
export interface SaveStockerRequest {
type: "save_stocker_req";
profileId: ExtId<Profile>;
aimeId: AimeId;
selectedCar: CarSelector;
backgrounds: Set<BackgroundCode>;
chara: Chara;

View File

@ -1,11 +1,9 @@
import { ExtId } from "../model/base";
import { CarSelector } from "../model/car";
import { Profile } from "../model/profile";
import { TimeAttackScore } from "../model/timeAttack";
import { AimeId } from "../../model";
export interface SaveTimeAttackRequest {
type: "save_time_attack_req";
profileId: ExtId<Profile>; // u32
aimeId: AimeId;
dayNight: number;
payload: TimeAttackScore;
field_0002: number; // u16, always 1

View File

@ -1,5 +1,5 @@
export interface UnlockProfileRequest {
type: "unlock_profile_req";
profileId: number;
aimeId: number;
pcbId: string;
}

View File

@ -1,18 +1,18 @@
import { ExtId, TitleCode } from "../model/base";
import { TitleCode } from "../model/base";
import { Car } from "../model/car";
import { Chara } from "../model/chara";
import { MissionState } from "../model/mission";
import { Profile } from "../model/profile";
import { Settings } from "../model/settings";
import { Story } from "../model/story";
import { Tickets } from "../model/tickets";
import { TimeAttackScore } from "../model/timeAttack";
import { Unlocks } from "../model/unlocks";
import { AimeId } from "../../model";
interface LoadProfileResponseBase {
type: "load_profile_res";
name: string;
profileId: ExtId<Profile>;
aimeId: AimeId;
lv: number;
exp: number;
fame: number;