数数:消耗来源

This commit is contained in:
luying
2021-12-14 13:18:23 +08:00
parent e9c471c583
commit b6501ee4a2
70 changed files with 503 additions and 305 deletions

View File

@@ -1,6 +1,6 @@
import { Application, BackendSession, HandlerService, } from "pinus";
import { resResult, shouldRefresh, getRandSingleEelm } from "../../../pubUtils/util";
import { STATUS, GACHA_ID, HERO_QUALITY_TYPE, TASK_TYPE, } from "../../../consts";
import { STATUS, GACHA_ID, HERO_QUALITY_TYPE, TASK_TYPE, ITEM_CHANGE_REASON, } from "../../../consts";
import { gameData } from "../../../pubUtils/data";
import { GachaResult, GachaData } from "../../../domain/activityField/gachaField";
import { UserGachaModel } from "../../../db/UserGacha";
@@ -85,13 +85,13 @@ export class GachaHandler {
// 消耗东西
if (costNum > 0) {
let cost = dicGacha.cost.map(cur => { return { id: cur.id, count: cur.count * costNum } });
let costResult = await handleCost(roleId, sid, cost);
let costResult = await handleCost(roleId, sid, cost, ITEM_CHANGE_REASON.GACHA_PULL);
if (!costResult) return resResult(STATUS.GACHA_COST_NOT_ENOUGH);
}
// 给东西
// console.log('****', heroInfo)
let { heroes, resultHeroes } = await createHeroes(roleId, roleName, sid, serverId, heroInfo);
await addItems(roleId, roleName, sid, items);
await addItems(roleId, roleName, sid, items, ITEM_CHANGE_REASON.GACHA_ITEMS);
// 更新数据
userGacha = await UserGachaModel.updateInfo(roleId, gachaId, activityId, {
freeCount, hope, floor, count: historyCount + count
@@ -328,7 +328,7 @@ export class GachaHandler {
visitedHero.push(hid);
let userGacha = await UserGachaModel.updateInfo(roleId, GACHA_ID.NORMAL, 0, { visitedHero, refVisitedTime });
let goods = await addItems(roleId, roleName, sid, [{ id: pieceId, count: RECRUIT.RECRUIT_SHARD_LIMIT }]);
let goods = await addItems(roleId, roleName, sid, [{ id: pieceId, count: RECRUIT.RECRUIT_SHARD_LIMIT }], ITEM_CHANGE_REASON.VISIT_HERO);
return resResult(STATUS.SUCCESS, {
hids: userGacha.visitedHero,
@@ -376,7 +376,7 @@ export class GachaHandler {
if(guideCount == 0) {
// 消耗东西
let cost = dicGacha.cost.map(cur => { return { id: cur.id, count: cur.count * count } });
let costResult = await handleCost(roleId, sid, cost);
let costResult = await handleCost(roleId, sid, cost, ITEM_CHANGE_REASON.GACHA_PULL);
if (!costResult) return resResult(STATUS.GACHA_COST_NOT_ENOUGH);
}
@@ -468,7 +468,7 @@ export class GachaHandler {
// 给东西
// console.log('****', heroInfo)
let { heroes, resultHeroes } = await createHeroes(roleId, roleName, sid, serverId, heroInfo);
await addItems(roleId, roleName, sid, items);
await addItems(roleId, roleName, sid, items, ITEM_CHANGE_REASON.GACHA_ITEMS);
// 更新数据
role = await RoleModel.updateRoleInfo(roleId, { gachaHasGuide: true });
await UserGachaRecModel.createRec(roleId, gachaId, 0, count, resultList);