GM后台添加皮肤
This commit is contained in:
@@ -2,14 +2,13 @@ import { GOOD_TYPE, ITID, CURRENCY, CURRENCY_TYPE, COUNTER, CONSUME_TYPE, getCur
|
||||
import { EquipModel } from './../db/Equip';
|
||||
import { CounterModel } from './../db/Counter';
|
||||
import { decodeStr, resResult } from '../pubUtils/util';
|
||||
import { getGoodById, getFashionsById } from '../pubUtils/gamedata';
|
||||
import { getGoodById } from '../pubUtils/gamedata';
|
||||
import { RoleModel } from '../db/Role';
|
||||
import { setAp } from './actionPointService';
|
||||
import { ItemModel } from '../db/Item';
|
||||
import { STATUS } from '../consts/statusCode';
|
||||
import { pinus } from 'pinus';
|
||||
import { HeroModel } from '../db/Hero';
|
||||
import { treatTask } from './battleService';
|
||||
import { addEquips, addBags, addSkins } from '../pubUtils/itemUtils';
|
||||
const _ = require('underscore');
|
||||
|
||||
export async function handleFixedReward(roleId: string, roleName: string, rewardStr: string, multi: number) {
|
||||
@@ -298,31 +297,4 @@ function sortItems (goods: Array<Item>, bags: Array<Bag>, skins: Array<number>,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function addSkins(roleId: string, id: number) {
|
||||
let skinInfo = getFashionsById(id);
|
||||
if (!skinInfo)
|
||||
return false;
|
||||
let hero = await HeroModel.findByHidAndRole(skinInfo.actorId, roleId, false);
|
||||
if (!hero)
|
||||
return false;
|
||||
if (!!_.findWhere(hero.skins, {id}))
|
||||
return false;
|
||||
hero.skins.push({id, enable: false});
|
||||
await HeroModel.updateHeroInfo(roleId, hero.hid, hero);
|
||||
return {skins: hero.skins, hid: hero.hid};
|
||||
}
|
||||
|
||||
async function addBags(roleId: string, roleName: string, data:Bag) {
|
||||
let {id, count, itemName, type, hid} = data;
|
||||
let item = await ItemModel.increaseItem(roleId, id, count, {roleId, roleName, itemName, id, type, hid});
|
||||
return {id:item.id, count: item.count};
|
||||
}
|
||||
|
||||
async function addEquips (roleId: string, roleName: string, weapon: Equip) {
|
||||
const seqId = await CounterModel.getNewCounter(COUNTER.EID);
|
||||
let equip = Object.assign({seqId, roleId, roleName}, weapon);
|
||||
return await EquipModel.createEquip(equip);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user