物品:获取装备上限
This commit is contained in:
@@ -2,8 +2,7 @@
|
||||
|
||||
import { HeroModel, HeroType } from '../db/Hero';
|
||||
import { ItemModel } from '../db/Item';
|
||||
import { EquipModel, RandSe, Holes, RandMain } from './../db/Equip';
|
||||
import { BagInter, EquipInter } from './interface';
|
||||
import { EquipModel, RandSe, Holes, RandMain, equipUpdate } from './../db/Equip';
|
||||
import { gameData, getQuenchByQualityAndGrade, getQuenchGradeByValue } from './data';
|
||||
import { RANDOM_SE_COUNT, ITID, CURRENCY_BY_TYPE, CURRENCY_TYPE, ROLE_SELECT, FIGURE_UNLOCK_CONDITION, CONSUME_TYPE, HERO_SYSTEM_TYPE, TASK_TYPE } from '../consts';
|
||||
import { getRandValueByMinMax, getRandEelm } from './util';
|
||||
@@ -16,6 +15,7 @@ import { calPlayerCeAndSave, reCalAllHeroCe } from './playerCe';
|
||||
import { checkTask, checkTaskWithHeroes, checkTaskWithEquip, accomplishTask } from './taskUtil';
|
||||
import { CreateHeroParam } from '../domain/roleField/hero';
|
||||
import { SkinModel } from '../db/Skin';
|
||||
import { TaskListReturn } from '../domain/roleField/task';
|
||||
|
||||
/**
|
||||
* 添加皮肤
|
||||
@@ -48,13 +48,44 @@ export async function addSkin(roleId: string, roleName: string, skinId: number,
|
||||
}
|
||||
}
|
||||
|
||||
export async function addBags(roleId: string, roleName: string, data: BagInter) {
|
||||
let { id, count, itemName, type, hid } = data;
|
||||
export async function addBags(roleId: string, roleName: string, datas: { id: number, count: number }[]) {
|
||||
let items: { id: number, count: number }[] = [];
|
||||
for(let data of datas) {
|
||||
let item = await addBag(roleId, roleName, data);
|
||||
items.push(item)
|
||||
}
|
||||
return { items }
|
||||
}
|
||||
|
||||
export async function addBag(roleId: string, roleName: string, data: { id: number, count: number }) {
|
||||
let { id, count } = data;
|
||||
let { name: itemName, itid, hid } = gameData.goods.get(id);
|
||||
let { type } = ITID.get(itid);
|
||||
|
||||
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) {
|
||||
|
||||
export async function addEquips(roleId: string, roleName: string, weapons: { id: number, hid?: number }[]) {
|
||||
let equipInfos: equipUpdate[] = [];
|
||||
for(let weapon of weapons) {
|
||||
let info = await getAddEquipInfo(roleId, roleName, weapon);
|
||||
equipInfos.push(info);
|
||||
}
|
||||
|
||||
const equips = await EquipModel.createEquips(roleId, equipInfos);
|
||||
let pushMessages: TaskListReturn[] = [];
|
||||
// 任务
|
||||
for(let equip of equips) {
|
||||
let pushMessage = await checkTaskWithEquip(roleId, TASK_TYPE.EQUIP_SUIT, equip);
|
||||
pushMessages = [...pushMessages, ...pushMessage];
|
||||
}
|
||||
|
||||
return { equips, pushMessages }
|
||||
}
|
||||
|
||||
export async function getAddEquipInfo(roleId: string, roleName: string, weapon: { id: number, hid?: number }) {
|
||||
let { id, hid = 0 } = weapon;
|
||||
let { name, quality, suitId, hole, randomEffect, itid, goodsAbility } = gameData.goods.get(id);
|
||||
let { type } = ITID.get(itid);
|
||||
@@ -84,6 +115,7 @@ export async function addEquips(roleId: string, roleName: string, weapon: EquipI
|
||||
if(attrValue > 0) {
|
||||
let { min, max } = getQuenchByQualityAndGrade(quality, grade);
|
||||
let rand = getRandValueByMinMax(min, max, 0);
|
||||
console.log(quality, grade, rand)
|
||||
grade = getQuenchGradeByValue(quality, rand);
|
||||
randMain.push({
|
||||
id: attrId,
|
||||
@@ -98,12 +130,7 @@ export async function addEquips(roleId: string, roleName: string, weapon: EquipI
|
||||
holes.push({ id: i + 1, isOpen: false, jewel: 0 });
|
||||
}
|
||||
|
||||
const equip = await EquipModel.createEquip({ roleId, roleName, id, name, quality, suitId, randRange, ePlaceId: type, randSe, holes, hid, grade, randMain });
|
||||
|
||||
// 任务
|
||||
let pushMessage = await checkTaskWithEquip(roleId, TASK_TYPE.EQUIP_SUIT, equip);
|
||||
|
||||
return { equipInfo: equip, pushMessage }
|
||||
return { roleId, roleName, id, name, quality, suitId, randRange, ePlaceId: type, randSe, holes, hid, grade, randMain };
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user