mirror of
https://github.com/djhackersdev/minime.git
synced 2026-08-20 01:14:08 -05:00
idz: Implement team leadership transfer
This commit is contained in:
@@ -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,
|
||||
|
||||
17
src/idz/decoder/updateTeamLeader.ts
Normal file
17
src/idz/decoder/updateTeamLeader.ts
Normal file
@@ -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<Team>,
|
||||
field_000C: buf.slice(0x000c, buf.indexOf("\0", 0x000c)).toString("ascii"),
|
||||
};
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
|
||||
10
src/idz/encoder/updateTeamLeader.ts
Normal file
10
src/idz/encoder/updateTeamLeader.ts
Normal file
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
|
||||
18
src/idz/handler/updateTeamLeader.ts
Normal file
18
src/idz/handler/updateTeamLeader.ts
Normal file
@@ -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<UpdateTeamLeaderResponse> {
|
||||
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,
|
||||
};
|
||||
}
|
||||
@@ -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
|
||||
|
||||
10
src/idz/request/updateTeamLeader.ts
Normal file
10
src/idz/request/updateTeamLeader.ts
Normal file
@@ -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<Team>;
|
||||
field_000C: string;
|
||||
}
|
||||
@@ -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
|
||||
|
||||
4
src/idz/response/updateTeamLeader.ts
Normal file
4
src/idz/response/updateTeamLeader.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export interface UpdateTeamLeaderResponse {
|
||||
type: "update_team_leader_res";
|
||||
status: number;
|
||||
}
|
||||
Reference in New Issue
Block a user