抽卡:修改抽卡概率
This commit is contained in:
@@ -4,18 +4,15 @@ import { STATUS, GACHA_ID, HERO_QUALITY_TYPE, TASK_TYPE, REFRESH_TIME, TIME_OUTP
|
||||
import { gameData } from "../../../pubUtils/data";
|
||||
import { GachaListReturn, GachaResult, GachaData } from "../../../domain/activityField/gachaField";
|
||||
import { UserGachaModel } from "../../../db/UserGacha";
|
||||
import { refreshGacha, getFloorResult, getResultFromContentId, getGachaList, getVisitedHeroList, getAllHeroByQuality } from "../../../services/activity/gachaService";
|
||||
import { refreshGacha, getFloorResult, getGachaList, getVisitedHeroList, getAllHeroByQuality, GachaPull } from "../../../services/activity/gachaService";
|
||||
import { RoleModel } from "../../../db/Role";
|
||||
import { HeroModel } from "../../../db/Hero";
|
||||
import { RewardInter } from "../../../pubUtils/interface";
|
||||
import { handleCost, createHeroes, addItems } from "../../../services/rewardService";
|
||||
import { getZeroPointD, getTimeFun } from "../../../pubUtils/timeUtil";
|
||||
import { UserGachaRecModel } from "../../../db/UserGachaRec";
|
||||
import { ActivityModel } from "../../../db/Activity";
|
||||
import { checkActivityTask, checkTask } from "../../../services/taskService";
|
||||
import { RECRUIT } from "../../../pubUtils/dicParam";
|
||||
import { transPiece } from "../../../pubUtils/itemUtils";
|
||||
import { CreateHeroParam } from "../../../domain/roleField/hero";
|
||||
|
||||
export default function (app: Application) {
|
||||
return new GachaHandler(app);
|
||||
@@ -61,37 +58,16 @@ export class GachaHandler {
|
||||
if (!dicGacha.count.includes(count)) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let userGacha = await UserGachaModel.findByRole(roleId, gachaId, activityId);
|
||||
let { floor, freeCount, hope, point, pickHero, refFreeTime, count: historyCount } = await refreshGacha(dicGacha, userGacha);
|
||||
userGacha = await refreshGacha(dicGacha, userGacha);
|
||||
let { freeCount, point, pickHero, refFreeTime, count: historyCount } = userGacha;
|
||||
if ((gachaId == GACHA_ID.ASSIGN || gachaId == GACHA_ID.TIMELIMIT) && !pickHero) return resResult(STATUS.GACHA_NOT_ASSIGN);
|
||||
|
||||
let userHeroes = await HeroModel.findByRole(roleId);
|
||||
|
||||
let items: RewardInter[] = [], heroInfo: CreateHeroParam[] = [], resultList: GachaResult[] = [];
|
||||
|
||||
let activityData = [];//活动需要统计抽中的英雄、碎片品质
|
||||
for (let i = 0; i < count; i++) {
|
||||
// 按照一般概率抽出
|
||||
let { dic: { id: base } } = getRandEelmWithWeight(dicGacha.percent);
|
||||
let contentId = getFloorResult(gachaId, base, floor);
|
||||
if (contentId == false) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
let result = getResultFromContentId(contentId, lv, hope);
|
||||
|
||||
if (result.hid > 0) {
|
||||
result.setSetPickHero(pickHero);
|
||||
let hasHero = userHeroes.find(cur => cur.hid == result.hid);
|
||||
if (hasHero) { // 已有转换为碎片
|
||||
activityData.push({ hid: hasHero.hid, quality: hasHero.quality });
|
||||
let { pieceId, count } = transPiece(result.hid);
|
||||
result.transferToPiece(pieceId, count);
|
||||
items.push({ id: pieceId, count });
|
||||
} else {
|
||||
heroInfo.push({ hid: result.hid, count: 1 })//默认1个英雄
|
||||
}
|
||||
} else {
|
||||
items.push({ id: result.id, count: result.count });
|
||||
}
|
||||
resultList.push(result);
|
||||
}
|
||||
let gachaPull = new GachaPull(gachaId, lv, userHeroes);
|
||||
gachaPull.setByUserGacha(dicGacha, userGacha);
|
||||
let { items, heroInfo, resultList, activityData } = gachaPull.pull(count);
|
||||
let { hope, floor } = gachaPull.getUserGachaParam(userGacha);
|
||||
|
||||
let costNum = count;
|
||||
if (count == 1 && dicGacha.free.count > 0) { // 单抽的时候免费
|
||||
@@ -110,6 +86,7 @@ export class GachaHandler {
|
||||
if (!costResult) return resResult(STATUS.GACHA_COST_NOT_ENOUGH);
|
||||
}
|
||||
// 给东西
|
||||
console.log('****', heroInfo)
|
||||
let { heroes } = await createHeroes(roleId, roleName, sid, serverId, funcs, heroInfo);
|
||||
await addItems(roleId, roleName, sid, items);
|
||||
// 更新数据
|
||||
|
||||
Reference in New Issue
Block a user