装备:淬火

This commit is contained in:
luying
2021-07-29 14:21:51 +08:00
parent dc832da60a
commit 972abb7d07
19 changed files with 805 additions and 68 deletions
+24 -6
View File
@@ -2,9 +2,9 @@
import { HeroModel, HeroType } from '../db/Hero';
import { ItemModel } from '../db/Item';
import { EquipModel, RandSe, Holes } from './../db/Equip';
import { EquipModel, RandSe, Holes, RandMain } from './../db/Equip';
import { BagInter, EquipInter } from './interface';
import { gameData } from './data';
import { gameData, getQuenchByQualityAndGrade, getQuenchGradeByValue } from './data';
import { RANDOM_SE_COUNT, FIX_ATTRIBUTES_RAN, 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';
@@ -55,9 +55,11 @@ export async function addBags(roleId: string, roleName: string, data: BagInter)
}
export async function addEquips(roleId: string, roleName: string, weapon: EquipInter) {
let { id, name, quality, suitId, hole, randomEffect, itid, hid } = weapon;
let { id, hid = 0 } = weapon;
let { name, quality, suitId, hole, randomEffect, itid, goodsAbility } = gameData.goods.get(id);
let { type } = ITID.get(itid);
// 随机属性
let randomNum = RANDOM_SE_COUNT.get(quality);
let randomResult: number[] = getRandEelm(randomEffect, randomNum);
@@ -73,14 +75,30 @@ export async function addEquips(roleId: string, roleName: string, weapon: EquipI
};
});
let randRange = getRandValueByMinMax(0 - FIX_ATTRIBUTES_RAN, FIX_ATTRIBUTES_RAN, 0);
let randRange = 0;
// 淬火品相
let randMain: RandMain[] = [];
let grade = 0;
for(let [ attrId, attrValue ] of goodsAbility) {
if(attrValue > 0) {
let { min, max } = getQuenchByQualityAndGrade(quality, grade);
let rand = getRandValueByMinMax(min, max, 0);
grade = getQuenchGradeByValue(rand);
randMain.push({
id: attrId,
rand
});
}
}
let holes = new Array<Holes>();
for (let i = 0; i < hole; i++) {
holes.push({ id: i + 1, isOpen: false, jewel: 0 })
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 });
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);