商店:回收将魂
This commit is contained in:
@@ -132,6 +132,7 @@ export class RaceActivityHandler {
|
||||
let sid = session.get('sid');
|
||||
|
||||
let {id, count, toGuild} = msg;
|
||||
if(!count || count < 0) return resResult(STATUS.WRONG_PARMS);
|
||||
let obj = getRaceActivityObj();
|
||||
let woodenHorse = obj.getWoodenHorse(toGuild, serverId);
|
||||
if(!woodenHorse) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { Application, BackendSession } from "pinus";
|
||||
import { gameData } from "../../../pubUtils/data";
|
||||
import { resResult } from "../../../pubUtils/util";
|
||||
import { STATUS, GUILD_STRUCTURE } from "../../../consts";
|
||||
import { STATUS, GUILD_STRUCTURE, ITID, CONSUME_TYPE, HERO_QUALITY_TYPE } from "../../../consts";
|
||||
import { DicShopListModel } from "../../../db/DicShopList";
|
||||
import { ShopItem } from "../../../domain/dbGeneral";
|
||||
import { ShopItemListParam } from '../../../domain/roleField/shop';
|
||||
import { UserShopModel } from "../../../db/UserShop";
|
||||
import { handleCost, addItems } from "../../../services/rewardService";
|
||||
import { GuildModel } from "../../../db/Guild";
|
||||
import { SHOP } from "../../../pubUtils/dicParam";
|
||||
import { getHonourObject } from "../../../pubUtils/itemUtils";
|
||||
|
||||
export default function(app: Application) {
|
||||
return new ShopHandler(app);
|
||||
@@ -135,7 +137,44 @@ export class ShopHandler {
|
||||
|
||||
// 将魂回收
|
||||
async recycleSoul(msg: { goodsId: number, count: number }, session: BackendSession) {
|
||||
|
||||
let roleId = session.get('roleId');
|
||||
let roleName = session.get('roleName');
|
||||
let sid = session.get('sid');
|
||||
let { goodsId, count } = msg;
|
||||
if(!count || count < 0) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let dicGoods = gameData.goods.get(goodsId);
|
||||
if(!dicGoods) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
let dicItid = ITID.get(dicGoods.itid);
|
||||
if(!dicItid) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if(dicItid.type != CONSUME_TYPE.SOUL) {
|
||||
return resResult(STATUS.ITEM_NOT_SOUL);
|
||||
}
|
||||
|
||||
// 检查自己的数量
|
||||
let cost = [{
|
||||
id: goodsId, count
|
||||
}];
|
||||
let costResult = await handleCost(roleId, sid, cost);
|
||||
if(!costResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
let honour = 0;
|
||||
switch (dicGoods.quality) {
|
||||
case HERO_QUALITY_TYPE.BLUE:
|
||||
honour = SHOP.HERO_SOUL_BULE * count; break;
|
||||
case HERO_QUALITY_TYPE.PURPLE:
|
||||
honour = SHOP.HERO_SOUL_PURPLE * count; break;
|
||||
case HERO_QUALITY_TYPE.GOLD:
|
||||
honour = SHOP.HERO_SOUL_GOLDEN * count; break;
|
||||
}
|
||||
// 增加功勋
|
||||
let reward = getHonourObject(honour);
|
||||
let goods = await addItems(roleId, roleName, sid, [reward]);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
goodsId, count,
|
||||
goods
|
||||
});
|
||||
}
|
||||
|
||||
// !测试接口,初始化:将json表中的内容加入数据库内
|
||||
|
||||
Reference in New Issue
Block a user