红点:修改推送方式

This commit is contained in:
luying
2021-05-31 13:29:58 +08:00
parent 44d9e80640
commit a8eebc200c
38 changed files with 805 additions and 605 deletions

View File

@@ -1,10 +1,14 @@
import { ChannelUser } from './../domain/ChannelUser';
import { Channel } from 'pinus';
import { getRandValueByMinMax, getRandEelm } from '../pubUtils/util';
import { getRandValueByMinMax, getRandEelm, decodeIdCntArrayStr } from '../pubUtils/util';
import { TERAPH_RANDOM } from "../consts";
import { DicTeraph } from '../pubUtils/dictionary/DicTeraph';
import { Teraph, RoleModel } from '../db/Role';
import { ROLE_SELECT } from '../consts';
import { SCHOOL } from '../pubUtils/dicParam';
import { gameData } from '../pubUtils/data';
import { SchoolModel } from '../db/School';
import { SclResultInter, SclPosInter } from '../pubUtils/interface';
const TERAPH_STRENGTHEN = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
/**
* 计算强化次数和消耗
@@ -98,3 +102,43 @@ export async function getSimpleRoleInfos(roleIds: string[]) {
let roles = await RoleModel.findRoleByField('roleId', roleIds, ROLE_SELECT.SHOW_SIMPLE, true);
return roles;
}
/**
* 百家学宫
* @param roleId
*/
export async function getSchoolList(roleId: string) {
const dicPosition = decodeIdCntArrayStr(SCHOOL.SCHOOL_POSITION, 1); // id=>isOpen
const userSchoolList = await SchoolModel.findByRoleId(roleId);
let school = new Array<SclResultInter>();
gameData.school.forEach((dicSchool) => {
let position = new Array<SclPosInter>();
dicPosition.forEach((isOpen, dicId) => {
let id = parseInt(dicId);
let userSchool = userSchoolList.find(cur => cur.schoolId == dicSchool.id && cur.positionId == id);
if (userSchool) {
position.push({
id,
hid: userSchool.hid,
isOpen: userSchool.isOpen
});
} else {
position.push({
id,
hid: 0,
isOpen: !!isOpen
});
}
});
school.push({
id: dicSchool.id,
position
});
});
return school;
}