装备:清理旧代码
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
import { dicHero, dicMyHeroes, loadHero } from "./dictionary/DicHero";
|
||||
import { dicHero, loadHero } from "./dictionary/DicHero";
|
||||
import { dicGoods, figureCondition, loadGoods } from "./dictionary/DicGoods";
|
||||
import { dicBlueprtCompose, loadBlueprtCompose } from "./dictionary/DicBlueprtCompose";
|
||||
import { dicBlueprtPossibility, loadBlueprtPossibility } from "./dictionary/DicBlueprtPossibility";
|
||||
import { dicDaily, loadDaily } from "./dictionary/DicDaily";
|
||||
import { dicEvent, dicEventList, loadEvent } from "./dictionary/DicEvent";
|
||||
import { dicExpedition, DicExpedition, loadExpedition } from "./dictionary/DicExpedition";
|
||||
import { dicExpeditionPoint, loadExpeditionPoint } from "./dictionary/DicExpeditionPoint";
|
||||
import { dicFuncSwitch, loadFuncSwitch } from "./dictionary/DicFuncSwitch";
|
||||
import { dicHeroSkill, loadHeroSkill } from "./dictionary/DicHeroSkill";
|
||||
import { dicJob, jobClassAndgrades, jobClassMaxGrades, loadJob } from "./dictionary/DicJob";
|
||||
import { dicKingExp, maxPlayerLv, loadKingExp } from "./dictionary/DicKingExp";
|
||||
@@ -18,7 +15,7 @@ import { dicTowerTask, loadTowerTask } from "./dictionary/DicTowerTask";
|
||||
import { dicWar, dicWarPvp, dicDailyWarByType, loadWar } from "./dictionary/DicWar";
|
||||
import { dicWarJson, loadWarJson } from "./dictionary/DicWarJson";
|
||||
import { dicXunbao, loadXunbao } from "./dictionary/DicXunbao";
|
||||
import { AUCTION_TIME, CONSUME_TYPE, ITID } from "../consts";
|
||||
import { AUCTION_TIME } from "../consts";
|
||||
import { dicFashions, dicFashionsByHeroId, loadFashions } from "./dictionary/DicFashions";
|
||||
import { friendShips, friendShipHidAandIds, loadFriendShip } from "./dictionary/DicFriendShip";
|
||||
import { maxFriendShipLv, dicFriendShipLevelMap, loadFriendShipLevel } from "./dictionary/DicFriendShipLevel";
|
||||
@@ -26,10 +23,6 @@ import { dicHeroQualityUp, loadHeroQualityUp } from "./dictionary/DicHeroQuality
|
||||
import { dicHeroStar, loadHeroStar } from "./dictionary/DicHeroStar";
|
||||
import { dicHeroWake, loadHeroWake } from "./dictionary/DicHeroWake";
|
||||
import { dicRandomEffectPool, loadRandomEffectPool } from './dictionary/DicRandomEffectPool';
|
||||
import { dicStrengthenCost, loadStrengthenCost } from './dictionary/DicStrengthenCost';
|
||||
import { dicRefine, loadRefine } from './dictionary/DicRefine';
|
||||
import { dicHeroEquip, loadHeroEquip } from './dictionary/DicHeroEquip';
|
||||
import { dicSuit, dicSuitByTypeAndLv, loadSuit } from './dictionary/DicSuit';
|
||||
import { dicTitle, loadTitle } from './dictionary/DicTitle';
|
||||
import { dicTeraph, loadTeraph } from './dictionary/DicTeraph';
|
||||
import { dicSchool, loadSchool } from './dictionary/DicSchool';
|
||||
@@ -87,8 +80,6 @@ import { dicServerName, loadServerName } from "./dictionary/DicServerName";
|
||||
import { dicAp, loadAp, dicApMaxLevel } from './dictionary/DicAp';
|
||||
import { dicApBuy, dicApMaxBuyTimes, loadApBuy } from "./dictionary/DicApBuy";
|
||||
import { dicKingExpRatio, loadKingExpRatio } from './dictionary/DicKingExpRatio';
|
||||
import { dicQuenchByQuality, dicQuenchRangeByQuality, dicQuenchRangeByQualityAndGrade, loadQuenchQuality } from './dictionary/DicQuenchQuality';
|
||||
import { dicQuenchConsume, loadQuenchConsume } from './dictionary/DicQuenchConsume';
|
||||
import { dicHoliday, loadHoliday } from './dictionary/DicHoliday';
|
||||
import { dicExpeditionSubAttr, loadExpeditionSubAttr } from './dictionary/DicExpeditionSubAttr';
|
||||
import { dicAuctionPool, loadAuctionReward } from './dictionary/DicAuctionReward';
|
||||
@@ -111,14 +102,11 @@ import { dicEquipSuit, dicEquipSuitByJobClass, loadEquipSuit } from "./dictionar
|
||||
import { dicJewelCondition, loadJewelCondition } from './dictionary/DicJewelCondition';
|
||||
|
||||
export const gameData = {
|
||||
blurprtCompose: dicBlueprtCompose,
|
||||
blueprtPossibility: dicBlueprtPossibility,
|
||||
daily: dicDaily,
|
||||
event: dicEvent,
|
||||
eventList: dicEventList,
|
||||
expedition: dicExpedition,
|
||||
expeditionPoint: dicExpeditionPoint,
|
||||
funcsSwitch: dicFuncSwitch,
|
||||
goods: dicGoods,
|
||||
hero: dicHero,
|
||||
heroQualityUp: dicHeroQualityUp,
|
||||
@@ -148,11 +136,6 @@ export const gameData = {
|
||||
maxFriendShipLv: maxFriendShipLv,
|
||||
friendShipLevelMap: dicFriendShipLevelMap,
|
||||
randomEffectPool: dicRandomEffectPool,
|
||||
strengthenCost: dicStrengthenCost,
|
||||
refine: dicRefine,
|
||||
dicHeroEquip: dicHeroEquip,
|
||||
suit: dicSuit,
|
||||
suitByTypeAndLv: dicSuitByTypeAndLv,
|
||||
title: dicTitle,
|
||||
teraphs: dicTeraph,
|
||||
school: dicSchool,
|
||||
@@ -209,7 +192,6 @@ export const gameData = {
|
||||
shop: dicShop,
|
||||
shopItem: dicShopItem,
|
||||
shopList: dicShopList,
|
||||
dicMyHeroes: dicMyHeroes,
|
||||
rank: dicRank,
|
||||
generalRankReward: dicRankReward,
|
||||
taskType: dicTaskType,
|
||||
@@ -239,10 +221,6 @@ export const gameData = {
|
||||
apBuy: dicApBuy,
|
||||
apMaxBuyTimes: dicApMaxBuyTimes,
|
||||
kingExpRaio: dicKingExpRatio,
|
||||
quenchRangeByQuality: dicQuenchRangeByQuality,
|
||||
quenchRangeByQualityAndGrade: dicQuenchRangeByQualityAndGrade,
|
||||
quenchConsume: dicQuenchConsume,
|
||||
quenchByQuality: dicQuenchByQuality,
|
||||
equipAttributeRatio: new Map<number, number>(),
|
||||
ceRatio: new Array<{type: number, val: number}>(),
|
||||
holiday: dicHoliday,
|
||||
@@ -414,10 +392,6 @@ export function getGoodById(gid: number) {
|
||||
return gameData.goods.get(gid);
|
||||
}
|
||||
|
||||
export function getHeroEquipByClassId(classId: number) {
|
||||
return gameData.dicHeroEquip.get(classId);
|
||||
}
|
||||
|
||||
export function getHeroJob(jobId: number) {
|
||||
const job = gameData.job.get(jobId);
|
||||
return job;
|
||||
@@ -443,16 +417,6 @@ export function getScollByStar(quality: number, star: number, curQuality: number
|
||||
return heroScroll;
|
||||
}
|
||||
|
||||
export function getSuit(id: number) {
|
||||
const suitInfo = gameData.suit.get(id);
|
||||
return suitInfo;
|
||||
}
|
||||
|
||||
export function getFuncsSwitch(id: number) {
|
||||
const funcInfo = gameData.funcsSwitch.get(id);
|
||||
return funcInfo;
|
||||
}
|
||||
|
||||
export function getPLvByScore(score: number) {
|
||||
let lv = 0;
|
||||
for (let { teamLv, topLineupMin, topLineupMax } of gameData.pvpTeamLevel) {
|
||||
@@ -750,50 +714,10 @@ export function getDicApByLv(level: number) {
|
||||
}
|
||||
}
|
||||
|
||||
export function getDicSuitByTypeAndLv(suitType: number, starLevel: number) {
|
||||
return gameData.suitByTypeAndLv.get(`${suitType}_${starLevel}`);
|
||||
}
|
||||
|
||||
export function getQuenchGradeByValue(quality: number, value: number) {
|
||||
|
||||
let dicQuench = gameData.quenchByQuality.get(quality)||[];
|
||||
let grade = 0;
|
||||
for(let [_grade, { singleRatioMin, singleRatioMax }] of dicQuench) {
|
||||
if((value >= singleRatioMin && value < singleRatioMax) || (value == singleRatioMin && value == singleRatioMax) ) {
|
||||
grade = _grade;
|
||||
}
|
||||
}
|
||||
return grade;
|
||||
}
|
||||
|
||||
export function getWishPoolReward(id: number) {
|
||||
let dicGoods = gameData.goods.get(id);
|
||||
if(!dicGoods) return false;
|
||||
let dicItid = ITID.get(dicGoods.itid);
|
||||
let starLevel = 0;
|
||||
if(dicItid.type == CONSUME_TYPE.PIECE) {
|
||||
starLevel = dicGoods.equipLvl;
|
||||
}
|
||||
// console.log('*****', dicGoods.itid, starLevel, dicGoods.quality)
|
||||
return gameData.guildWishReward.get(`${dicGoods.itid}_${starLevel}_${dicGoods.quality}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根绝品质和品相获得上下限,当grade为0,获取该品质下全阶的上下限
|
||||
* @param quality 品质
|
||||
* @param grade 品相
|
||||
* @returns {{ min: number, max: number }}
|
||||
*/
|
||||
export function getQuenchByQualityAndGrade(quality: number, grade: number) {
|
||||
if(grade == 0) { // 这个品质的上下限
|
||||
return gameData.quenchRangeByQuality.get(quality);
|
||||
} else { // 该品质该品相的上下限
|
||||
return gameData.quenchRangeByQualityAndGrade.get(`${quality}_${grade}`);
|
||||
}
|
||||
}
|
||||
|
||||
export function getQuenchConsume(lvLimited: number, quality: number) {
|
||||
return gameData.quenchConsume.get(`${lvLimited}_${quality}`);
|
||||
return gameData.guildWishReward.get(`${dicGoods.itid}_${dicGoods.quality}`);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -988,13 +912,10 @@ function treatTaskGroup() {
|
||||
function loadDatas() {
|
||||
loadHero();
|
||||
loadGoods();
|
||||
loadBlueprtCompose();
|
||||
loadBlueprtPossibility();
|
||||
loadDaily();
|
||||
loadEvent();
|
||||
loadExpedition();
|
||||
loadExpeditionPoint();
|
||||
loadFuncSwitch();
|
||||
loadHeroSkill();
|
||||
loadJob();
|
||||
loadKingExp();
|
||||
@@ -1013,10 +934,6 @@ function loadDatas() {
|
||||
loadHeroStar();
|
||||
loadHeroWake();
|
||||
loadRandomEffectPool();
|
||||
loadStrengthenCost();
|
||||
loadRefine();
|
||||
loadHeroEquip();
|
||||
loadSuit();
|
||||
loadTitle();
|
||||
loadTeraph();
|
||||
loadSchool();
|
||||
@@ -1067,8 +984,6 @@ function loadDatas() {
|
||||
loadAp();
|
||||
loadApBuy();
|
||||
loadKingExpRatio();
|
||||
loadQuenchQuality();
|
||||
loadQuenchConsume();
|
||||
loadEquipAttributeRatio();
|
||||
loadHoliday();
|
||||
loadExpeditionSubAttr();
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
// 藏宝图合成表
|
||||
import { readFileAndParse, parseGoodStr } from '../util'
|
||||
import { FILENAME } from '../../consts'
|
||||
import { RewardInter } from '../interface';
|
||||
|
||||
export interface DicBlueprtCompose {
|
||||
|
||||
// 品质
|
||||
readonly quality: number;
|
||||
// 消耗的寻宝币数量
|
||||
readonly coinNum: RewardInter[];
|
||||
// 消耗的藏宝图的数量
|
||||
readonly blueprtNum: number;
|
||||
// 目标品质
|
||||
readonly targetQuality: number;
|
||||
|
||||
}
|
||||
|
||||
export const dicBlueprtCompose = new Map<number, DicBlueprtCompose>();
|
||||
export function loadBlueprtCompose() {
|
||||
dicBlueprtCompose.clear();
|
||||
let arr = readFileAndParse(FILENAME.DIC_BLUEPRT_COMPOSE);
|
||||
|
||||
arr.forEach(o => {
|
||||
o.coinNum = parseGoodStr(o.coinNum);
|
||||
dicBlueprtCompose.set(o.quality, o);
|
||||
});
|
||||
arr = undefined;
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
// 藏宝图掉落率
|
||||
import { decodeArrayListStr, readFileAndParse } from '../util'
|
||||
import { FILENAME } from '../../consts'
|
||||
|
||||
export interface DicBlueprtPossibility {
|
||||
|
||||
// 君主等级下限
|
||||
readonly min: number;
|
||||
// 君主等级上限
|
||||
readonly max: number;
|
||||
// 掉落概率
|
||||
readonly possibility: Array<{id: number, weight: number}>;
|
||||
|
||||
}
|
||||
|
||||
export const dicBlueprtPossibility = new Array<DicBlueprtPossibility>();
|
||||
export function loadBlueprtPossibility() {
|
||||
dicBlueprtPossibility.splice(0, dicBlueprtPossibility.length);
|
||||
let arr = readFileAndParse(FILENAME.DIC_BLUEPRT_POSSIBILITY);
|
||||
arr.forEach(o => {
|
||||
o.possibility = parsePossibility(o.possibility);
|
||||
dicBlueprtPossibility.push(o);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function parsePossibility(str: string) {
|
||||
let result = new Array<{id: number, weight: number}>();
|
||||
if(!str) return result;
|
||||
let decodeArr = decodeArrayListStr(str);
|
||||
for(let [id, weight] of decodeArr) {
|
||||
if(isNaN(parseInt(id)) || isNaN(parseInt(weight))) {
|
||||
throw new Error('data table format wrong');
|
||||
}
|
||||
result.push({id: parseInt(id), weight: parseInt(weight)});
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
// 开启功能表
|
||||
import { readFileAndParse } from '../util';
|
||||
import { FILENAME } from '../../consts';
|
||||
|
||||
export interface DicFuncSwitch {
|
||||
// 功能id
|
||||
readonly id: number;
|
||||
// 描述
|
||||
readonly desc: string;
|
||||
// 条件
|
||||
readonly conditionType: number;
|
||||
// 参数
|
||||
readonly param: number;
|
||||
// 客户端指令
|
||||
readonly script: string;
|
||||
|
||||
}
|
||||
|
||||
export const dicFuncSwitch = new Map<number, DicFuncSwitch>();
|
||||
export function loadFuncSwitch() {
|
||||
dicFuncSwitch.clear();
|
||||
let arr = readFileAndParse(FILENAME.DIC_FUNC_SWITCH);
|
||||
|
||||
arr.forEach(o => {
|
||||
dicFuncSwitch.set(o.id, o);
|
||||
});
|
||||
arr = undefined;
|
||||
}
|
||||
@@ -1,69 +1,31 @@
|
||||
// 物品表
|
||||
import { decodeArrayListStr, readFileAndParse, parseGoodStr, parseNumberList, decodeArrayStr } from '../util'
|
||||
import { FILENAME, IT_TYPE, ABI_TYPE } from '../../consts'
|
||||
import { decodeArrayListStr, readFileAndParse, parseGoodStr, } from '../util'
|
||||
import { FILENAME, } from '../../consts'
|
||||
import { RewardInter } from '../interface';
|
||||
const _ = require('lodash');
|
||||
import { findWhere } from 'underscore';
|
||||
|
||||
export interface SpecialMaterial {
|
||||
readonly ids: number[];
|
||||
readonly count: number;
|
||||
}
|
||||
|
||||
export interface DicGoods {
|
||||
// 物品id
|
||||
readonly good_id: number;
|
||||
// 物品名
|
||||
readonly name: string;
|
||||
// 等级限制
|
||||
readonly lvLimited: number;
|
||||
// 星级
|
||||
readonly equipLvl: number;
|
||||
// 职业限制
|
||||
readonly jobLimited: number[];
|
||||
// 武将限制
|
||||
readonly charLimited: number[];
|
||||
// 合成装备需要的碎片数
|
||||
readonly pieces: number;
|
||||
// 对应的碎片id
|
||||
readonly pieceId: number;
|
||||
// 合成材料
|
||||
readonly composeMaterial: Array<RewardInter>;
|
||||
// 特殊材料
|
||||
readonly specialMaterial: SpecialMaterial;
|
||||
// 分解所得
|
||||
readonly decomposeItem: Array<RewardInter>;
|
||||
// 物品品质
|
||||
readonly quality: number;
|
||||
// 洞数
|
||||
readonly hole: number;
|
||||
// 随机属性范围
|
||||
readonly randomEffect: Array<number>;
|
||||
|
||||
// 类型id
|
||||
readonly itid: number;
|
||||
// 物品类型
|
||||
readonly goodType: number;
|
||||
|
||||
// 分解所得
|
||||
readonly decomposeItem: Array<RewardInter>;
|
||||
// 将魂对应武将id
|
||||
readonly hid: number;
|
||||
// 属性
|
||||
readonly goodsAbility: Map<number, number>;
|
||||
// 强化属性
|
||||
readonly goodsAbilityUp: Map<number, number>;
|
||||
// 套装id
|
||||
readonly suitId: number;
|
||||
// 特殊属性
|
||||
readonly specialAttr: Map<number, number>;
|
||||
// 属性外加的值,经验,好感
|
||||
readonly value: number;
|
||||
|
||||
readonly count?: number;
|
||||
|
||||
readonly nextJewelId?: number;
|
||||
readonly specialCount?: number;
|
||||
readonly nextSpecialId?: number;
|
||||
// 对应的装备id
|
||||
readonly equipId?: number;
|
||||
// 解锁条件
|
||||
readonly condition: { id: number, type: number, params: number[] }[];
|
||||
// 时间限制
|
||||
@@ -78,35 +40,17 @@ type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
const DicGoodsKeys: KeysEnum<DicGoods> = {
|
||||
good_id: true,
|
||||
name: true,
|
||||
lvLimited: true,
|
||||
pieces: true,
|
||||
composeMaterial: true,
|
||||
specialMaterial: true,
|
||||
decomposeItem: true,
|
||||
quality: true,
|
||||
hole: true,
|
||||
randomEffect: true,
|
||||
itid: true,
|
||||
goodType: true,
|
||||
hid: true,
|
||||
goodsAbility: true,
|
||||
goodsAbilityUp: true,
|
||||
suitId: true,
|
||||
specialAttr: true,
|
||||
value: true,
|
||||
pieceId: true,
|
||||
count: true,
|
||||
nextJewelId: true,
|
||||
specialCount: true,
|
||||
nextSpecialId: true,
|
||||
equipId: true,
|
||||
condition: true,
|
||||
timeLimit: true,
|
||||
image_id: true,
|
||||
gift: true,
|
||||
jobLimited: true,
|
||||
charLimited: true,
|
||||
equipLvl: true
|
||||
}
|
||||
export const dicGoods = new Map<number, DicGoods>();
|
||||
export const figureCondition = new Map<number, { params: number[], id: number, gid: number }[]>(); // type => {params, id, gid}
|
||||
@@ -118,19 +62,8 @@ export function loadGoods() {
|
||||
let arr = readFileAndParse(FILENAME.DIC_GOODS);
|
||||
|
||||
arr.forEach(o => {
|
||||
o.goodsAbility = parseAbility(o);
|
||||
o.goodsAbilityUp = parseAbilityUp(o);
|
||||
o.composeMaterial = parseGoodStr(o.composeMaterial);
|
||||
o.decomposeItem = parseGoodStr(o.decomposeItem);
|
||||
o.specialAttr = parseSpecialAttr(o.specialAttr);
|
||||
o.specialMaterial = parseSpecialMaterial(o.specialMaterial);
|
||||
o.randomEffect = parseNumberList(o.randomEffect);
|
||||
o.timeLimit = o.timelimit;
|
||||
if (o.goodType == IT_TYPE.EQUIP_PIECE) {
|
||||
let good = findWhere(arr, { pieceId: o.good_id });
|
||||
if (!!good)
|
||||
o.equipId = good.good_id;
|
||||
}
|
||||
let condition = parseConditionStr(o.condition);
|
||||
for (let { id, type, params } of condition) {
|
||||
let mapArr = figureCondition.get(type) || new Array<{ params: number[], id: number, gid: number }>();
|
||||
@@ -138,68 +71,12 @@ export function loadGoods() {
|
||||
figureCondition.set(type, mapArr);
|
||||
}
|
||||
o.condition = condition;
|
||||
o.jobLimited = parseNumberList(o.jobLimited);
|
||||
o.charLimited = parseNumberList(o.charLimited);
|
||||
dicGoods.set(o.good_id, _.pick(o, Object.keys(DicGoodsKeys)));
|
||||
});
|
||||
|
||||
arr = undefined;
|
||||
}
|
||||
|
||||
function parseSpecialAttr(str: string) {
|
||||
let specialAttr = new Map<number, number>();
|
||||
if (str) {
|
||||
let decodeArr = decodeArrayListStr(str);
|
||||
for (let [type, count] of decodeArr) {
|
||||
if (isNaN(parseInt(type)) || isNaN(parseInt(count))) {
|
||||
throw new Error('data table format wrong');
|
||||
}
|
||||
|
||||
specialAttr.set(parseInt(type), parseInt(count));
|
||||
}
|
||||
}
|
||||
return specialAttr;
|
||||
}
|
||||
|
||||
function parseAbility(json) {
|
||||
let map = new Map<number, number>();
|
||||
map.set(ABI_TYPE.ABI_HP, json.hp || 0);
|
||||
map.set(ABI_TYPE.ABI_ATK, json.atk || 0);
|
||||
map.set(ABI_TYPE.ABI_DEF, json.def || 0);
|
||||
map.set(ABI_TYPE.ABI_MDEF, json.mdef || 0);
|
||||
map.set(ABI_TYPE.ABI_DAMAGE_INCREASE, json.damageIncrease || 0);
|
||||
map.set(ABI_TYPE.ABI_DAMAGE_DECREASE, json.damageDecrease || 0);
|
||||
map.set(ABI_TYPE.ABI_PHYSICAL_DAMAGE_DECREASE, json.atkDecrease || 0);
|
||||
map.set(ABI_TYPE.ABI_MAGIC_DAMAGE_DECREASE, json.matkDecrease || 0);
|
||||
return map
|
||||
}
|
||||
|
||||
function parseAbilityUp(json) {
|
||||
let map = new Map<number, number>();
|
||||
map.set(ABI_TYPE.ABI_HP, json.hp_up || 0);
|
||||
map.set(ABI_TYPE.ABI_ATK, json.atk_up || 0);
|
||||
map.set(ABI_TYPE.ABI_DEF, json.def_up || 0);
|
||||
map.set(ABI_TYPE.ABI_MDEF, json.mdef_up || 0);
|
||||
map.set(ABI_TYPE.ABI_DAMAGE_INCREASE, json.damageIncrease_up || 0);
|
||||
map.set(ABI_TYPE.ABI_DAMAGE_DECREASE, json.damageDecrease_up || 0);
|
||||
return map
|
||||
}
|
||||
|
||||
function parseSpecialMaterial(str: string) {
|
||||
let specialAttr = { ids: new Array<number>(), count: 0 }
|
||||
if (!str) return specialAttr;
|
||||
|
||||
let decodeArr = decodeArrayStr(str);
|
||||
if (decodeArr.length >= 2) {
|
||||
let ids = parseNumberList(decodeArr[0]);
|
||||
let count = parseInt(decodeArr[1]);
|
||||
if (isNaN(count)) return specialAttr;
|
||||
specialAttr.ids = ids;
|
||||
specialAttr.count = count;
|
||||
}
|
||||
return specialAttr;
|
||||
}
|
||||
|
||||
// 解析物品 {"type": number, "param": number} 格式
|
||||
export function parseConditionStr(str: string) {
|
||||
let result = new Array<{ id: number, type: number, params: number[] }>();
|
||||
|
||||
@@ -8,8 +8,6 @@ export interface DicGuildWishReward {
|
||||
readonly id: number;
|
||||
// itid
|
||||
readonly itid: number;
|
||||
// 装备星级
|
||||
readonly starLevel: number;
|
||||
// 品质
|
||||
readonly quality: number;
|
||||
// 功勋奖励
|
||||
@@ -24,7 +22,7 @@ export function loadGuildWishReward() {
|
||||
|
||||
arr.forEach(o => {
|
||||
if(o.starLevel == '&') o.starLevel = 0;
|
||||
dicGuildWishReward.set(`${o.itid}_${o.starLevel}_${o.quality}`, o);
|
||||
dicGuildWishReward.set(`${o.itid}_${o.quality}`, o);
|
||||
});
|
||||
arr = undefined;
|
||||
}
|
||||
@@ -37,17 +37,12 @@ export interface DicHero {
|
||||
|
||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
const DicHeroKeys: KeysEnum<DicHero> = {heroId: true, name: true, quality: true, camp: true, jobClass: true, jobid: true, skill: true, pieceId: true, initialStars: true, pieceCount: true, baseAbilityArr: true, baseAbilityUpArr: true, initialSkin: true, recruit: true, face_id: true};
|
||||
export const dicMyHeroes = new Array<number>();
|
||||
export const dicHero = new Map<number, DicHero>();
|
||||
export function loadHero() {
|
||||
dicMyHeroes.splice(0, dicMyHeroes.length);
|
||||
dicHero.clear();
|
||||
|
||||
let arr = readFileAndParse(FILENAME.DIC_HERO);
|
||||
arr.forEach(o => {
|
||||
if(o.heroId > 0 && o.heroId <= 300) {
|
||||
dicMyHeroes.push(o.heroId);
|
||||
}
|
||||
o.baseAbilityArr = parseBaseAbilityArr(o);
|
||||
o.baseAbilityUpArr = parseBaseAbilityUpArr(o);
|
||||
o.recruit = parseInt(o.recruit) == 1;
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
// 藏宝图合成表
|
||||
import { readFileAndParse, parseNumberList } from '../util'
|
||||
import { FILENAME } from '../../consts'
|
||||
const _ = require('lodash');
|
||||
|
||||
export interface DicHeroEquip {
|
||||
readonly itId: number;
|
||||
readonly classId: Array<number>;
|
||||
}
|
||||
|
||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
const DicHeroEquipKeys: KeysEnum<DicHeroEquip> = {
|
||||
itId: true,
|
||||
classId: true
|
||||
}
|
||||
export const dicHeroEquip = new Map<number, DicHeroEquip>();
|
||||
export function loadHeroEquip() {
|
||||
dicHeroEquip.clear();
|
||||
let arr = readFileAndParse(FILENAME.DIC_HERO_EQUIP);
|
||||
|
||||
arr.forEach(o => {
|
||||
o.classId = parseNumberList(o.classId);
|
||||
dicHeroEquip.set(o.itId, _.pick(o, Object.keys(DicHeroEquipKeys)));
|
||||
});
|
||||
|
||||
arr = undefined;
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
import { readFileAndParse, parseGoodStr } from '../util'
|
||||
import { FILENAME } from '../../consts'
|
||||
import { RewardInter } from '../interface';
|
||||
|
||||
export interface DicQuenchConsume {
|
||||
// id
|
||||
readonly id: number;
|
||||
// 等级
|
||||
readonly equipLvl: number;
|
||||
// 品质
|
||||
readonly quality: number;
|
||||
// 淬火一次的消耗
|
||||
readonly unitConsume: RewardInter[];
|
||||
}
|
||||
|
||||
export const dicQuenchConsume = new Map<string, RewardInter[]>(); // equipLvl&quality => dic
|
||||
export function loadQuenchConsume() {
|
||||
dicQuenchConsume.clear();
|
||||
|
||||
let arr = readFileAndParse(FILENAME.DIC_QUENCH_CONSUME);
|
||||
|
||||
arr.forEach(o => {
|
||||
o.unitConsume = parseGoodStr(o.unitconsume);
|
||||
dicQuenchConsume.set(`${o.equipLvl}_${o.quality}`, o.unitConsume);
|
||||
});
|
||||
arr = undefined;
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
import { readFileAndParse } from '../util'
|
||||
import { FILENAME } from '../../consts'
|
||||
|
||||
export interface DicQuenchQuality {
|
||||
// id
|
||||
readonly id: number;
|
||||
// 装备品质
|
||||
readonly quality: number;
|
||||
// 品相
|
||||
readonly grade: number;
|
||||
// 单属性最小值
|
||||
readonly singleRatioMin: number;
|
||||
// 单属性最大值
|
||||
readonly singleRatioMax: number;
|
||||
// 初始是否可以随机出
|
||||
readonly initialAvailable: number;
|
||||
// 暴击率
|
||||
readonly critProbability: number;
|
||||
// 暴击效果
|
||||
readonly critEffect: number;
|
||||
}
|
||||
|
||||
export const dicQuenchRangeByQualityAndGrade = new Map<string, { min: number, max: number, randMin: number, randMax: number }>();
|
||||
export const dicQuenchRangeByQuality = new Map<number, { min: number, max: number, randMin: number, randMax: number }>(); // quality => {}
|
||||
export const dicQuenchByQuality = new Map<number, Map<number, DicQuenchQuality>>(); // quality => grade => dic
|
||||
export function loadQuenchQuality() {
|
||||
dicQuenchByQuality.clear();
|
||||
dicQuenchRangeByQuality.clear();
|
||||
dicQuenchRangeByQualityAndGrade.clear();
|
||||
let arr = readFileAndParse(FILENAME.DIC_QUENCH_QUALITY);
|
||||
|
||||
arr.forEach(o => {
|
||||
if(o.initialAvailable == 1) {
|
||||
}
|
||||
|
||||
|
||||
if(!dicQuenchRangeByQuality.has(o.quality)) {
|
||||
dicQuenchRangeByQuality.set(o.quality, { min: o.singleRatioMin, max: o.singleRatioMax, randMin: o.singleRatioMin, randMax: o.singleRatioMax });
|
||||
} else {
|
||||
if(o.singleRatioMin < dicQuenchRangeByQuality.get(o.quality).min) {
|
||||
dicQuenchRangeByQuality.get(o.quality).min = o.singleRatioMin;
|
||||
}
|
||||
if(o.singleRatioMax > dicQuenchRangeByQuality.get(o.quality).max) {
|
||||
dicQuenchRangeByQuality.get(o.quality).max = o.singleRatioMax;
|
||||
}
|
||||
if(o.singleRatioMin < dicQuenchRangeByQuality.get(o.quality).randMin && o.initialAvailable == 1) {
|
||||
dicQuenchRangeByQuality.get(o.quality).randMin = o.singleRatioMin;
|
||||
}
|
||||
if(o.singleRatioMax > dicQuenchRangeByQuality.get(o.quality).randMax && o.initialAvailable == 1) {
|
||||
dicQuenchRangeByQuality.get(o.quality).randMax = o.singleRatioMax;
|
||||
}
|
||||
|
||||
}
|
||||
dicQuenchRangeByQualityAndGrade.set(`${o.quality}_${o.grade}`, { min: o.singleRatioMin, max: o.singleRatioMax, randMin: o.singleRatioMin, randMax: o.singleRatioMax });
|
||||
|
||||
|
||||
if(!dicQuenchByQuality.has(o.quality)) {
|
||||
dicQuenchByQuality.set(o.quality, new Map<number, DicQuenchQuality>());
|
||||
}
|
||||
dicQuenchByQuality.get(o.quality).set(o.grade, o);
|
||||
});
|
||||
arr = undefined;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
// 武将特技表
|
||||
import { readFileAndParse, parseGoodStr } from '../util'
|
||||
import { FILENAME } from '../../consts'
|
||||
import { RewardInter } from '../interface';
|
||||
|
||||
export interface DicRefine {
|
||||
|
||||
// 精炼id
|
||||
readonly id: number;
|
||||
// 精炼等级
|
||||
readonly level: number;
|
||||
// 精炼次数
|
||||
readonly count: number;
|
||||
// 等级限制
|
||||
readonly levelLimited: number;
|
||||
// 提高属性百分比
|
||||
readonly upPercent: number;
|
||||
// 材料
|
||||
readonly consume: Array<RewardInter>;
|
||||
}
|
||||
|
||||
export const dicRefine = new Map<number, DicRefine>();
|
||||
export function loadRefine() {
|
||||
dicRefine.clear();
|
||||
|
||||
let arr = readFileAndParse(FILENAME.DIC_REFINE);
|
||||
|
||||
arr.forEach(o => {
|
||||
o.consume = parseGoodStr(o.consume)
|
||||
dicRefine.set(o.id, o);
|
||||
});
|
||||
|
||||
arr = undefined;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
// 强化消耗表
|
||||
import {readFileAndParse} from '../util'
|
||||
import { FILENAME } from '../../consts'
|
||||
|
||||
export interface DicStrengthenCost {
|
||||
// 等级
|
||||
readonly level: number;
|
||||
// 消耗铜钱
|
||||
readonly costCoin: number;
|
||||
}
|
||||
|
||||
export const dicStrengthenCost = new Map<number, number>();
|
||||
export function loadStrengthenCost() {
|
||||
dicStrengthenCost.clear();
|
||||
|
||||
let arr = readFileAndParse(FILENAME.DIC_STRENGTHEN_COST);
|
||||
|
||||
arr.forEach(o => {
|
||||
dicStrengthenCost.set(o.level, o.costCoin);
|
||||
});
|
||||
arr = undefined;
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
// 套装表
|
||||
import { decodeArrayListStr, readFileAndParse, parseNumberList } from '../util'
|
||||
import { FILENAME } from '../../consts';
|
||||
|
||||
export interface DicSuit {
|
||||
// 套装id
|
||||
readonly id: number;
|
||||
// 套装类型,相同suitType效果可跨级用
|
||||
readonly suitType: number;
|
||||
// 星级,相同suitType starLevel较高的套装可覆盖较低的效果
|
||||
readonly starLevel: number;
|
||||
// 包含关卡
|
||||
readonly name: string;
|
||||
// 总件数
|
||||
readonly totalCount: number;
|
||||
// 套装效果
|
||||
readonly effect: Array<{ count: number, seid: number }>;
|
||||
readonly tireInfo: Array<number>;
|
||||
}
|
||||
|
||||
|
||||
export const dicSuit = new Map<number, DicSuit>();
|
||||
export const dicSuitByTypeAndLv = new Map<string, DicSuit>();
|
||||
export function loadSuit() {
|
||||
dicSuit.clear();
|
||||
dicSuitByTypeAndLv.clear();
|
||||
|
||||
let arr = readFileAndParse(FILENAME.DIC_SUIT);
|
||||
|
||||
arr.forEach(o => {
|
||||
o.effect = parseSuitEffect(o.effect);
|
||||
o.tireInfo = parseNumberList(o.tireInfo);
|
||||
dicSuit.set(o.id, o);
|
||||
dicSuitByTypeAndLv.set(`${o.suitType}_${o.starLevel}`, o);
|
||||
});
|
||||
arr = undefined;
|
||||
}
|
||||
|
||||
function parseSuitEffect(str: string) {
|
||||
let result = new Array<{ count: number, seid: number }>();
|
||||
if (!str) return result;
|
||||
let decodeArr = decodeArrayListStr(str);
|
||||
for (let [count, seid] of decodeArr) {
|
||||
if (isNaN(parseInt(count)) || isNaN(parseFloat(seid))) {
|
||||
throw new Error('data table format wrong');
|
||||
}
|
||||
result.push({ count: parseInt(count), seid: parseFloat(seid) });
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -187,21 +187,6 @@ export async function calPlayerCe(hero: HeroType, update: HeroUpdate, type: numb
|
||||
case HERO_SYSTEM_TYPE.JEWEL_QUENCH:
|
||||
heroAttrs = calJewelResetRandSeIncAttr(hero, args, params, addSeidList, removeSeidList);
|
||||
break;
|
||||
case HERO_SYSTEM_TYPE.EQUIP: //
|
||||
heroAttrs = calEquipPutOnOffIncAttr(hero, args, addSeidList, removeSeidList);
|
||||
break;
|
||||
case HERO_SYSTEM_TYPE.EQUIP_BASE: //
|
||||
heroAttrs = calHeroEquipIncAttr(hero);
|
||||
break;
|
||||
case HERO_SYSTEM_TYPE.RESTRENGTHEN: //
|
||||
heroAttrs = calRestrengthenIncAttr(hero, args.shift(), args, addSeidList, removeSeidList);
|
||||
break;
|
||||
case HERO_SYSTEM_TYPE.JEWEL_ON: //
|
||||
heroAttrs = calHeroCeWhenJewelOnOrOff(hero, args[0], args[1]);
|
||||
break;
|
||||
case HERO_SYSTEM_TYPE.JEWEL_OFF: //
|
||||
heroAttrs = calHeroCeWhenJewelOnOrOff(hero, 0, args[0]);
|
||||
break;
|
||||
case HERO_SYSTEM_TYPE.SCROLL:
|
||||
heroAttrs = calHeroCeScrollIncAttr(hero, update);
|
||||
break;
|
||||
@@ -795,185 +780,6 @@ export function calJewelResetRandSeIncAttr(hero: HeroType, eplaceIds: number[],
|
||||
return heroAttrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 穿脱, removeSeidList原来身上穿着的所有装备的seid,包括套装的
|
||||
* @param {HeroType} hero 武将
|
||||
* @param {number[]} seids args 原来穿着的装备的seid
|
||||
* @param {number[]} addSeidList 用于更新被动
|
||||
* @param {number[]} removeSeidList 用于更新被动
|
||||
*/
|
||||
export function calEquipPutOnOffIncAttr(hero: HeroType, seids: Array<number>, addSeidList: Array<number>, removeSeidList: Array<number>) {
|
||||
// 计算身上所有装备的战力值(特技相关以外)
|
||||
let heroAttrs = calHeroEquipIncAttr(hero);
|
||||
|
||||
// 计算被动技能
|
||||
let resultSeid = calEquipSeids(hero);
|
||||
for(let seid of resultSeid) {
|
||||
addSeidList.push(seid, 0);
|
||||
}
|
||||
|
||||
for (let seid of seids) {
|
||||
removeSeidList.push(seid, 0);
|
||||
}
|
||||
|
||||
return heroAttrs
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算一个武将身上的所有被动seid
|
||||
* @param {HeroType} hero 武将,equip需要populate
|
||||
*/
|
||||
export function calEquipSeids(_hero: HeroType) {
|
||||
let seids: number[] = [];
|
||||
// // 计算被动技能
|
||||
// let { ePlace } = hero;
|
||||
// let suits = new Map<number, Map<number, { dic: DicSuit, count: number }>>(); // suitType => starLevel => DicSuit
|
||||
|
||||
// for (let { equip } of ePlace) {
|
||||
// if (equip) {
|
||||
// let e = <EquipType>equip;
|
||||
// if (!!e.randSe) {
|
||||
// for (let { seid, rand } of e.randSe) {
|
||||
// seids.push(seid, rand);
|
||||
// }
|
||||
// }
|
||||
// if (e.suitId > 0) {
|
||||
// let { suitType, starLevel } = gameData.suit.get(e.suitId);
|
||||
// if (!suits.has(suitType)) {
|
||||
// suits.set(suitType, new Map<number, { dic: DicSuit, count: number }>());
|
||||
// }
|
||||
// for(let lv = 1; lv <= starLevel; lv++) {
|
||||
// let dicSuit = getDicSuitByTypeAndLv(suitType, lv); // 计算同type的低阶套装
|
||||
// if(dicSuit) {
|
||||
// if(!suits.get(suitType).has(lv)) {
|
||||
// suits.get(suitType).set(lv, { dic: dicSuit, count: 0 });
|
||||
// }
|
||||
// suits.get(suitType).get(lv).count ++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// for(let [ _suitType, map ] of suits) {
|
||||
// let effectSeid = new Map<number, { starLevel: number, seid: number }>(); // count => { starLevel, seid }
|
||||
// for(let [ starLevel, { dic: { effect }, count } ] of map) {
|
||||
// for(let { count: effectCount, seid} of effect) {
|
||||
// if(count >= effectCount ) { // 生效
|
||||
// if(!effectSeid.has(effectCount) || effectSeid.get(effectCount).starLevel < starLevel) { // 没有同数量效果
|
||||
// effectSeid.set(effectCount, { starLevel, seid });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// for(let [_count, { seid }] of effectSeid) {
|
||||
// seids.push(seid, 0);
|
||||
// }
|
||||
// }
|
||||
return seids;
|
||||
}
|
||||
|
||||
/**
|
||||
* 装备,装备栏升级,装备精炼等涉及到值的
|
||||
* @param {HeroType} hero 装备更新过的武将
|
||||
*/
|
||||
export function calHeroEquipIncAttr(hero: HeroType) {
|
||||
let { attr: heroAttrs } = hero;
|
||||
|
||||
// let setMap = new Map<number, number>();
|
||||
// for (let { equip, lv, refineLv } of ePlace) {
|
||||
// if (equip) {
|
||||
// let e = <EquipType>equip;
|
||||
// let dicGoods = gameData.goods.get(e.id);
|
||||
// let { goodsAbility, goodsAbilityUp } = dicGoods;
|
||||
// let dicRefine = gameData.refine.get(refineLv);
|
||||
|
||||
// let jewel = new Map<number, number>();
|
||||
// for (let { jewel: jewelId } of e.holes) {
|
||||
// if (jewelId > 0) {
|
||||
// let g = gameData.goods.get(jewelId);
|
||||
// if (g) {
|
||||
// let jGoods = g.goodsAbility;
|
||||
// jGoods.forEach((value, key) => {
|
||||
// if (!jewel.has(key)) {
|
||||
// jewel.set(key, value);
|
||||
// } else {
|
||||
// jewel.set(key, jewel.get(key) + value);
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// let randMainMap = new Map<number, number>();
|
||||
// for(let {id, rand} of (e.randMain||[])) {
|
||||
// randMainMap.set(id, rand);
|
||||
// }
|
||||
// for (let i = ABI_TYPE.ABI_HP; i < ABI_TYPE.ABI_MAX; i++) {
|
||||
// // console.log('***', i);
|
||||
// let value1 = goodsAbility.get(i) || 0 * (HERO_CE_RATIO + e.randRange);
|
||||
// // console.log('基础值', value1);
|
||||
// let valueup = goodsAbilityUp.get(i) || 0;
|
||||
// // console.log('成长', lv, valueup);
|
||||
// let valueRefine = dicRefine ? dicRefine.upPercent : 0;
|
||||
// // console.log('精炼', dicRefine?dicRefine.upPercent:0 );
|
||||
// let valueJewel = jewel.get(i) || 0;
|
||||
// // console.log('宝石', valueJewel);
|
||||
// let valueGrade = randMainMap.get(i)||0;
|
||||
// // console.log('品相', valueGrade)
|
||||
// let attr = (value1 + lv * valueup) * valueGrade * (HERO_CE_RATIO + valueRefine) + valueJewel * HERO_CE_RATIO * HERO_CE_RATIO;
|
||||
|
||||
// if(attr >= 0) {
|
||||
// // console.log('装备战力:', i, attr);
|
||||
// if(setMap.has(i)) {
|
||||
// setMap.set(i, setMap.get(i) + Math.floor(attr / HERO_CE_RATIO));
|
||||
// } else {
|
||||
// setMap.set(i, Math.floor(attr / HERO_CE_RATIO));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// for (let i = ABI_TYPE.ABI_HP; i < ABI_TYPE.ABI_MAX; i++) {
|
||||
// let attr = setMap.get(i)||0;
|
||||
// updateHeroAttr(heroAttrs, i, { set: { equipUp: attr } })
|
||||
// }
|
||||
|
||||
// hero.attr = heroAttrs;
|
||||
return heroAttrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 洗炼
|
||||
* @param {HeroType} hero 更新过的武将
|
||||
* @param {number} ePaceId 更新的栏位id
|
||||
* @param {number[]} seids 移除的seid
|
||||
* @param {number[]} addSeidList 用于更新被动
|
||||
* @param {number[]} removeSeidList 用于更新被动
|
||||
*/
|
||||
export function calRestrengthenIncAttr(hero: HeroType, _ePaceId: number, _seids: Array<number>, _addSeidList: Array<number>, _removeSeidList: Array<number>) {
|
||||
|
||||
let { attr: heroAttrs } = hero;
|
||||
// let { ePlace } = hero;
|
||||
|
||||
// let curPlace = ePlace.find(cur => cur.id == ePaceId);
|
||||
// if (curPlace && curPlace.equip) {
|
||||
// let e = <EquipType>curPlace.equip;
|
||||
// for (let { seid, rand } of e.randSe) {
|
||||
// addSeidList.push(seid, rand);
|
||||
// }
|
||||
// }
|
||||
|
||||
// for (let seid of seids) {
|
||||
// removeSeidList.push(seid)
|
||||
// }
|
||||
|
||||
return heroAttrs
|
||||
}
|
||||
|
||||
// 添加技能增加的被动属性
|
||||
function addSeidEffect(heroAttrs: CeAttrData[], addSeidList: Array<number>, removeSeidList: Array<number>) {
|
||||
|
||||
@@ -1036,34 +842,6 @@ function addSeid(effectList: Array<any>, seidId: number, rand: number, seidValue
|
||||
effectList.push(seid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带上宝石
|
||||
* @param {HeroType} hero 武将数据
|
||||
* @param {number} id 带上的宝石
|
||||
* @param {number} oldId 脱下的宝石
|
||||
*/
|
||||
function calHeroCeWhenJewelOnOrOff(hero: HeroType, id: number, oldId: number) {
|
||||
let { attr: heroAttrs } = hero;
|
||||
let { goodsAbility } = gameData.goods.get(id)||{ goodsAbility: new Map<number, number>() };
|
||||
let { goodsAbility: oldGoodsAbility } = gameData.goods.get(oldId)||{ goodsAbility: new Map<number, number>() };
|
||||
|
||||
let allIds: number[] = [];
|
||||
for(let [ id ] of goodsAbility) {
|
||||
allIds.push(id);
|
||||
}
|
||||
for(let [ id ] of oldGoodsAbility) {
|
||||
if(allIds.indexOf(id) == -1) allIds.push(id);
|
||||
}
|
||||
for(let id of allIds) {
|
||||
let value = goodsAbility.get(id)||0;
|
||||
let oldValue = oldGoodsAbility.get(id)||0;
|
||||
updateHeroAttr(heroAttrs, id, { inc: { equipUp: (value - oldValue) * HERO_CE_RATIO } })
|
||||
}
|
||||
|
||||
hero.attr = heroAttrs;
|
||||
return heroAttrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局加成,百家学宫
|
||||
* @param role 角色
|
||||
|
||||
@@ -15,7 +15,6 @@ import { reduceCe, resResult } from "./util";
|
||||
import { calculatetopLineup, } from "./playerCe";
|
||||
import { GuildModel, GuildType } from "../db/Guild";
|
||||
import { PvpDefenseModel } from "../db/PvpDefense";
|
||||
import { EquipModel } from '../db/Equip';
|
||||
import { ActionPointModel } from '../db/ActionPoint';
|
||||
import { BattleDropModel } from '../db/BattleDrop';
|
||||
import { BattleRecordModel } from '../db/BattleRecord';
|
||||
@@ -101,6 +100,7 @@ import { HeroShowParam } from '../domain/roleField/hero';
|
||||
import { saveCeChangeLog } from "./logUtil";
|
||||
import { ActivityInRemote } from "../domain/activityField/activityField";
|
||||
import { AttributeCal } from "../domain/roleField/attribute";
|
||||
import { JewelModel } from "../db/Jewel";
|
||||
|
||||
// 储存在内存中的初始数据
|
||||
export function getInitRoleInfo() {
|
||||
@@ -418,7 +418,7 @@ export async function deletRole(roleId: string) {
|
||||
await ChatInfoModel.updateMany({ 'recentPrivateChats.targetRoleId': roleId }, { $pull: { recentPrivateChats: { targetRoleId: roleId } } });
|
||||
await DailyRecordModel.deleteMany({ roleId });
|
||||
await DungeonFirstModel.deleteMany({ roleId });
|
||||
await EquipModel.deleteMany({ roleId });
|
||||
await JewelModel.deleteMany({ roleId });
|
||||
await EquipPrintDropModel.deleteMany({ roleId });
|
||||
await EventRecordModel.deleteMany({ roleId });
|
||||
await ExpeditionPointModel.deleteMany({ roleId });
|
||||
|
||||
@@ -6,7 +6,6 @@ import { RoleType, RoleModel } from '../db/Role';
|
||||
import { TaskParam, TaskListReturn } from '../domain/roleField/task';
|
||||
import { getZeroPoint } from './timeUtil';
|
||||
import { HeroType } from '../db/Hero';
|
||||
import { EquipType, EquipModel } from '../db/Equip';
|
||||
import { ItemInter } from './interface';
|
||||
import { DailyChallengesData } from '../domain/activityField/dailyChallengesField';
|
||||
import { splitString } from './util';
|
||||
@@ -149,61 +148,61 @@ export async function checkTaskWithHero(roleId: string, taskType: number, hero:
|
||||
}
|
||||
|
||||
|
||||
export async function checkTaskWithEquip(roleId: string, taskType: number, equip: EquipType, args: number[] = []) {
|
||||
let pushMessage = new Array<TaskListReturn>();
|
||||
if (taskType == TASK_TYPE.EQUIP_QUALITY) {
|
||||
// args[0] 1:装上 -1:脱下
|
||||
let dicGood = gameData.goods.get(equip.id);
|
||||
pushMessage = await checkTask(roleId, taskType, args[0], true, { quality: dicGood.quality })
|
||||
}
|
||||
else if (taskType == TASK_TYPE.EQUIP_JEWEL) {
|
||||
// args[0] 原来镶嵌了多少宝石
|
||||
let { holes } = equip;
|
||||
let jewelCount = holes.filter(cur => cur.jewel > 0).length;
|
||||
if (jewelCount > 0 && args[0] <= 0) { // 原来没有,镶嵌上了
|
||||
pushMessage = await checkTask(roleId, taskType, 1, true, {});
|
||||
} else if (jewelCount <= 0 && args[0] > 0) { // 原来镶嵌着,现在没了
|
||||
pushMessage = await checkTask(roleId, taskType, -1, true, {});
|
||||
}
|
||||
}
|
||||
else if (taskType == TASK_TYPE.EQUIP_COMPOSE_SUIT) {
|
||||
let dicGood = gameData.goods.get(equip.id);
|
||||
if (dicGood.suitId) {
|
||||
pushMessage = await checkTask(roleId, taskType, 1, true, {});
|
||||
}
|
||||
}
|
||||
else if (taskType == TASK_TYPE.EQUIP_SUIT) {
|
||||
let dicGood = gameData.goods.get(equip.id);
|
||||
if (dicGood.suitId) {
|
||||
let suit = gameData.suit.get(dicGood.suitId);
|
||||
let equips = await EquipModel.getEquipsByIds(roleId, suit.tireInfo);
|
||||
let everyEquip = new Map<number, number>();
|
||||
for (let equip of equips) {
|
||||
if (everyEquip.has(equip.id)) {
|
||||
everyEquip.set(equip.id, everyEquip.get(equip.id) + 1);
|
||||
} else {
|
||||
everyEquip.set(equip.id, 1);
|
||||
}
|
||||
}
|
||||
let minCount = 0, curCount = 0;
|
||||
for (let id of suit.tireInfo) {
|
||||
let count = everyEquip.get(id) || 0;
|
||||
if (minCount > count) minCount = count;
|
||||
if (id == equip.id) curCount = count;
|
||||
}
|
||||
if (curCount == minCount) {
|
||||
pushMessage = await checkTask(roleId, taskType, 1, true, {});
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (taskType == TASK_TYPE.EQUIP_JEWEL_SUM) {
|
||||
// args[0] 原来镶嵌了多少宝石
|
||||
let { holes } = equip;
|
||||
let jewelCount = holes.filter(cur => cur.jewel > 0).length;
|
||||
pushMessage = await checkTask(roleId, taskType, jewelCount - args[0], true, {});
|
||||
}
|
||||
return pushMessage
|
||||
}
|
||||
// export async function checkTaskWithEquip(roleId: string, taskType: number, equip: EquipType, args: number[] = []) {
|
||||
// let pushMessage = new Array<TaskListReturn>();
|
||||
// if (taskType == TASK_TYPE.EQUIP_QUALITY) {
|
||||
// // args[0] 1:装上 -1:脱下
|
||||
// let dicGood = gameData.goods.get(equip.id);
|
||||
// pushMessage = await checkTask(roleId, taskType, args[0], true, { quality: dicGood.quality })
|
||||
// }
|
||||
// else if (taskType == TASK_TYPE.EQUIP_JEWEL) {
|
||||
// // args[0] 原来镶嵌了多少宝石
|
||||
// let { holes } = equip;
|
||||
// let jewelCount = holes.filter(cur => cur.jewel > 0).length;
|
||||
// if (jewelCount > 0 && args[0] <= 0) { // 原来没有,镶嵌上了
|
||||
// pushMessage = await checkTask(roleId, taskType, 1, true, {});
|
||||
// } else if (jewelCount <= 0 && args[0] > 0) { // 原来镶嵌着,现在没了
|
||||
// pushMessage = await checkTask(roleId, taskType, -1, true, {});
|
||||
// }
|
||||
// }
|
||||
// else if (taskType == TASK_TYPE.EQUIP_COMPOSE_SUIT) {
|
||||
// let dicGood = gameData.goods.get(equip.id);
|
||||
// if (dicGood.suitId) {
|
||||
// pushMessage = await checkTask(roleId, taskType, 1, true, {});
|
||||
// }
|
||||
// }
|
||||
// else if (taskType == TASK_TYPE.EQUIP_SUIT) {
|
||||
// let dicGood = gameData.goods.get(equip.id);
|
||||
// if (dicGood.suitId) {
|
||||
// let suit = gameData.suit.get(dicGood.suitId);
|
||||
// let equips = await EquipModel.getEquipsByIds(roleId, suit.tireInfo);
|
||||
// let everyEquip = new Map<number, number>();
|
||||
// for (let equip of equips) {
|
||||
// if (everyEquip.has(equip.id)) {
|
||||
// everyEquip.set(equip.id, everyEquip.get(equip.id) + 1);
|
||||
// } else {
|
||||
// everyEquip.set(equip.id, 1);
|
||||
// }
|
||||
// }
|
||||
// let minCount = 0, curCount = 0;
|
||||
// for (let id of suit.tireInfo) {
|
||||
// let count = everyEquip.get(id) || 0;
|
||||
// if (minCount > count) minCount = count;
|
||||
// if (id == equip.id) curCount = count;
|
||||
// }
|
||||
// if (curCount == minCount) {
|
||||
// pushMessage = await checkTask(roleId, taskType, 1, true, {});
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else if (taskType == TASK_TYPE.EQUIP_JEWEL_SUM) {
|
||||
// // args[0] 原来镶嵌了多少宝石
|
||||
// let { holes } = equip;
|
||||
// let jewelCount = holes.filter(cur => cur.jewel > 0).length;
|
||||
// pushMessage = await checkTask(roleId, taskType, jewelCount - args[0], true, {});
|
||||
// }
|
||||
// return pushMessage
|
||||
// }
|
||||
|
||||
export async function checkTaskWithArgs(roleId: string, taskType: number, args: number[]) {
|
||||
let pushMessage = new Array<TaskListReturn>();
|
||||
@@ -217,18 +216,18 @@ export async function checkTaskWithArgs(roleId: string, taskType: number, args:
|
||||
}
|
||||
}
|
||||
else if (taskType == TASK_TYPE.EQUIP_JEWEL_STAGE) {
|
||||
// args 装上的, 卸下的
|
||||
let [putOnJewel, putOffJewel] = args;
|
||||
if (putOnJewel > 0) {
|
||||
let dicGood = gameData.goods.get(putOnJewel);
|
||||
let push = await checkTask(roleId, taskType, 1, true, { stage: dicGood.lvLimited });
|
||||
pushMessage.push(...push);
|
||||
}
|
||||
if (putOffJewel > 0) {
|
||||
let dicGood = gameData.goods.get(putOffJewel);
|
||||
let push = await checkTask(roleId, taskType, -1, true, { stage: dicGood.lvLimited });
|
||||
pushMessage.push(...push);
|
||||
}
|
||||
// // args 装上的, 卸下的
|
||||
// let [putOnJewel, putOffJewel] = args;
|
||||
// if (putOnJewel > 0) {
|
||||
// let dicGood = gameData.goods.get(putOnJewel);
|
||||
// let push = await checkTask(roleId, taskType, 1, true, { stage: dicGood.lvLimited });
|
||||
// pushMessage.push(...push);
|
||||
// }
|
||||
// if (putOffJewel > 0) {
|
||||
// let dicGood = gameData.goods.get(putOffJewel);
|
||||
// let push = await checkTask(roleId, taskType, -1, true, { stage: dicGood.lvLimited });
|
||||
// pushMessage.push(...push);
|
||||
// }
|
||||
}
|
||||
else if (taskType == TASK_TYPE.CHAT) {
|
||||
// args[0] 聊天type 1-系统 2-世界 3-军团 4-组队 5-私聊
|
||||
|
||||
Reference in New Issue
Block a user