GM后台添加皮肤
This commit is contained in:
@@ -24,4 +24,7 @@ export interface Attributes {
|
||||
defIngnore?: number;
|
||||
bloodSuck?: number;
|
||||
ap?: number;
|
||||
}
|
||||
}
|
||||
|
||||
export interface EquipInter {id: number, name: string, quality: number, type: number};
|
||||
export interface BagInter {id: number, itemName: string, count: number, type: number, hid:number};
|
||||
37
shared/pubUtils/itemUtils.ts
Normal file
37
shared/pubUtils/itemUtils.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
|
||||
import { HeroModel } from '../db/Hero';
|
||||
import { ItemModel } from '../db/Item';
|
||||
import { EquipModel } from './../db/Equip';
|
||||
import { CounterModel } from './../db/Counter';
|
||||
import { COUNTER } from './../consts/consts';
|
||||
import { BagInter, EquipInter } from './interface';
|
||||
import { gameData } from './data';
|
||||
|
||||
const _ = require('underscore');
|
||||
|
||||
export async function addSkins(roleId: string, id: number) {
|
||||
let skinInfo = gameData.fashion.get(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 };
|
||||
}
|
||||
|
||||
export async function addBags(roleId: string, roleName: string, data: BagInter) {
|
||||
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 };
|
||||
}
|
||||
|
||||
export async function addEquips(roleId: string, roleName: string, weapon: EquipInter) {
|
||||
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