diff --git a/src/idz/decoder/index.ts b/src/idz/decoder/index.ts index afaabe1..63ff947 100644 --- a/src/idz/decoder/index.ts +++ b/src/idz/decoder/index.ts @@ -36,6 +36,7 @@ import { saveTimeAttack1, saveTimeAttack2 } from "./saveTimeAttack"; import { saveTopic } from "./saveTopic"; import { unlockProfile } from "./unlockProfile"; import { updateProvisionalStoreRank } from "./updateProvisionalStoreRank"; +import { updateTeamLeader } from "./updateTeamLeader"; import { updateTeamMember } from "./updateTeamMember"; import { updateStoryClearNum1, @@ -101,6 +102,7 @@ const funcList: ReaderFn[] = [ updateResult, updateStoryClearNum1, updateStoryClearNum2, + updateTeamLeader, updateTeamMember, updateTeamPoints, updateUiReport, diff --git a/src/idz/decoder/updateTeamLeader.ts b/src/idz/decoder/updateTeamLeader.ts new file mode 100644 index 0000000..ca247b4 --- /dev/null +++ b/src/idz/decoder/updateTeamLeader.ts @@ -0,0 +1,17 @@ +import { RequestCode } from "./_defs"; +import { ExtId } from "../model/base"; +import { Team } from "../model/team"; +import { UpdateTeamLeaderRequest } from "../request/updateTeamLeader"; +import { AimeId } from "../../model"; + +updateTeamLeader.msgCode = 0x008a as RequestCode; +updateTeamLeader.msgLen = 0x0020; + +export function updateTeamLeader(buf: Buffer): UpdateTeamLeaderRequest { + return { + type: "update_team_leader_req", + aimeId: buf.readUInt32LE(0x0004) as AimeId, + teamExtId: buf.readUInt32LE(0x0008) as ExtId, + field_000C: buf.slice(0x000c, buf.indexOf("\0", 0x000c)).toString("ascii"), + }; +} diff --git a/src/idz/encoder/index.ts b/src/idz/encoder/index.ts index 6dbe659..f6a3386 100644 --- a/src/idz/encoder/index.ts +++ b/src/idz/encoder/index.ts @@ -29,6 +29,7 @@ import { saveTopic } from "./saveTopic"; import { unlockProfile } from "./unlockProfile"; import { updateProvisionalStoreRank } from "./updateProvisionalStoreRank"; import { updateStoryClearNum } from "./updateStoryClearNum"; +import { updateTeamLeader } from "./updateTeamLeader"; import { updateTeamMember } from "./updateTeamMember"; import { Response } from "../response"; @@ -121,6 +122,9 @@ function encode(res: Response): Buffer { case "update_story_clear_num_res": return updateStoryClearNum(res); + case "update_team_leader_res": + return updateTeamLeader(res); + case "update_team_member_res": return updateTeamMember(res); diff --git a/src/idz/encoder/updateTeamLeader.ts b/src/idz/encoder/updateTeamLeader.ts new file mode 100644 index 0000000..b0c7ccc --- /dev/null +++ b/src/idz/encoder/updateTeamLeader.ts @@ -0,0 +1,10 @@ +import { UpdateTeamLeaderResponse } from "../response/updateTeamLeader"; + +export function updateTeamLeader(res: UpdateTeamLeaderResponse): Buffer { + const buf = Buffer.alloc(0x0010); + + buf.writeUInt16LE(0x008b, 0x0000); + buf.writeUInt32LE(res.status, 0x0004); + + return buf; +} diff --git a/src/idz/handler/index.ts b/src/idz/handler/index.ts index 130e49a..68224b9 100644 --- a/src/idz/handler/index.ts +++ b/src/idz/handler/index.ts @@ -35,6 +35,7 @@ import { unlockProfile } from "./unlockProfile"; import { updateProvisionalStoreRank } from "./updateProvisionalStoreRank"; import { updateResult } from "./updateResult"; import { updateStoryClearNum } from "./updateStoryClearNum"; +import { updateTeamLeader } from "./updateTeamLeader"; import { updateTeamMember } from "./updateTeamMember"; import { updateTeamPoints } from "./updateTeamPoints"; import { updateUiReport } from "./updateUiReport"; @@ -159,6 +160,9 @@ export async function dispatch( case "update_story_clear_num_req": return updateStoryClearNum(w, req); + case "update_team_leader_req": + return updateTeamLeader(w, req); + case "update_team_member_req": return updateTeamMember(w, req); diff --git a/src/idz/handler/updateTeamLeader.ts b/src/idz/handler/updateTeamLeader.ts new file mode 100644 index 0000000..4ac1d89 --- /dev/null +++ b/src/idz/handler/updateTeamLeader.ts @@ -0,0 +1,18 @@ +import { UpdateTeamLeaderRequest } from "../request/updateTeamLeader"; +import { UpdateTeamLeaderResponse } from "../response/updateTeamLeader"; +import { Repositories } from "../repo"; + +export async function updateTeamLeader( + w: Repositories, + req: UpdateTeamLeaderRequest +): Promise { + const profileId = await w.profile().find(req.aimeId); + const teamId = await w.teams().find(req.teamExtId); + + await w.teamMembers().makeLeader(teamId, profileId); + + return { + type: "update_team_leader_res", + status: 0, + }; +} diff --git a/src/idz/request/index.ts b/src/idz/request/index.ts index 8b5aef2..92265d1 100644 --- a/src/idz/request/index.ts +++ b/src/idz/request/index.ts @@ -35,6 +35,7 @@ import { UnlockProfileRequest } from "./unlockProfile"; import { UpdateProvisionalStoreRankRequest } from "./updateProvisionalStoreRank"; import { UpdateResultRequest } from "./updateResult"; import { UpdateStoryClearNumRequest } from "./updateStoryClearNum"; +import { UpdateTeamLeaderRequest } from "./updateTeamLeader"; import { UpdateTeamMemberRequest } from "./updateTeamMember"; import { UpdateTeamPointsRequest } from "./updateTeamPoints"; import { UpdateUiReportRequest } from "./updateUiReport"; @@ -78,6 +79,7 @@ export type Request = | UpdateProvisionalStoreRankRequest | UpdateResultRequest | UpdateStoryClearNumRequest + | UpdateTeamLeaderRequest | UpdateTeamMemberRequest | UpdateTeamPointsRequest | UpdateUiReportRequest diff --git a/src/idz/request/updateTeamLeader.ts b/src/idz/request/updateTeamLeader.ts new file mode 100644 index 0000000..741b402 --- /dev/null +++ b/src/idz/request/updateTeamLeader.ts @@ -0,0 +1,10 @@ +import { ExtId } from "../model/base"; +import { Team } from "../model/team"; +import { AimeId } from "../../model"; + +export interface UpdateTeamLeaderRequest { + type: "update_team_leader_req"; + aimeId: AimeId; + teamExtId: ExtId; + field_000C: string; +} diff --git a/src/idz/response/index.ts b/src/idz/response/index.ts index edaad65..44ebfcd 100644 --- a/src/idz/response/index.ts +++ b/src/idz/response/index.ts @@ -27,6 +27,7 @@ import { SaveTimeAttackResponse } from "./saveTimeAttack"; import { SaveTopicResponse } from "./saveTopic"; import { UpdateProvisionalStoreRankResponse } from "./updateProvisionalStoreRank"; import { UpdateStoryClearNumResponse } from "./updateStoryClearNum"; +import { UpdateTeamLeaderResponse } from "./updateTeamLeader"; import { UpdateTeamMemberResponse } from "./updateTeamMember"; import { UnlockProfileResponse } from "./unlockProfile"; @@ -56,6 +57,7 @@ export type Response = | UnlockProfileResponse | UpdateProvisionalStoreRankResponse | UpdateStoryClearNumResponse + | UpdateTeamLeaderResponse | UpdateTeamMemberResponse | SaveExpeditionResponse | SaveGarageResponse diff --git a/src/idz/response/updateTeamLeader.ts b/src/idz/response/updateTeamLeader.ts new file mode 100644 index 0000000..5fdfbdc --- /dev/null +++ b/src/idz/response/updateTeamLeader.ts @@ -0,0 +1,4 @@ +export interface UpdateTeamLeaderResponse { + type: "update_team_leader_res"; + status: number; +}