抽卡:获取抽卡列表
This commit is contained in:
94
game-server/app/servers/activity/handler/gachaHandler.ts
Normal file
94
game-server/app/servers/activity/handler/gachaHandler.ts
Normal file
@@ -0,0 +1,94 @@
|
||||
import { Application, BackendSession } from "pinus";
|
||||
import { resResult } from "../../../pubUtils/util";
|
||||
import { STATUS, GACHA_ID } from "../../../consts";
|
||||
import { gameData } from "../../../pubUtils/data";
|
||||
import { GachaListReturn } from "../../../domain/activityField/gachaField";
|
||||
import { UserGachaModel } from "../../../db/UserGacha";
|
||||
import { refreshFreeCount } from "../../../services/gachaService";
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
return new GachaHandler(app);
|
||||
}
|
||||
|
||||
export class GachaHandler {
|
||||
constructor(private app: Application) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取抽卡列表 元宝招募、友情点招募、求贤若渴
|
||||
* @param {{}} msg
|
||||
* @param {BackendSession} session
|
||||
* @memberof GachaHandler
|
||||
*/
|
||||
async getGachaList(msg: {}, session: BackendSession) {
|
||||
const { } = msg;
|
||||
const roleId: string = session.get('roleId');
|
||||
|
||||
let userGachaList = await UserGachaModel.findAllByRole(roleId);
|
||||
let list: GachaListReturn[] = [];
|
||||
for(let [id, dicGacha] of gameData.gacha) {
|
||||
if(id == GACHA_ID.TIMELIMIT) continue; // 不包括限时
|
||||
|
||||
let userGacha = userGachaList.find(cur => cur.gachaId == id);
|
||||
userGacha = await refreshFreeCount(dicGacha, userGacha);
|
||||
let param = new GachaListReturn(dicGacha, userGacha);
|
||||
list.push(param);
|
||||
}
|
||||
|
||||
return resResult(STATUS.SUCCESS, { list });
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 抽卡,所有抽卡类型都
|
||||
* @param {{ gachaId: number, activityId: number, count: number }} msg
|
||||
* @param {BackendSession} session
|
||||
* @memberof GachaHandler
|
||||
*/
|
||||
async pull(msg: { gachaId: number, activityId: number, count: number }, session: BackendSession) {
|
||||
const { gachaId, activityId, count } = msg;
|
||||
const roleId: string = session.get('roleId');
|
||||
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 设置心愿单
|
||||
* @param {{ gachaId: number, hope: { id: number, hid: number }[] }} msg
|
||||
* @param {BackendSession} session
|
||||
* @memberof GachaHandler
|
||||
*/
|
||||
async setHope(msg: { gachaId: number, hope: { id: number, hid: number }[] }, session: BackendSession) {
|
||||
const { gachaId, hope } = msg;
|
||||
const roleId: string = session.get('roleId');
|
||||
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 转盘
|
||||
* @param {{ gachaId: number }} msg
|
||||
* @param {BackendSession} session
|
||||
* @memberof GachaHandler
|
||||
*/
|
||||
async drawTurnTable(msg: { gachaId: number }, session: BackendSession) {
|
||||
const { gachaId } = msg;
|
||||
const roleId: string = session.get('roleId');
|
||||
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 求贤若渴&限时招募里面设置pick武将
|
||||
* @param {{ gachaId: number, pickHero: number }} msg
|
||||
* @param {BackendSession} session
|
||||
* @memberof GachaHandler
|
||||
*/
|
||||
async setPickHero(msg: { gachaId: number, pickHero: number }, session: BackendSession) {
|
||||
const { gachaId, pickHero } = msg;
|
||||
const roleId: string = session.get('roleId');
|
||||
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user