武将养成
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
import {Application, BackendSession, createTcpMailBox, ChannelService} from 'pinus';
|
import {Application, BackendSession, createTcpMailBox, ChannelService} from 'pinus';
|
||||||
import { handleCost } from '../../../services/rewardService';
|
import { handleCost } from '../../../services/rewardService';
|
||||||
|
import { calPlayerCeAndSave } from '../../../services/playerCeService';
|
||||||
import { resResult } from '../../../pubUtils/util';
|
import { resResult } from '../../../pubUtils/util';
|
||||||
import { STATUS } from '../../../consts/statusCode';
|
import { STATUS } from '../../../consts/statusCode';
|
||||||
|
import {HeroModel} from '../../../db/Hero';
|
||||||
|
import { getJobInfoById, getMaxGradeByjobClass , updateHeroInfo} from '../../../pubUtils/gamedata';
|
||||||
export default function(app: Application) {
|
export default function(app: Application) {
|
||||||
return new HeroHandler(app);
|
return new HeroHandler(app);
|
||||||
}
|
}
|
||||||
@@ -74,5 +76,49 @@ export class HeroHandler {
|
|||||||
// 升品,满品3级
|
// 升品,满品3级
|
||||||
// handleCost
|
// handleCost
|
||||||
}
|
}
|
||||||
|
//训练 TODO
|
||||||
|
async heroJobTrain (msg: {hid:number}, session: BackendSession) {
|
||||||
|
let roleId = session.get('roleId');
|
||||||
|
let { hid } = msg;
|
||||||
|
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||||
|
if (!hero)
|
||||||
|
return resResult(STATUS.WRONG_PARMS);
|
||||||
|
let heroJob = getJobInfoById(hero.job);
|
||||||
|
if (hero.jobStage >= 6)
|
||||||
|
return resResult(STATUS.HERO_JOB_STAGE_REACH_MAX_STAGE);
|
||||||
|
if (hero.job >= getMaxGradeByjobClass(heroJob.job_class))
|
||||||
|
return resResult(STATUS.HERO_JOB_REACH_MAX_STAGE);
|
||||||
|
//消耗物品TODO
|
||||||
|
|
||||||
|
hero.jobStage = hero.jobStage ++;
|
||||||
|
//重算战力并下发
|
||||||
|
let sid: string = session.get('sid');
|
||||||
|
let heros = await calPlayerCeAndSave(sid, roleId, [hero]);
|
||||||
|
return resResult(STATUS.SUCCESS, { hid : heros[0].hid, job : heros[0].job, jobStage : heros[0].jobStage});
|
||||||
|
}
|
||||||
|
//进阶 TODO
|
||||||
|
async heroJobStageUp() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//激活羁绊 TODO
|
||||||
|
async heroConectionActivate() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//赠送(包括一键赠送)TODO
|
||||||
|
async heroGiveFavor() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//购买时装
|
||||||
|
async buyHeroSkin() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//穿带时装
|
||||||
|
async heroWearSkin() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,6 +112,8 @@ export const STATUS = {
|
|||||||
DUNGEON_REFRESH_TIMES_LACK: { code: 20701, simStr: '购买次数不足' },
|
DUNGEON_REFRESH_TIMES_LACK: { code: 20701, simStr: '购买次数不足' },
|
||||||
DUNGEON_TIMES_LACK: { code: 20701, simStr: '挑战次数不足' },
|
DUNGEON_TIMES_LACK: { code: 20701, simStr: '挑战次数不足' },
|
||||||
// 养成相关状态 30000 - 39999
|
// 养成相关状态 30000 - 39999
|
||||||
|
HERO_JOB_REACH_MAX_STAGE: {code: 30001, simStr: '武将已达到最大的职业阶级'},
|
||||||
|
HERO_JOB_STAGE_REACH_MAX_STAGE: {code: 30001, simStr: '武将已训练到最大阶段'},
|
||||||
// 社交相关状态 40000 - 49999
|
// 社交相关状态 40000 - 49999
|
||||||
// 运营模块相关状态 50000 - 59999
|
// 运营模块相关状态 50000 - 59999
|
||||||
// GM后台相关状态 60000 - 69999
|
// GM后台相关状态 60000 - 69999
|
||||||
@@ -129,4 +131,5 @@ export const STATUS = {
|
|||||||
GM_PVP_DEFENSE_NOT_FOUND: { code: 60012, simStr: '该玩家未保存防守阵' },
|
GM_PVP_DEFENSE_NOT_FOUND: { code: 60012, simStr: '该玩家未保存防守阵' },
|
||||||
GM_PVP_DEFENSE_HERO_NOT_FOUND: { code: 60013, simStr: '该守阵没有该武将' },
|
GM_PVP_DEFENSE_HERO_NOT_FOUND: { code: 60013, simStr: '该守阵没有该武将' },
|
||||||
GM_JSON_FORMAT_ERR: { code: 60005, simStr: 'json格式错误' }
|
GM_JSON_FORMAT_ERR: { code: 60005, simStr: 'json格式错误' }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,30 @@ import { updateCe } from '../pubUtils/util';
|
|||||||
/**
|
/**
|
||||||
* 英雄表
|
* 英雄表
|
||||||
*/
|
*/
|
||||||
|
interface heroUpdate {
|
||||||
|
exp?: number;
|
||||||
|
lv?: number;
|
||||||
|
ce?: number;
|
||||||
|
star?: number;
|
||||||
|
starStage?: number;
|
||||||
|
fire?: number;
|
||||||
|
fireStage?: number;
|
||||||
|
quality?: number;
|
||||||
|
job?:number;
|
||||||
|
jobStage?:number;
|
||||||
|
favour?:number;
|
||||||
|
favourLv?:number;
|
||||||
|
skins?: [{
|
||||||
|
id: number;
|
||||||
|
enable: boolean;
|
||||||
|
}];
|
||||||
|
conections?: [{
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
valid: boolean;
|
||||||
|
}];
|
||||||
|
_id?:number;
|
||||||
|
}
|
||||||
@index({ roleId: 1, hid: 1 })
|
@index({ roleId: 1, hid: 1 })
|
||||||
@index({ roleId: 1, seqId: 1 })
|
@index({ roleId: 1, seqId: 1 })
|
||||||
export default class Hero extends BaseModel {
|
export default class Hero extends BaseModel {
|
||||||
@@ -140,6 +164,13 @@ export default class Hero extends BaseModel {
|
|||||||
return result||{};
|
return result||{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async updateHeroInfo(roleId: string, hid:number, heroUpdate:heroUpdate, lean = true) {
|
||||||
|
delete heroUpdate._id;
|
||||||
|
let result = await HeroModel.findOneAndUpdate({roleId, hid}, {$set:heroUpdate}).lean(lean);
|
||||||
|
return result||{};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const HeroModel = getModelForClass(Hero);
|
export const HeroModel = getModelForClass(Hero);
|
||||||
|
|
||||||
@@ -4,7 +4,10 @@ import { index, getModelForClass, prop } from '@typegoose/typegoose';
|
|||||||
import User from './User';
|
import User from './User';
|
||||||
import { shouldRefresh } from '../pubUtils/util';
|
import { shouldRefresh } from '../pubUtils/util';
|
||||||
import { HeroModel } from './Hero';
|
import { HeroModel } from './Hero';
|
||||||
|
interface roleUpdate {
|
||||||
|
ce?: number;
|
||||||
|
_id?:number;
|
||||||
|
}
|
||||||
class TopHero {
|
class TopHero {
|
||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
hid: number; // 武将id
|
hid: number; // 武将id
|
||||||
@@ -380,6 +383,12 @@ export default class Role extends BaseModel {
|
|||||||
const recs = await RoleModel.findOneAndUpdate({roleId}, {$push: {funcs: {$each: funcs}}}, {new: true}).lean(lean);
|
const recs = await RoleModel.findOneAndUpdate({roleId}, {$push: {funcs: {$each: funcs}}}, {new: true}).lean(lean);
|
||||||
return recs
|
return recs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async updateRoleInfo(roleId: string, roleUpdate:roleUpdate, lean = true) {
|
||||||
|
delete roleUpdate._id;
|
||||||
|
let result = await HeroModel.findOneAndUpdate({roleId}, {$set:roleUpdate}).lean(lean);
|
||||||
|
return result||{};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const RoleModel = getModelForClass(Role);
|
export const RoleModel = getModelForClass(Role);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ const towerInfos = new Map<number, any>();
|
|||||||
const towerTaskInfos = new Map<number, any>();
|
const towerTaskInfos = new Map<number, any>();
|
||||||
const heroInfos = new Map<number, any>();
|
const heroInfos = new Map<number, any>();
|
||||||
const jobInfos = new Map<number, any>();
|
const jobInfos = new Map<number, any>();
|
||||||
|
const jobClassMaxGrades = new Map<number, number>();
|
||||||
const levelInfos = new Map<number, {sum: number, cur: number}>();
|
const levelInfos = new Map<number, {sum: number, cur: number}>();
|
||||||
const starRatioInfo = new Map<number, number>();
|
const starRatioInfo = new Map<number, number>();
|
||||||
const heroSkillInfo = new Map<number, any>()
|
const heroSkillInfo = new Map<number, any>()
|
||||||
@@ -96,6 +97,10 @@ function parseJobData() {
|
|||||||
jobsData.forEach(elem => {
|
jobsData.forEach(elem => {
|
||||||
if (elem && elem.jobid) {
|
if (elem && elem.jobid) {
|
||||||
jobInfos.set(elem.jobid, elem);
|
jobInfos.set(elem.jobid, elem);
|
||||||
|
let maxLevel = jobClassMaxGrades.get(elem.job_class)||0;
|
||||||
|
if (maxLevel < elem.grade) {
|
||||||
|
jobClassMaxGrades.set(elem.job_class, elem.grade);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -311,6 +316,10 @@ export function getJobInfoById(jid: number) {
|
|||||||
const jobInfo = jobInfos.get(jid);
|
const jobInfo = jobInfos.get(jid);
|
||||||
return jobInfo;
|
return jobInfo;
|
||||||
}
|
}
|
||||||
|
export function getMaxGradeByjobClass(jobClass: number) {
|
||||||
|
const maxGrade = jobClassMaxGrades.get(jobClass);
|
||||||
|
return maxGrade;
|
||||||
|
}
|
||||||
|
|
||||||
export function getLvByExp(exp: number) {
|
export function getLvByExp(exp: number) {
|
||||||
let curLv = 0;
|
let curLv = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user