feat(db): 修改hero表数据库操作方式

This commit is contained in:
liangtongchuan
2023-05-06 17:07:48 +08:00
parent 3f3c1af549
commit 297e1af7ee
27 changed files with 133 additions and 137 deletions

View File

@@ -5,7 +5,7 @@ import { gameData } from "../../../pubUtils/data";
import { UserGachaModel } from "../../../db/UserGacha";
import { refreshGacha, getGachaList, getVisitedHeroList, GachaPull, GachaResults, getDicGachaByGachaCnt, getNormalGachaId, getDicGachas } from "../../../services/activity/gachaService";
import Role from "../../../db/Role";
import { HeroModel } from "../../../db/Hero";
import Hero from "../../../db/Hero";
import { handleCost, addItems } from "../../../services/role/rewardService";
import { getZeroPointD, getTimeFun } from "../../../pubUtils/timeUtil";
import { UserGachaRecModel } from "../../../db/UserGachaRec";
@@ -70,7 +70,7 @@ export class GachaHandler {
// console.log('##########', dic, min, max)
let _count = max + 1 - min;
let gachaPull = new GachaPull(dic, { hope, floor, pickHero });
let userHeroes = await HeroModel.findByRole(roleId);
let userHeroes = await Hero.findByRole(roleId);
let { resultList: _resultList, heroInfo: _heroInfo, items: _items } = gachaPull.pull(_count, userHeroes);
let { hope: _hope, floor: _floor } = gachaPull.getUserGachaParam();
resultList.push(..._resultList); heroInfo.push(..._heroInfo); items.push(..._items);
@@ -197,7 +197,7 @@ export class GachaHandler {
let randTurntable = getRandSingleEelm(turntablePool);
let { quality, count, planId } = randTurntable;
let userHeroes = await HeroModel.findByRole(roleId);
let userHeroes = await Hero.findByRole(roleId);
let gachaResults = new GachaResults();
gachaResults.addPlan(planId);
gachaResults.processDetail(null, count);
@@ -367,7 +367,7 @@ export class GachaHandler {
if (!costResult) return resResult(STATUS.GACHA_COST_NOT_ENOUGH);
}
let userHeroes = await HeroModel.findByRole(roleId);
let userHeroes = await Hero.findByRole(roleId);
let gachaPull = new GachaPull(dicGacha);
let { resultList } = gachaPull.pull(count, userHeroes);
@@ -438,7 +438,7 @@ export class GachaHandler {
let candidate = playerData.chooseCandidate(id);
if(!candidate) return resResult(STATUS.GACHA_GUIDE_NO_CANDIDATE);
let userHeroes = await HeroModel.findByRole(roleId);
let userHeroes = await Hero.findByRole(roleId);
let results = new GachaResults();
results.addBySimpleResult(candidate.list);
let { items, heroInfo, resultList } = results.transferToFinalResult(userHeroes);