✨ feat(db): 修改hero表数据库操作方式
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { FIGURE_UNLOCK_CONDITION, ITEM_CHANGE_REASON, REDIS_KEY, STATUS, TASK_TYPE, HERO_SYSTEM_TYPE, LINEUP_NUM, COUNTER, PUSH_ROUTE } from "../../consts";
|
||||
import { SkinModel } from "../../db/Skin";
|
||||
import { HeroModel, HeroSkin, HeroType, HeroUpdate } from "../../db/Hero";
|
||||
import Hero, { HeroSkin, HeroType, HeroUpdate } from "../../db/Hero";
|
||||
import { SkinUpdate } from "../../db/Skin";
|
||||
import { nowSeconds } from "../../pubUtils/timeUtil";
|
||||
import { CreateHeroParam, HeroParam, HeroShowParam } from "../../domain/roleField/hero";
|
||||
@@ -25,7 +25,7 @@ import { pushGetHero } from "../sysChatService";
|
||||
export async function createHeroes(roleId: string, roleName: string, sid: string, serverId: number, heroInfo: CreateHeroParam[], initRoleInfos?: RoleUpdate) {
|
||||
heroInfo = filterHeroes(heroInfo, obj => obj.hid, roleId);
|
||||
let hids = heroInfo.map(cur => cur.hid);
|
||||
let userHeroesMap = await HeroModel.findMapByHidRange(hids, roleId);
|
||||
let userHeroesMap = await Hero.findMapByHidRange(hids, roleId);
|
||||
|
||||
let createHeroeInfos: CreateHeroParam[] = [], pieces: ItemInter[] = [];
|
||||
for (let h of heroInfo) {
|
||||
@@ -55,7 +55,7 @@ import { pushGetHero } from "../sysChatService";
|
||||
skins.push(initSkin); // 初始皮肤
|
||||
let seqId = await CounterModel.getNewCounter(COUNTER.HID) || -1;
|
||||
let initHeroSkins = [initSkin, ...originSkins].map((skin, index) => new HeroSkin(skin, index == 0));
|
||||
let initHero = HeroModel.getInitInfo(hid, { ...info, seqId, serverId, roleId, roleName, skins: initHeroSkins });
|
||||
let initHero = Hero.getInitInfo(hid, { ...info, seqId, serverId, roleId, roleName, skins: initHeroSkins });
|
||||
heroInfos.set(hid, initHero);
|
||||
figureConditions.push({ type: FIGURE_UNLOCK_CONDITION.GET_HERO, paramHid: hid });
|
||||
incHeroNum ++;
|
||||
|
||||
@@ -6,7 +6,7 @@ import { ItemModel, } from '../../db/Item';
|
||||
import { ItemInter, } from '../../pubUtils/interface';
|
||||
import { gameData, getDefArtifactByGid } from '../../pubUtils/data';
|
||||
import { uniq } from 'underscore';
|
||||
import { EPlace, HeroModel, HeroType, } from '../../db/Hero';
|
||||
import Hero, { EPlace, HeroType, } from '../../db/Hero';
|
||||
import { Figure } from '../../domain/dbGeneral';
|
||||
import { ArtifactParam, JewelParam } from '../../domain/roleField/hero';
|
||||
import { HeroSkin } from '../../db/Hero';
|
||||
@@ -78,7 +78,7 @@ export async function handleCost(roleId: string, sid: string, goods: Array<ItemI
|
||||
for(let jewel of resJewels) {
|
||||
if(jewel.hid > 0) {
|
||||
if(!heroMap.has(jewel.hid)) {
|
||||
let hero = await HeroModel.findByHidAndRole(jewel.hid, roleId);
|
||||
let hero = await Hero.findByHidAndRole(jewel.hid, roleId);
|
||||
heroMap.set(jewel.hid, { hero, jewels: [] });
|
||||
}
|
||||
heroMap.get(jewel.hid).jewels.push(jewel);
|
||||
@@ -349,7 +349,7 @@ export async function checkGoods(roleId: string, goodIds: Array<number>) {
|
||||
|
||||
export async function checkHeroes(roleId: string, hids: number[]) {
|
||||
if (!!hids.length) {
|
||||
let heros = await HeroModel.findByHidRange(hids, roleId);
|
||||
let heros = await Hero.findByHidRange(hids, roleId);
|
||||
if (heros.length < hids.length)
|
||||
return false;
|
||||
}
|
||||
@@ -357,7 +357,7 @@ export async function checkHeroes(roleId: string, hids: number[]) {
|
||||
}
|
||||
|
||||
export async function checkHeroEquips(roleId: string, quality: number) {
|
||||
return await HeroModel.checkEquipByQuality(roleId, quality);
|
||||
return await Hero.checkEquipByQuality(roleId, quality);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -429,7 +429,7 @@ export async function addSkin(roleId: string, roleName: string, serverId: number
|
||||
let skin = await increaseSkin(roleId, roleName, skinId);
|
||||
if(!skin) return false;
|
||||
|
||||
if(skin.hid && !hero) hero = await HeroModel.findByHidAndRole(skin.hid, roleId);
|
||||
if(skin.hid && !hero) hero = await Hero.findByHidAndRole(skin.hid, roleId);
|
||||
let condition = { type: FIGURE_UNLOCK_CONDITION.GET_SKIN, paramSkinId: skinId };
|
||||
await unlockFigure(sid, roleId, [condition]); // 解锁头像
|
||||
await calculateCeWithRole(HERO_SYSTEM_TYPE.ADD_SKIN, roleId, serverId, sid, {}, { skinId }); // 全局加成
|
||||
@@ -438,7 +438,7 @@ export async function addSkin(roleId: string, roleName: string, serverId: number
|
||||
let curSkin = hero.skins.find(cur => cur.id == skinId);
|
||||
if (!curSkin) {
|
||||
hero.skins.push(new HeroSkin(skin, enable));
|
||||
await HeroModel.updateHeroInfo(roleId, hero.hid, hero);
|
||||
await Hero.updateHeroInfo(roleId, hero.hid, hero);
|
||||
}
|
||||
return hero;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user