装备:镶嵌天晶石

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

View File

@@ -26,6 +26,7 @@ import Counter from '../../../db/Counter';
import { getExpByLv } from '../../../pubUtils/data';
import { reportTAUserSet } from '../../../services/sdkService';
import { saveLoginAndOutLog } from '../../../pubUtils/logUtil';
import { JewelModel } from '../../../db/Jewel';
export default function (app: Application) {
new HandlerService(app, {});
@@ -79,7 +80,7 @@ export class EntryHandler {
addRoleToWorldChannel(role.roleId, self.app.get('serverId'), role.serverId);
await self.app.rpc.chat.chatRemote.addWorldChannel.route(session)(role.roleId, serverId, self.app.get('serverId'));
let heros = await HeroModel.findByRole(role.roleId, [], HERO_SELECT.ENTRY, true);
let equips = await EquipModel.findbyRole(role.roleId);
let jewels = await JewelModel.findbyRole(role.roleId);
let items = await ItemModel.findbyRole(role.roleId);
let skins = await SkinModel.findbyRole(role.roleId);
reportOneOnline(role.roleId, user.userCode, self.app.get('serverId'), true, user);
@@ -98,7 +99,7 @@ export class EntryHandler {
pushData(role.hasInit, role, session);
role['heros'] = heros;
role['equips'] = equips;
role['jewels'] = jewels;
role['consumeGoods'] = items;
role['skins'] = skins;
let ip = session.remoteAddress.ip.replace('::ffff:', '');

View File

@@ -11,13 +11,14 @@ import { calPlayerCeAndSave } from "../../../services/playerCeService";
import { getGoodById, gameData, getEquipByJobClassAndEPlace, getNextEquipQuality, getEquipQualityIdByEquipIdAndPoint, getEquipStarIdByEquipId, getNextEquipStar } from "../../../pubUtils/data";
import { BAG, EQUIP } from "../../../pubUtils/dicParam";
import { ITID, QUALITY_TYPE, equipTypeToSortAttr, IT_TYPE, QUENCH_TYPE, REFINE_TYPE } from "../../../consts";
import { checkMaterialEnough, checkEquipCanPut, quenchOnce, checkQuenchMaxByQualityAndGrade, getRandSeResult, refineOnce, checkRefineReachNextLv, calEquipCe, updateEplace, updateEplaces } from "../../../services/equipService";
import { checkMaterialEnough, checkEquipCanPut, quenchOnce, checkQuenchMaxByQualityAndGrade, getRandSeResult, refineOnce, checkRefineReachNextLv, calEquipCe, updateEplace, updateEplaces, checkJewelCanPutOnEquip } from "../../../services/equipService";
import { findIndex, isNumber, pick } from 'underscore';
import { pushEquipRefineSucMsg, pushNormalEquipMsg, pushNormalItemMsg } from "../../../services/chatService";
import { checkTaskWithHero, checkTaskWithEquip, checkTask, checkTaskWithArgs, checkActivityTask } from "../../../services/taskService";
import { QuenchLogParam } from "../../../domain/roleField/equip";
import { calEquipSeids } from "../../../pubUtils/playerCe";
import { JewelModel, JewelType } from "../../../db/Jewel";
export default function (app: Application) {
new HandlerService(app, {});
@@ -279,66 +280,53 @@ export class EquipHandler {
}
// // 装备栏精炼
// public async refine(msg: { hid: number, ePlaceId: number, type: REFINE_TYPE }, session: BackendSession) {
// let roleId: string = session.get('roleId');
// let roleName: string = session.get('roleName');
// let serverId = session.get('serverId');
// let sid: string = session.get('sid');
//镶嵌天晶石
public async putOnJewel(msg: { hid: number, eplaceId: number, jewel: number }, session: BackendSession) {
let { hid, eplaceId, jewel: seqId } = msg;
let roleId: string = session.get('roleId');
let sid: string = session.get('sid');
let hero = await HeroModel.findByHidAndRole(hid, roleId);
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
// let { hid, ePlaceId, type } = msg;
let curEquip = hero.ePlace?.find(cur => cur.id == eplaceId);
if(!curEquip) return resResult(STATUS.EQUIP_NOT_FIND);
let jewel = await JewelModel.findbySeqId(seqId);
if(!jewel) return resResult(STATUS.JEWEL_IS_NOT_FIND);
if(curEquip.jewel == seqId) return resResult(STATUS.JEWEL_HAS_SUIT);
if(!checkJewelCanPutOnEquip(curEquip, jewel)) {
return resResult(STATUS.EQUIP_NOT_MATCH_JEWEL)
}
// let hero = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);
// if (!hero) return resResult(STATUS.HERO_NOT_FIND);
// let { ePlace } = hero; // 装备栏
let originHeroResult: { hid: number, ePlace: Partial<EPlace>[] };
let originJewel = curEquip.jewel? await JewelModel.findbySeqId(curEquip.jewel): null; // 原本自己的天晶石
let canSentMineToOrigin = false; // 自己的能不能塞到对方身上
if(jewel.hid != 0) { // 如果天晶石原本镶嵌在其他武将身上,把自己的给他
let originHero = await HeroModel.findByHidAndRole(jewel.hid, roleId);
let originEquip = originHero?.ePlace?.find(cur => cur.jewel == seqId);
if(originEquip) {
let canChange = originJewel && checkJewelCanPutOnEquip(originEquip, originJewel);
if(canChange) canSentMineToOrigin = true;
let { newEplace, updatedEplace } = updateEplace(originHero.ePlace, eplaceId, { jewel: canChange? originJewel.seqId: 0 });
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_JEWEL, sid, roleId, originHero, { ePlace: newEplace }, [eplaceId]);
originHeroResult = { hid: originHero.hid, ePlace: updatedEplace };
}
}
if(originJewel) { // 更新自己的天晶石
await JewelModel.putOnOrOff(originJewel.seqId, canSentMineToOrigin? jewel.hid: 0, canSentMineToOrigin? eplaceId: 0);
}
// let curEplace = ePlace.find(cur => cur.id == ePlaceId);
// if (!curEplace) {
// return resResult(STATUS.ROLE_EQUIP_PLACE_NOT_ENOUGH);
// }
// let { lv, refineLv: oldRefineLv, equip } = curEplace; // 强化等级,精炼等级,精炼次数
// 目标镶嵌上
let curJewel = await JewelModel.putOnOrOff(seqId, hid, eplaceId);
let { newEplace, updatedEplace } = updateEplace(hero.ePlace, eplaceId, { jewel: seqId });
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_JEWEL, sid, roleId, hero, { ePlace: newEplace }, [eplaceId]);
let curHero = {
hid,
eplace: updatedEplace
}
// let check = new CheckMeterial(roleId);
// let refineLv = oldRefineLv, times = 0;
// while(
// (type == REFINE_TYPE.ONCE && times == 0) ||
// (type == REFINE_TYPE.ONE_LEVEL && !checkRefineReachNextLv(oldRefineLv, refineLv) )
// ) {
// let result = await refineOnce(lv, refineLv);
// if(!result) break;
// let isEnough = await check.decrease(result.consumes);
// if(!isEnough) break; // 消耗不足
// refineLv = result.refineLv;
// times ++;
// }
// if(times == 0) {
// return resResult(STATUS.EQUIP_REFINE_ERR);
// }
// let consumes = check.getConsume();
// let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.EQUIP_REFINE);
// if (!result)
// return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
// curEplace.refineLv = refineLv;
// await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_BASE, sid, roleId, hero, { ePlace });
// const curHero = {
// hid,
// ePlace: [curEplace]
// }
// let curEquip = <EquipType>equip;
// pushEquipRefineSucMsg(roleId, roleName, serverId, curEplace, curEquip ? curEquip.quality : 0);
// await checkTask(roleId, sid, TASK_TYPE.EQUIP_REFINE, times, true, {});
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_REFINE, times);
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_REFINE_LV, times, { lv: curEplace.refineLv });
// return resResult(STATUS.SUCCESS, { curHero });
// }
return resResult(STATUS.SUCCESS, { curHero, originHero: originHeroResult, curJewel });
}
// // 装备洗炼锁定
// public async lockRandSe(msg: { eid: number, id: number, lock: boolean }, session: BackendSession) {

