idz: Implement team leadership transfer

This commit is contained in:
Tau
2019-05-28 19:43:50 -04:00
parent 3bee10d948
commit 2478bc5ceb
10 changed files with 73 additions and 0 deletions

View File

@@ -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,

View 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"),
};
}

View File

@@ -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);

View 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;
}

View File

@@ -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);

View 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,
};
}

View File

@@ -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

View 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;
}

View File

@@ -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

View File

@@ -0,0 +1,4 @@
export interface UpdateTeamLeaderResponse {
type: "update_team_leader_res";
status: number;
}