装备:获得天晶石&合成装备

This commit is contained in:
luying
2022-02-15 18:46:56 +08:00
parent ecc55b3063
commit 465cc15e43
30 changed files with 506 additions and 283 deletions
+13 -6
View File
@@ -1,5 +1,5 @@
import { dicHero, dicMyHeroes, loadHero } from "./dictionary/DicHero";
import { dicGoods, blueprtWithQuality, blueprtWithQualityAndStar, dicJewel, figureCondition, loadGoods } from "./dictionary/DicGoods";
import { dicGoods, blueprtWithQuality, blueprtWithQualityAndStar, figureCondition, loadGoods } from "./dictionary/DicGoods";
import { dicBlueprtCompose, loadBlueprtCompose } from "./dictionary/DicBlueprtCompose";
import { dicBlueprtPossibility, loadBlueprtPossibility } from "./dictionary/DicBlueprtPossibility";
import { dicDaily, loadDaily } from "./dictionary/DicDaily";
@@ -100,6 +100,8 @@ import { dicApiById, dicApiByUrl, loadApi } from './dictionary/DicApi';
import { dicServerConst, loadServerConst } from './dictionary/DicServerConst';
import { pick } from "underscore";
import _ = require("underscore");
import { dicEquipById, dicEquipIdByJobClassAndEplace, loadEquip } from "./dictionary/DicEquip";
import { dicJewel, loadJewel } from "./dictionary/DicJewel";
export const gameData = {
blurprtCompose: dicBlueprtCompose,
@@ -144,7 +146,6 @@ export const gameData = {
randomEffectPool: dicRandomEffectPool,
strengthenCost: dicStrengthenCost,
refine: dicRefine,
jewels: dicJewel,
dicHeroEquip: dicHeroEquip,
suit: dicSuit,
suitByTypeAndLv: dicSuitByTypeAndLv,
@@ -249,6 +250,9 @@ export const gameData = {
apiById: dicApiById,
apiByUrl: dicApiByUrl,
serverConst: dicServerConst,
equipById: dicEquipById,
equipIdByJobAndEPlace: dicEquipIdByJobClassAndEplace,
jewel: dicJewel,
};
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
@@ -409,10 +413,6 @@ export function getGoodById(gid: number) {
return gameData.goods.get(gid);
}
export function getJewelById(gid: number) {
return gameData.jewels.get(gid);
}
export function getHeroEquipByClassId(classId: number) {
return gameData.dicHeroEquip.get(classId);
}
@@ -834,6 +834,11 @@ function splitTime(str: string) {
return { hour: parseInt(arr[0]), minute: parseInt(arr[1]), seconds: parseInt(arr[2]) }
}
export function getEquipByJobClassAndEPlace(jobClass: number, eplaceId: number) {
let equipId = gameData.equipIdByJobAndEPlace.get(`${jobClass}_${eplaceId}`);
return gameData.equipById.get(equipId);
}
// 初始加载
function initDatas() {
parseDicParam();
@@ -999,6 +1004,8 @@ function loadDatas() {
loadGuildWishReward();
loadApi();
loadServerConst();
loadEquip();
loadJewel();
}
// 重载dicParam
+54
View File
@@ -0,0 +1,54 @@
// 装备表
import { readFileAndParse, decodeArrayListStr, parseGoodStr } from '../util'
import { FILENAME } from '../../consts'
import { RewardInter } from '../interface';
export interface DicEquip {
// (key) 装备的id
readonly id: number;
// 装备的位置(武器、衣甲、帽冠、行具)
readonly eplaceId: number;
// 装备名
readonly name: string;
// 匹配的武将的职业的大类
readonly jobClass: number;
// 套装id
readonly suitId: number;
// 属性提升
readonly attribute: {id: number, num: number}[];
// 属性成长加成提升
readonly attributeUp: {id: number, num: number}[];
// 合成消耗
readonly composeMaterial: RewardInter[];
}
export const dicEquipById = new Map<number, DicEquip>();
export const dicEquipIdByJobClassAndEplace = new Map<string, number>();
export function loadEquip() {
dicEquipById.clear();
dicEquipIdByJobClassAndEplace.clear();
let arr = readFileAndParse(FILENAME.DIC_EQUIP);
arr.forEach(o => {
o.attribute = parseAttr(o.attribute);
o.attributeUp = parseAttr(o.attributeUp);
o.composeMaterial = parseGoodStr(o.composeMaterial);
dicEquipById.set(o.id, o);
dicEquipIdByJobClassAndEplace.set(`${o.jobClass}_${o.eplaceId}`, o.id);
});
arr = undefined;
}
function parseAttr(str: string) {
let result = new Array<{id: number, num: number}>();
if(!str) return result;
let decodeArr = decodeArrayListStr(str);
for(let [id, num] of decodeArr) {
if(isNaN(parseInt(id)) || isNaN(parseInt(num))) {
throw new Error('data table format wrong');
}
result.push({id: parseInt(id), num: parseInt(num)});
}
return result
}
@@ -0,0 +1,26 @@
// 装备强化表
import { readFileAndParse, parseGoodStr } from '../util'
import { FILENAME } from '../../consts'
import { RewardInter } from '../interface';
export interface DicEquipStrength {
// id
readonly id: number;
// 等级
readonly lv: number;
// 消耗
readonly consume: RewardInter[];
}
export const dicEquipStrength = new Map<number, DicEquipStrength>();
export function loadEquipStrength() {
dicEquipStrength.clear();
let arr = readFileAndParse(FILENAME.DIC_EQUIP);
arr.forEach(o => {
o.consume = parseGoodStr(o.consume);
dicEquipStrength.set(o.lv, o);
});
arr = undefined;
}
@@ -0,0 +1,44 @@
// 装备套装表
import { readFileAndParse, parseNumberList, decodeArrayListStr } from '../util'
import { FILENAME } from '../../consts'
export interface DicEquipSuit {
// id
readonly id: number;
// 匹配的武将的职业的大类
readonly jobClass: number;
// 套装内含的装备编号
readonly equips: number[];
// 按星级可解锁的属性
readonly effect: { star: number, seid: number }[];
// 解锁条件索引
readonly effectCondition: Map<number, number>
}
export const dicEquipSuit = new Map<number, DicEquipSuit>();
export function loadEquipSuit() {
dicEquipSuit.clear();
let arr = readFileAndParse(FILENAME.DIC_EQUIP);
arr.forEach(o => {
o.equips = parseNumberList(o.equips);
parseRandomEffect(o, o.effect);
dicEquipSuit.set(o.jobClass, o);
});
arr = undefined;
}
function parseRandomEffect(o: any, str: string) {
if (!str) return null;
let decodeArr = decodeArrayListStr(str);
let effect: number[] = [], effectCondition = new Map<number, number>();
for (let [star, seid] of decodeArr) {
if (isNaN(parseInt(star)) || isNaN(parseFloat(seid))) {
throw new Error('data table format wrong');
}
effect.push(parseInt(seid));
effectCondition.set(parseInt(seid), parseInt(star));
}
o.effect = effect;
o.effectCondition = effectCondition;
}
+1 -19
View File
@@ -1,6 +1,6 @@
// 物品表
import { decodeArrayListStr, readFileAndParse, parseGoodStr, parseNumberList, decodeArrayStr } from '../util'
import { FILENAME, IT_TYPE, ABI_TYPE, GOOD_TYPE } from '../../consts'
import { FILENAME, IT_TYPE, ABI_TYPE } from '../../consts'
import { RewardInter } from '../interface';
const _ = require('lodash');
import { findWhere } from 'underscore';
@@ -108,14 +108,12 @@ const DicGoodsKeys: KeysEnum<DicGoods> = {
charLimited: true,
equipLvl: true
}
export const dicJewel = new Map<number, DicGoods>();
export const dicGoods = new Map<number, DicGoods>();
export const blueprtWithQuality = new Map<number, Array<number>>();
export const blueprtWithQualityAndStar = new Map<string, Array<number>>();
export const figureCondition = new Map<number, { params: number[], id: number, gid: number }[]>(); // type => {params, id, gid}
export function loadGoods() {
dicJewel.clear();
dicGoods.clear();
blueprtWithQuality.clear();
blueprtWithQualityAndStar.clear();
@@ -155,22 +153,6 @@ export function loadGoods() {
let arr2 = blueprtWithQuality.get(o.quality) || new Array<number>();
arr.push(o.good_id);
blueprtWithQuality.set(o.quality, arr2);
} else if (o.goodType == GOOD_TYPE.JEWEL) {
let material = o.composeMaterial[0];
if (!!material && !!material.id) {
let lastJewel = findWhere(arr, { good_id: material.id });
if (!!lastJewel) {
lastJewel.count = material.count;
lastJewel.nextJewelId = o.good_id;
if (!!o.specialMaterial.ids[0]) {
lastJewel.specialCount = o.specialMaterial.count;
lastJewel.nextSpecialId = o.specialMaterial.ids[0];
}
dicJewel.set(lastJewel.good_id, _.pick(lastJewel, Object.keys(DicGoodsKeys)));
}
} else {
dicJewel.set(o.good_id, _.pick(o, Object.keys(DicGoodsKeys)));
}
}
});
+42
View File
@@ -0,0 +1,42 @@
// 天晶石表
import { decodeArrayListStr, readFileAndParse, parseGoodStr, parseNumberList } from '../util'
import { FILENAME } from '../../consts';
import { RewardInter } from '../interface';
export interface DicJewel {
// 物品id
readonly good_id: number;
// 天晶石名
readonly name: string;
// 装备栏id
readonly eplaceId: number;
// itid
readonly itid: number;
// 天晶石阶
readonly lv: number;
// 天晶石品质
readonly quality: number;
// 天晶石属性条数
readonly effectCount: number;
// 套装效果
readonly randomEffect: number[];
// 对应藏宝图id
readonly mapGoodId: number;
// 淬炼消耗
readonly quenchConsume: RewardInter[];
}
export const dicJewel = new Map<number, DicJewel>();
export function loadJewel() {
dicJewel.clear();
let arr = readFileAndParse(FILENAME.DIC_JEWEL);
arr.forEach(o => {
o.randomEffect = parseNumberList(o.randomEffect);
o.quenchConsume = parseGoodStr(o.quenchConsume);
dicJewel.set(o.good_id, o);
});
arr = undefined;
}
+1 -1
View File
@@ -1,4 +1,4 @@
// 镇念塔
// 套装
import { decodeArrayListStr, readFileAndParse, parseNumberList } from '../util'
import { FILENAME } from '../../consts';
+28 -59
View File
@@ -2,9 +2,8 @@
import { HeroModel, HeroType, } from '../db/Hero';
import { ItemModel } from '../db/Item';
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, ITEM_CHANGE_REASON } from '../consts';
import { gameData } from './data';
import { ITID, CURRENCY_BY_TYPE, CURRENCY_TYPE, ROLE_SELECT, FIGURE_UNLOCK_CONDITION, CONSUME_TYPE, HERO_SYSTEM_TYPE, ITEM_CHANGE_REASON } from '../consts';
import { getRandValueByMinMax, getRandEelm } from './util';
import { findWhere } from 'underscore';
@@ -12,10 +11,10 @@ import { RoleModel, RoleType, } from '../db/Role';
import { Figure } from '../domain/dbGeneral';
import { getTimeFun } from './timeUtil';
import { reCalAllHeroCe } from './playerCe';
import { checkTaskWithEquip } from './taskUtil';
// import { checkTask, checkTaskWithHeroes, checkTaskWithEquip, accomplishTask } from './taskUtil';
import { SkinModel, } from '../db/Skin';
import { TaskListReturn } from '../domain/roleField/task';
import { JewelModel, jewelUpdate, RandSe, } from '../db/Jewel';
/**
* 只插入皮肤,不管那么多的
@@ -80,76 +79,46 @@ export async function addBag(roleId: string, roleName: string, data: { id: numbe
}
export async function addEquips(roleId: string, roleName: string, weapons: { id: number, hid?: number }[], reason: number) {
let equipInfos: equipUpdate[] = [];
for(let weapon of weapons) {
let info = await getAddEquipInfo(roleId, roleName, weapon);
equipInfos.push(info);
export async function addJewels(roleId: string, roleName: string, jewels: { id: number, hid?: number }[], reason: number) {
let jewelInfo: jewelUpdate[] = [];
for(let jewel of jewels) {
let info = await getAddJewelInfo(roleId, roleName, jewel);
jewelInfo.push(info);
}
const equips = await EquipModel.createEquips(roleId, equipInfos);
const jewelResult = await JewelModel.createJewels(roleId, jewelInfo);
let pushMessages: TaskListReturn[] = [];
// 任务
for(let equip of equips) {
let pushMessage = await checkTaskWithEquip(roleId, TASK_TYPE.EQUIP_SUIT, equip);
if(reason == ITEM_CHANGE_REASON.EQUIP_COMPOSE) {
let pm = await checkTaskWithEquip(roleId, TASK_TYPE.EQUIP_COMPOSE_SUIT, equip);
pushMessages.push(...pm);
}
pushMessages.push(...pushMessage);
}
// TODO 修改任务
// for(let equip of jewelResult) {
// let pushMessage = await checkTaskWithEquip(roleId, TASK_TYPE.EQUIP_SUIT, equip);
// if(reason == ITEM_CHANGE_REASON.EQUIP_COMPOSE) {
// let pm = await checkTaskWithEquip(roleId, TASK_TYPE.EQUIP_COMPOSE_SUIT, equip);
// pushMessages.push(...pm);
// }
// pushMessages.push(...pushMessage);
// }
return { equips: equips.map(equip => {
return { ...equip, inc: 1, reason }
return { jewels: jewelResult.map(jewel => {
return { ...jewel, count: 1, inc: 1, reason }
}), 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);
export async function getAddJewelInfo(roleId: string, roleName: string, jewel: { id: number, hid?: number, eplaceId?: number }) {
console.log('#####', jewel)
let { id, hid = 0, eplaceId = 0 } = jewel;
let { name, randomEffect, effectCount } = gameData.jewel.get(id);
// 随机属性
let randomNum = RANDOM_SE_COUNT.get(quality);
let randomResult: number[] = getRandEelm(randomEffect, randomNum);
let randomResult: number[] = getRandEelm(randomEffect, effectCount);
let randSe: Array<RandSe> = randomResult.map((id: number, i: number) => {
let randSe: Array<RandSe> = randomResult.map((id: number, index: number) => {
let random = gameData.randomEffectPool.get(id)
let rand = 0;
if (random.id > 0) rand = getRandValueByMinMax(random.Min, random.Max, 0);
return {
id: i + 1,
seid: random.id,
rand,
locked: false
};
return new RandSe(index + 1, random.id, rand);
});
let randRange = 0;
// 淬火品相
let randMain: RandMain[] = [];
let grade = 0;
for(let [ attrId, attrValue ] of goodsAbility) {
if(attrValue > 0) {
let { randMin, randMax } = getQuenchByQualityAndGrade(quality, grade);
let rand = getRandValueByMinMax(randMin, randMax, 0);
// console.log(quality, grade, rand)
grade = getQuenchGradeByValue(quality, 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 });
}
return { roleId, roleName, id, name, quality, suitId, randRange, ePlaceId: type, randSe, holes, hid, grade, randMain };
return { roleId, roleName, id, name, hid, eplaceId, randSe };
}
/**
+17 -4
View File
@@ -9,9 +9,8 @@ import { HeroModel, HeroType, HeroUpdate, CeAttrData } from '../db/Hero';
import { RoleModel, RoleType, RoleUpdate, CeAttrDataRole } from '../db/Role';
import { AttributeCal } from '../domain/roleField/attribute';
import { ABI_STAGE, SEID_TYPE } from '../consts';
import { gameData, getJobByGradeAndClass, getHeroWakeByQuality, getHeroStarByQuality, getFriendShipById, getSchoolRateByStar, getScollByStar, getTeraph, getDicSuitByTypeAndLv } from './data';
import { gameData, getJobByGradeAndClass, getHeroWakeByQuality, getHeroStarByQuality, getFriendShipById, getSchoolRateByStar, getScollByStar, getTeraph } from './data';
import { DicSe } from './dictionary/DicSe';
import { EquipType } from '../db/Equip';
import { DicRandomEffectPool } from './dictionary/DicRandomEffectPool';
import { SchoolModel } from '../db/School';
import { ABI_TYPE_MAIN, ABI_JOB_STAGE, ABI_STAGE_TO_TYPE } from '../consts/constModules/abilityConst'
@@ -19,7 +18,6 @@ import { PvpDefenseModel } from '../db/PvpDefense';
import { findIndex } from 'underscore';
import { GuildModel } from '../db/Guild';
import { DicJob } from './dictionary/DicJob';
import { DicSuit } from './dictionary/DicSuit';
import { saveCeChangeLog } from './logUtil';
// 修改并下发战力
@@ -166,6 +164,9 @@ export function calPlayerCe(hero: HeroType, update: HeroUpdate, type: number, ar
case HERO_SYSTEM_TYPE.CONNECT:
heroAttrs = calHeroConectIncAttr(hero, update, args[0]);
break;
case HERO_SYSTEM_TYPE.COMPOSE_EQUIP:
heroAttrs = calComposeEquipIncAttr(hero, update, args[0]);
break;
case HERO_SYSTEM_TYPE.EQUIP:
heroAttrs = calEquipPutOnOffIncAttr(hero, args, addSeidList, removeSeidList);
break;
@@ -603,6 +604,18 @@ export function calHeroFavourUpIncAttr(originHero: HeroType, update: HeroUpdate)
return heroAttrs;
}
export function calComposeEquipIncAttr(hero: HeroType, update: HeroUpdate, eplaceId: number) {
let { attr: heroAttrs } = hero;
let newEquip = update.ePlace.find(cur => cur.id == eplaceId);
if(newEquip) {
let dicEquip = gameData.equipById.get(newEquip.equipId);
for(let attr of dicEquip.attribute) {
updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp: attr.num * HERO_CE_RATIO } });
}
}
return heroAttrs;
}
/**
* 穿脱, removeSeidList原来身上穿着的所有装备的seid,包括套装的
* @param {HeroType} hero 武将
@@ -687,7 +700,7 @@ export function calEquipSeids(_hero: HeroType) {
* @param {HeroType} hero 装备更新过的武将
*/
export function calHeroEquipIncAttr(hero: HeroType) {
let { ePlace:_, attr: heroAttrs } = hero;
let { attr: heroAttrs } = hero;
// let setMap = new Map<number, number>();
// for (let { equip, lv, refineLv } of ePlace) {