View File

@@ -8,6 +8,7 @@ import { dicGoods, DicGoods } from '../pubUtils/dictionary/DicGoods';
import { QuenchLogParam } from '../domain/roleField/equip';
import { QUENCH } from '../pubUtils/dicParam';
import { DicQuenchQuality } from '../pubUtils/dictionary/DicQuenchQuality';
import { JewelType } from '../db/Jewel';
/**
* 校验前端传入的消耗数量是否准确并返回消耗的道具并加上特殊材料needConsumes
@@ -225,4 +226,20 @@ export function updateEplaces(eplace: EPlace[], update: Map<number, Partial<EPla
}
}
return {newEplace, updatedEplace};
}
/**
* 检查天晶石能否装备上这个装备
* @param equip
* @param jewel
*/
export function checkJewelCanPutOnEquip(equip: EPlace, jewel: JewelType) {
// 位置是否满足
let dicJewel = gameData.jewel.get(jewel.id);
console.log('####', dicJewel, dicJewel.eplaceId, equip.id)
if(!dicJewel || dicJewel.eplaceId != equip.id) return false;
// 品质是否满足
let dicEquipQualityExtra = gameData.equipQualityExtra.get(equip.quality);
if(!dicEquipQualityExtra || dicEquipQualityExtra.jewelCnt == 0) return false;
return true
}

