feat(稷下学宫): 新增初始角色卡刷新接口

This commit is contained in:
zhangxk
2023-09-13 17:02:00 +08:00
parent 3500e32054
commit 3085f7f3aa
3 changed files with 38 additions and 1 deletions

View File

@@ -111,6 +111,33 @@ export class RougeHandler {
return resResult(STATUS.SUCCESS, { gameCode, ...result })
}
/**
* 角色卡刷新
* @param msg
* @param session
* @returns
*/
async refreshInitCharaCard(msg: { gameCode: string }, session: BackendSession) {
const roleId = session.get('roleId');
const { gameCode } = msg;
let dbRecord = await RougelikeRecordModel.findByGameCode(gameCode)
if (!dbRecord) return resResult(STATUS.NO_ROUGELIKE_GAME);
const { type = 0, grade = 0 } = dbRecord;
await RougelikeCharaModel.deleteCharaByRoleId(roleId);
const charaCards = getInitCharaCard() || [];
let handleAddFun = new HandleAddCard(session, gameCode);
for (let ele of charaCards) {
handleAddFun.pushChara(ele.id, await getMaxHp(roleId, gameCode, ele.id, type, grade), []);
}
let result = await handleAddFun.save();
return resResult(STATUS.SUCCESS, { gameCode, charas: result?.addCharas || [] })
}
/**
* 开启一场游戏
* @param msg

View File

@@ -878,7 +878,12 @@ export function checkRouteParam(route: string, msg: any) {
if (!checkNaturalNumbers(type, grade)) return false;
break;
}
case "battle.rougeHandler.refreshInitCharaCard":
{
let { gameCode } = msg
if (!checkNaturalStrings(gameCode)) return false;
break;
}
case "battle.rougeHandler.startGame":
{
let { gameCode, authorType } = msg;

View File

@@ -127,6 +127,11 @@ export default class RougelikeChara extends BaseModel {
}))
}
public static async deleteCharaByRoleId(roleId: string) {
let result = await RougelikeCharaModel.deleteMany({ roleId });
return result;
}
};
export const RougelikeCharaModel = getModelForClass(RougelikeChara);