装备:镶嵌天晶石

This commit is contained in:
luying
2022-02-16 16:51:23 +08:00
parent 862c3f4d65
commit 29e66fc844
17 changed files with 277 additions and 144 deletions
+10
View File
@@ -102,11 +102,13 @@ import { pick } from "underscore";
import _ = require("underscore");
import { dicEquipById, dicEquipIdByJobClassAndEplace, loadEquip } from "./dictionary/DicEquip";
import { dicJewel, loadJewel } from "./dictionary/DicJewel";
import { dicStone, loadStone } from './dictionary/DicStone';
import { dicEquipStrength, loadEquipStrength } from "./dictionary/DicEquipStrength";
import { dicEquipQuality, dicEquipQualityIdByEquipIdAndPoint, loadEquipQuality } from "./dictionary/DicEquipQuality";
import { dicEquipStar, dicEquipStarIdByEquipId, loadEquipStar } from './dictionary/DicEquipStar';
import { dicEquipQualityExtra, loadEquipQualityExtra } from './dictionary/DicEquipQualityExtra';
import { dicEquipSuit, dicEquipSuitByJobClass, loadEquipSuit } from "./dictionary/DicEquipSuit";
import { dicJewelCondition, loadJewelCondition } from './dictionary/DicJewelCondition';
export const gameData = {
blurprtCompose: dicBlueprtCompose,
@@ -258,6 +260,7 @@ export const gameData = {
equipById: dicEquipById,
equipIdByJobAndEPlace: dicEquipIdByJobClassAndEplace,
jewel: dicJewel,
stone: dicStone,
equipStrengthenCost: dicEquipStrength,
equipQuality: dicEquipQuality,
equipQualityIdByEquipIdAndPoint: dicEquipQualityIdByEquipIdAndPoint,
@@ -266,6 +269,7 @@ export const gameData = {
equipQualityExtra: dicEquipQualityExtra,
equipSuit: dicEquipSuit,
equipSuitByJobClass: dicEquipSuitByJobClass,
jewelCondition: dicJewelCondition,
};
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
@@ -918,6 +922,10 @@ export function getEquipSuitByHero(hid: number) {
return gameData.equipSuit.get(equipSuitId);
}
export function getJewelConditionByLvAndSeId(lv: number, randSeId: number) {
return gameData.jewelCondition.get(`${lv}_${randSeId}`);
}
// 初始加载
function initDatas() {
parseDicParam();
@@ -1090,6 +1098,8 @@ function loadDatas() {
loadEquipSuit();
loadEquipQualityExtra();
loadJewel();
loadStone();
loadJewelCondition();
}
// 重载dicParam
+1 -1
View File
@@ -1,5 +1,5 @@
// 天晶石表
import { decodeArrayListStr, readFileAndParse, parseGoodStr, parseNumberList } from '../util'
import { readFileAndParse, parseGoodStr, parseNumberList } from '../util'
import { FILENAME } from '../../consts';
import { RewardInter } from '../interface';
@@ -0,0 +1,29 @@
// 天晶石表
import { readFileAndParse, parseGoodStr, parseNumberList } from '../util'
import { FILENAME } from '../../consts';
export interface DicJewelCondition {
// id
readonly id: number;
// 天晶石品质
readonly jewelLv: number;
// 属性词条id
readonly randSeId: number;
// 需要的地玉石的数量
readonly stoneCnt: number;
// 需要的地玉石的品质之和
readonly stoneLv: number;
}
export const dicJewelCondition = new Map<string, DicJewelCondition>();
export function loadJewelCondition() {
dicJewelCondition.clear();
let arr = readFileAndParse(FILENAME.DIC_JEWEL_CONDITION);
arr.forEach(o => {
dicJewelCondition.set(`${o.jewelLv}_${o.randSeId}`, o);
});
arr = undefined;
}
+51
View File
@@ -0,0 +1,51 @@
// 地玉石表
import { readFileAndParse, parseGoodStr, decodeArrayListStr } from '../util'
import { FILENAME } from '../../consts';
import { RewardInter } from '../interface';
export interface DicStone {
// 物品id
readonly good_id: number;
// 地玉石名
readonly name: string;
// 装备栏id
readonly eplaceId: number;
// itid
readonly itid: number;
// 地玉石阶
readonly lv: number;
// 地玉石品质
readonly quality: number;
// 合成消耗
readonly composeMaterial: RewardInter[];
// 属性提升
readonly attribute: {id: number, num: number}[];
}
export const dicStone = new Map<number, DicStone>();
export function loadStone() {
dicStone.clear();
let arr = readFileAndParse(FILENAME.DIC_STONE);
arr.forEach(o => {
o.composeMaterial = parseGoodStr(o.composeMaterial);
o.attribute = parseAttr(o.attribute);
dicStone.set(o.good_id, o);
});
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
}
+4 -5
View File
@@ -79,7 +79,7 @@ export async function addBag(roleId: string, roleName: string, data: { id: numbe
}
export async function addJewels(roleId: string, roleName: string, jewels: { id: number, hid?: number }[], reason: number) {
export async function addJewels(roleId: string, roleName: string, jewels: { id: number, }[], reason: number) {
let jewelInfo: jewelUpdate[] = [];
for(let jewel of jewels) {
let info = await getAddJewelInfo(roleId, roleName, jewel);
@@ -103,9 +103,8 @@ export async function addJewels(roleId: string, roleName: string, jewels: { id:
}), pushMessages }
}
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;
export async function getAddJewelInfo(roleId: string, roleName: string, jewel: { id: number, }) {
let { id, } = jewel;
let { name, randomEffect, effectCount } = gameData.jewel.get(id);
// 随机属性
@@ -118,7 +117,7 @@ export async function getAddJewelInfo(roleId: string, roleName: string, jewel: {
return new RandSe(index + 1, random.id, rand);
});
return { roleId, roleName, id, name, hid, eplaceId, randSe };
return { roleId, roleName, id, name, randSe };
}
/**
+50 -8
View File
@@ -5,20 +5,21 @@
import { HERO_SYSTEM_TYPE, ABI_TYPE, HERO_CE_RATIO, LINEUP_NUM } from '../consts';
import { cal, deepCopy, getAllAttrStage, reduceCe } from './util';
import { HeroModel, HeroType, HeroUpdate, CeAttrData, EPlace } from '../db/Hero';
import { HeroModel, HeroType, HeroUpdate, CeAttrData, EPlace, Stone } 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, getEquipQualityIdByEquipIdAndPoint, getEquipStarIdByEquipId, getEquipSuitByHero, getEquipStarMainAttrByStage } from './data';
import { gameData, getJobByGradeAndClass, getHeroWakeByQuality, getHeroStarByQuality, getFriendShipById, getSchoolRateByStar, getScollByStar, getTeraph, getEquipQualityIdByEquipIdAndPoint, getEquipStarIdByEquipId, getEquipSuitByHero, getEquipStarMainAttrByStage, getJewelConditionByLvAndSeId } from './data';
import { DicSe } from './dictionary/DicSe';
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'
import { PvpDefenseModel } from '../db/PvpDefense';
import { findIndex } from 'underscore';
import { findIndex, uniq } from 'underscore';
import { GuildModel } from '../db/Guild';
import { DicJob } from './dictionary/DicJob';
import { saveCeChangeLog } from './logUtil';
import { JewelModel, JewelType } from '../db/Jewel';
// 修改并下发战力
export async function calPlayerCeAndSave(type: number, roleId: string, originHero: HeroType, update: HeroUpdate, args?: Array<number>) {
@@ -26,7 +27,7 @@ export async function calPlayerCeAndSave(type: number, roleId: string, originHer
let { attr: roleAttrs = [], serverId } = role;
let heroAttrs = calPlayerCe(originHero, update, type, args); // 根据操作计算attr的增加
let heroAttrs = await calPlayerCe(originHero, update, type, args); // 根据操作计算attr的增加
let newAttr = new AttributeCal();
newAttr.setLv(update.lv||originHero.lv);
@@ -136,7 +137,7 @@ async function reCalRoleAttr(type: number, heros: Array<HeroType>, role: RoleTyp
}
// 计算单个武将战力
export function calPlayerCe(hero: HeroType, update: HeroUpdate, type: number, args: Array<number> = []) {
export async function calPlayerCe(hero: HeroType, update: HeroUpdate, type: number, args: Array<number> = []) {
let heroAttrs: CeAttrData[] = []; // {"hp": {"base": number, "fixUp": number, "ratioUp": number}}
let addSeidList = new Array<number>();
@@ -176,6 +177,9 @@ export function calPlayerCe(hero: HeroType, update: HeroUpdate, type: number, ar
case HERO_SYSTEM_TYPE.EQUIP_STAR:
heroAttrs = calEquipStarIncAttr(hero, update, args, addSeidList, removeSeidList);
break;
case HERO_SYSTEM_TYPE.EQUIP_JEWEL:
heroAttrs = await calEquipPutOnOrOffJewelIncAttr(hero, update, args, addSeidList, removeSeidList);
break;
case HERO_SYSTEM_TYPE.EQUIP: //
heroAttrs = calEquipPutOnOffIncAttr(hero, args, addSeidList, removeSeidList);
break;
@@ -707,10 +711,48 @@ function calEquipSuitIncAttr(hid: number, oldEplace: EPlace[], newEplace: EPlace
for(let { star, seid } of dicEquipSuit.effect) {
if(oldStar >= star) removeSeidList.push(seid);
if(newStar >= star) addSeidList.push(seid);
if(newStar >= star) addSeidList.push(seid, 0);
}
}
export async function calEquipPutOnOrOffJewelIncAttr(hero: HeroType, update: HeroUpdate, eplaceIds: number[], addSeidList: number[], removeSeidList: number[]) {
let { attr: heroAttrs, ePlace: oldEplace } = hero;
let { ePlace: newEplace } = update;
for(let eplaceId of eplaceIds) {
let oldEquip = oldEplace.find(cur => cur.id == eplaceId);
await setRandSeToSeidList(oldEquip, removeSeidList);
let newEquip = newEplace.find(cur => cur.id == eplaceId);
await setRandSeToSeidList(newEquip, addSeidList);
}
return heroAttrs;
}
async function setRandSeToSeidList(equip: EPlace, list: number[]) {
if(equip && equip.jewel) {
let jewel = await JewelModel.findbySeqId(equip.jewel);
for(let { id, seid, rand } of jewel.randSe) {
if(isRandSeUnLock(jewel.id, id, equip.stones)) {
list.push(seid, rand);
}
}
}
}
function isRandSeUnLock(jewelId: number, randSeId: number, stones: Stone[]) {
let dicJewel = gameData.jewel.get(jewelId);
let dicJewelCondition = getJewelConditionByLvAndSeId(dicJewel.lv, randSeId);
let stoneCnt = 0, stoneLv = 0;
for(let { stone } of stones) {
let dicStone = gameData.stone.get(stone);
if(dicStone) {
stoneCnt++;
stoneLv += dicStone.lv;
}
}
return stoneCnt >= dicJewelCondition.stoneCnt && stoneLv >= dicJewelCondition.stoneLv;
}
/**
* 穿脱, removeSeidList原来身上穿着的所有装备的seid,包括套装的
* @param {HeroType} hero 武将
@@ -725,11 +767,11 @@ export function calEquipPutOnOffIncAttr(hero: HeroType, seids: Array<number>, ad
// 计算被动技能
let resultSeid = calEquipSeids(hero);
for(let seid of resultSeid) {
addSeidList.push(seid);
addSeidList.push(seid, 0);
}
for (let seid of seids) {
removeSeidList.push(seid)
removeSeidList.push(seid, 0);
}
return heroAttrs