View File

@@ -25,6 +25,7 @@ export enum HERO_SYSTEM_TYPE {
EQUIP_STRENGTH = 22, // 装备强化
EQUIP_QUALITY = 23, // 装备升品
EQUIP_STAR = 24, // 装备升星
EQUIP_JEWEL = 25, // 装备装上or卸下天晶石
};
// 武将上限

View File

@@ -143,9 +143,9 @@ const itid_array = [
{ id: 56, name: '骰子', table: 'item', type: CONSUME_TYPE.DICE },
{ id: 58, name: '主公经验', table: 'role' },
{ id: 59, name: '武器天晶石', table: 'jewel' },
{ id: 60, name: '头饰天晶石', table: 'jewel' },
{ id: 61, name: '衣服天晶石', table: 'jewel' },
{ id: 62, name: '鞋子天晶石', table: 'jewel' },
{ id: 60, name: '衣服天晶石', table: 'jewel' },
{ id: 61, name: '头饰天晶石', table: 'jewel' },
{ id: 62, name: '行具天晶石', table: 'jewel' },
];
export const ITID = new Map<number, { id: number, name: string, table: string, type?: number, isCurrency?: boolean, equipJewel?: number }>();

View File

@@ -49,4 +49,4 @@ export enum FRIEND_SHIP_SELECT {
GET_FRIEND_VALUE = 'friendValue friendLv'
}
export const ENTERY_ROLE_PICK = ['roleId', 'roleName', 'serverId', 'ce', 'topLineupCe', 'coin', 'lv', 'exp', 'vLv', 'gold', 'heros', 'equips', 'consumeGoods', 'title', 'teraphs', 'showLineup', 'heads', 'head', 'frames', 'frame', 'spines', 'spine', 'hasGuild', 'guildCode', 'todayZeroPoint', 'apJson', 'skins', 'totalPay', 'guide', 'hasInit', 'renameCnt', 'totalCost', 'guildName'];
export const ENTERY_ROLE_PICK = ['roleId', 'roleName', 'serverId', 'ce', 'topLineupCe', 'coin', 'lv', 'exp', 'vLv', 'gold', 'heros', 'jewels', 'consumeGoods', 'title', 'teraphs', 'showLineup', 'heads', 'head', 'frames', 'frame', 'spines', 'spine', 'hasGuild', 'guildCode', 'todayZeroPoint', 'apJson', 'skins', 'totalPay', 'guide', 'hasInit', 'renameCnt', 'totalCost', 'guildName'];

View File

@@ -492,7 +492,9 @@ export const FILENAME = {
DIC_EQUIP_QUALITY: 'dic_zyz_equipQuality',
DIC_EQUIP_STAR: 'dic_zyz_equipStar',
DIC_EQUIP_QUALITY_EXTRA: 'dic_zyz_equipQuality_extra',
DIC_JEWEL: 'dic_jewel',
DIC_JEWEL: 'dic_zyz_jewel',
DIC_STONE: 'dic_zyz_stone',
DIC_JEWEL_CONDITION: 'dic_zyz_jewel_condition',
}
export const WAR_RELATE_TABLES = [

View File

@@ -300,11 +300,11 @@ export const STATUS = {
EQUIP_HOLE_NOT_FIND: { code: 30504, simStr: '装备孔不存在' },
EQUIP_HOLE_IS_DUG: { code: 30505, simStr: '装备已经打过孔' },
EQUIP_HOLE_IS_NOT_DUG: { code: 30506, simStr: '装备未打过孔' },
JEWEL_IS_NOT_FIND: { code: 30507, simStr: '石不存在' },
JEWEL_IS_NOT_FIND: { code: 30507, simStr: '天晶石不存在' },
EQUIP_NOT_FILL_HOLE: { code: 30508, simStr: '未穿戴宝石' },
EQUIP_NOT_EQUIPED_HERO: { code: 30509, simStr: '装备不能被该武将穿戴' },
EQUIP_LEVEL_LIMIT: { code: 30510, simStr: '装备穿戴等级限制' },
EQUIP_NOT_MATCH_JEWEL: { code: 30511, simStr: '装备不能镶嵌该石' },
EQUIP_NOT_MATCH_JEWEL: { code: 30511, simStr: '装备不能镶嵌该天晶石' },
EQUIP_QUENCH_ERR: { code: 30512, simStr: '该装备不能再淬火或材料不足' },
EQUIP_REFINE_ERR: { code: 30513, simStr: '该装备等级不足或材料不足' },
EQUIP_RESTRENGTHEN_NOT_PREVIEW: { code: 30514, simStr: '该装备未预览洗练值' },
@@ -316,6 +316,7 @@ export const STATUS = {
EQUIP_QUALITY_NOT_ENOUGH: { code: 30520, simStr: '该装备品质不足' },
EQUIP_QUALITYSTAGE_IS_MAX: { code: 30521, simStr: '该装备已到该品质下最高,请升品' },
EQUIP_STARSTAGE_IS_MAX: { code: 30522, simStr: '该装备已到该星级下最高,请升星' },
JEWEL_HAS_SUIT: { code: 30523, simStr: '该装备已镶嵌该天晶石了' },
//全局养成30600-30699
ROLE_REACH_MAX_TITLE_LEVEL: { code: 30600, simStr: '玩家已达到最高的爵位' },

View File

@@ -95,6 +95,11 @@ export default class Jewel extends BaseModel {
return result;
}
public static async putOnOrOff(seqId: number, hid: number, ePlaceId: number) {
let rec: JewelType = await JewelModel.findOneAndUpdate({ seqId }, { $set: { hid, ePlaceId } }, { new: true }).lean();
return rec;
}
public static async deleteBySeqIds(roleId: string, seqIds: number[]) {
let jewels = await JewelModel.findbySeqIds(seqIds);
await JewelModel.deleteMany({ roleId, seqId: { $in: seqIds } });

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

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';

View File

@@ -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;
}

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
}

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 };
}
/**

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

View File

@@ -1,13 +0,0 @@
[{
"id":1,
"good_id": 72032,
"name": "天晶石1",
"eplaceId": 1,
"itId": 59,
"lv": 1,
"quality": 1,
"effectCount": 3,
"randomEffect": "1&2&3&4&5",
"mapGoodId": 1,
"quenchConsume": "31001&10000"
}]

View File

@@ -1,184 +1,184 @@
[
{
"id": 1,
"quality": 1,
"jewelLv": 1,
"randSeId": 1,
"stoneCnt": 0,
"stoneQuality": 0
"stoneLv": 0
},
{
"id": 2,
"quality": 1,
"jewelLv": 1,
"randSeId": 2,
"stoneCnt": 1,
"stoneQuality": 1
"stoneLv": 1
},
{
"id": 3,
"quality": 2,
"jewelLv": 2,
"randSeId": 1,
"stoneCnt": 0,
"stoneQuality": 0
"stoneLv": 0
},
{
"id": 4,
"quality": 2,
"jewelLv": 2,
"randSeId": 2,
"stoneCnt": 1,
"stoneQuality": 1
"stoneLv": 2
},
{
"id": 5,
"quality": 3,
"jewelLv": 3,
"randSeId": 1,
"stoneCnt": 0,
"stoneQuality": 0
"stoneLv": 0
},
{
"id": 6,
"quality": 3,
"jewelLv": 3,
"randSeId": 2,
"stoneCnt": 1,
"stoneQuality": 1
"stoneLv": 3
},
{
"id": 7,
"quality": 4,
"jewelLv": 4,
"randSeId": 1,
"stoneCnt": 0,
"stoneQuality": 0
"stoneLv": 0
},
{
"id": 8,
"quality": 4,
"jewelLv": 4,
"randSeId": 2,
"stoneCnt": 1,
"stoneQuality": 1
"stoneLv": 4
},
{
"id": 9,
"quality": 5,
"jewelLv": 5,
"randSeId": 1,
"stoneCnt": 0,
"stoneQuality": 0
"stoneLv": 0
},
{
"id": 10,
"quality": 5,
"jewelLv": 5,
"randSeId": 2,
"stoneCnt": 1,
"stoneQuality": 1
"stoneLv": 5
},
{
"id": 11,
"quality": 5,
"jewelLv": 5,
"randSeId": 3,
"stoneCnt": 2,
"stoneQuality": 2
"stoneLv": 10
},
{
"id": 12,
"quality": 6,
"jewelLv": 6,
"randSeId": 1,
"stoneCnt": 0,
"stoneQuality": 0
"stoneLv": 0
},
{
"id": 13,
"quality": 6,
"jewelLv": 6,
"randSeId": 2,
"stoneCnt": 1,
"stoneQuality": 1
"stoneLv": 6
},
{
"id": 14,
"quality": 6,
"jewelLv": 6,
"randSeId": 3,
"stoneCnt": 2,
"stoneQuality": 2
"stoneLv": 12
},
{
"id": 15,
"quality": 7,
"jewelLv": 7,
"randSeId": 1,
"stoneCnt": 0,
"stoneQuality": 0
"stoneLv": 0
},
{
"id": 16,
"quality": 7,
"jewelLv": 7,
"randSeId": 2,
"stoneCnt": 1,
"stoneQuality": 1
"stoneLv": 7
},
{
"id": 17,
"quality": 7,
"jewelLv": 7,
"randSeId": 3,
"stoneCnt": 2,
"stoneQuality": 2
"stoneLv": 14
},
{
"id": 18,
"quality": 7,
"jewelLv": 7,
"randSeId": 4,
"stoneCnt": 3,
"stoneQuality": 3
"stoneLv": 21
},
{
"id": 19,
"quality": 8,
"jewelLv": 8,
"randSeId": 1,
"stoneCnt": 0,
"stoneQuality": 0
"stoneLv": 0
},
{
"id": 20,
"quality": 8,
"jewelLv": 8,
"randSeId": 2,
"stoneCnt": 1,
"stoneQuality": 1
"stoneLv": 8
},
{
"id": 21,
"quality": 8,
"jewelLv": 8,
"randSeId": 3,
"stoneCnt": 2,
"stoneQuality": 2
"stoneLv": 16
},
{
"id": 22,
"quality": 8,
"jewelLv": 8,
"randSeId": 4,
"stoneCnt": 3,
"stoneQuality": 3
"stoneLv": 24
},
{
"id": 23,
"quality": 9,
"jewelLv": 9,
"randSeId": 1,
"stoneCnt": 0,
"stoneQuality": 0
"stoneLv": 0
},
{
"id": 24,
"quality": 9,
"jewelLv": 9,
"randSeId": 2,
"stoneCnt": 1,
"stoneQuality": 1
"stoneLv": 9
},
{
"id": 25,
"quality": 9,
"jewelLv": 9,
"randSeId": 3,
"stoneCnt": 2,
"stoneQuality": 2
"stoneLv": 18
},
{
"id": 26,
"quality": 9,
"jewelLv": 9,
"randSeId": 4,
"stoneCnt": 3,
"stoneQuality": 3
"stoneLv": 27
}
]