装备:清理旧代码

This commit is contained in:
luying
2022-02-18 17:53:10 +08:00
parent e29326856c
commit 3d6fab2ae6
33 changed files with 169 additions and 1472 deletions

View File

@@ -1,5 +1,4 @@
import { STATUS } from './../../../consts/statusCode';
import { EquipModel } from './../../../db/Equip';
import { RoleModel, RoleType } from './../../../db/Role';
import { UserModel } from '../../../db/User';
import { GMUserModel } from '../../../db/GMUser';
@@ -17,7 +16,6 @@ import { rmRoleFromQueue, roleLeave, getRoleOnlineInfo, roleLogin } from '../../
import { addRoleToGuildChannel, addRoleToSysChannel, addRoleToWorldChannel, leaveGuildAuctionChannel, leaveGuildChannel, leaveSysChannel, leaveWorldAuctionChannel, leaveWorldChannel, recentGuildMsgs, recentPrivateChatInfos, recentSysMsgs, recentWorldMsgs } from '../../../services/chatService';
import { reportOneOnline, savePlayTime } from '../../../services/authenticateService';
import { Rank } from '../../../services/rankService';
import { checkTaskWithRole, } from '../../../services/taskService';
import { pushData, everydayRefresh, kickUser } from '../../../services/connectorService';
import { pick } from 'lodash';

View File

@@ -5,8 +5,8 @@ import { WishPoolReportModel } from '../../../db/WishPoolReport';
import { resResult, genCode } from '../../../pubUtils/util';
import { ITEM_CHANGE_REASON, STATUS } from '../../../consts';
import { getArmyWishPoolBaseByLv, getGoodById, getWishPoolReward } from '../../../pubUtils/data';
import { addItems, checkGoods, checkHeroes } from '../../../services/rewardService';
import { IT_TYPE } from '../../../consts/constModules/itemConst';
import { addItems, checkGoods, checkHeroEquips, checkHeroes } from '../../../services/rewardService';
import { ITID, CONSUME_TYPE } from '../../../consts/constModules/itemConst';
import { GUILD_STRUCTURE } from '../../../consts/constModules/guildConst';
import { refreshUserGuild, getWishPool, getUserGuildWithRefActive } from '../../../services/guildService';
import { findIndex, findWhere } from 'underscore';
@@ -40,23 +40,23 @@ export class WishPoolHandler {
const { goodId, type, myUserGuild } = msg;
const roleId: string = session.get('roleId');
const serverId: number = parseInt(session.get('serverId'));
let count;
let goodInfo = getGoodById(goodId)
if (!goodInfo)
return resResult(STATUS.WRONG_PARMS);
if (!(goodInfo.itid == IT_TYPE.HERO_PIECE && type == 2 ) && !(goodInfo.itid == IT_TYPE.EQUIP_PIECE && type == 1 ))
let dicGoods = getGoodById(goodId)
if (!dicGoods) return resResult(STATUS.WRONG_PARMS);
let dicItid = ITID.get(dicGoods.itid);
if (!(dicItid.type == CONSUME_TYPE.SOUL && type == 2 ) && !(dicItid.type == CONSUME_TYPE.DRAWING && type == 1 ))
return resResult(STATUS.WRONG_PARMS);
let userGuild = await refreshUserGuild(myUserGuild, roleId);
if (!userGuild)
return resResult(STATUS.WRONG_PARMS);
if (!userGuild) return resResult(STATUS.WRONG_PARMS);
let result = await checkGoods(roleId, [goodId]);
if (!result) {
if (goodInfo.itid == IT_TYPE.HERO_PIECE ) {
result = await checkHeroes(roleId, [goodInfo.hid]);
if (dicItid.type == CONSUME_TYPE.SOUL ) {
result = await checkHeroes(roleId, [dicGoods.hid]);
if (!result)
return resResult(STATUS.GUILD_WISH_POOL_NOT_OWN_HERO);
} else if (goodInfo.itid == IT_TYPE.EQUIP_PIECE ) {
result = await checkGoods(roleId, [goodInfo.equipId]);
} else if (dicItid.type == CONSUME_TYPE.DRAWING ) {
result = await checkHeroEquips(roleId, dicGoods.quality);
if (!result)
return resResult(STATUS.GUILD_WISH_POOL_NOT_OWN_EQUIP);
}
@@ -65,27 +65,23 @@ export class WishPoolHandler {
let { structure } = await GuildModel.findGuild(code, serverId, 'structure');
let { lv } = findWhere(structure, {id: GUILD_STRUCTURE.WISH_POOL});
let { wishgoodsDrawings, wishGoodsHeros } = getArmyWishPoolBaseByLv(lv);
let len = 0;
wishGoods.map(({type: resType})=>{
if (resType == type)
len++;
});
let len = wishGoods.filter(cur => cur.type == type).length;
if(receivedWishPool.indexOf(type) != -1 && getSeconds(createdAt) > getZeroPoint()) {
return resResult(STATUS.HAS_REACH_WISH_COUNT_LIMIT);
}
if (len >= ARMY.ARMY_WISH_TIMES) //今日已经许愿过
return resResult(STATUS.HAS_REACH_WISH_COUNT_LIMIT);
let dicWishPool = getArmyWishPoolBaseByLv(lv);
let count = 0;
if (type == 1) {
let wishGoodsDrawing = findWhere(wishgoodsDrawings, { quality: goodInfo.quality});
if (!wishGoodsDrawing)
return resResult(STATUS.NOT_WISH_THE_QUALITY_GOODS);
let wishGoodsDrawing = dicWishPool.wishgoodsDrawings.find(cur => cur.quality == dicGoods.quality);
if (!wishGoodsDrawing) return resResult(STATUS.NOT_WISH_THE_QUALITY_GOODS);
count = wishGoodsDrawing.count;
} else {
let wishGoodsHero = findWhere(wishGoodsHeros, { quality: goodInfo.quality});
if (!wishGoodsHero)
return resResult(STATUS.NOT_WISH_THE_QUALITY_GOODS);
let wishGoodsHero = dicWishPool.wishGoodsHeros.find(cur => cur.quality == dicGoods.quality);
if (!wishGoodsHero) return resResult(STATUS.NOT_WISH_THE_QUALITY_GOODS);
count = wishGoodsHero.count;
}
const id = genCode(6);

View File

@@ -1,24 +1,17 @@
import { Application, BackendSession, HandlerService, } from "pinus";
import { STATUS, EQUIP_STRENGTHEN_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, HERO_SYSTEM_TYPE, CONSUME_TYPE, HERO_GROW_MAX, MSG_SOURCE, JEWEL_PUSH_LV, TASK_TYPE, HERO_CE_RATIO, ITEM_CHANGE_REASON } from "../../../consts";
import { STATUS, HERO_SYSTEM_TYPE, ITEM_CHANGE_REASON } from "../../../consts";
import { ItemInter, RewardInter } from "../../../pubUtils/interface";
import { resResult, parseGoodStr } from "../../../pubUtils/util";
import { addItems, handleCost, combineItems, CheckMeterial } from "../../../services/rewardService";
import { EquipModel, EquipType } from "../../../db/Equip";
import { HeroModel, EPlace, HeroType } from "../../../db/Hero";
import Role from "../../../db/Role";
import { HeroModel, EPlace } from "../../../db/Hero";
import { calPlayerCeAndSave } from "../../../services/playerCeService";
import { getGoodById, gameData, getEquipByJobClassAndEPlace, getNextEquipQuality, getEquipQualityIdByEquipIdAndPoint, getEquipStarIdByEquipId, getNextEquipStar } from "../../../pubUtils/data";
import { gameData, getEquipByJobClassAndEPlace, getNextEquipQuality, 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 { checkEquipCanPut, quenchOnce, checkQuenchMaxByQualityAndGrade, getRandSeResult, refineOnce, checkRefineReachNextLv, calEquipCe, updateEplace, updateEplaces, checkJewelCanPutOnEquip, updateStone, checkStoneCanPutOnEquip } from "../../../services/equipService";
import { getRandSeResult, updateEplace, updateEplaces, checkJewelCanPutOnEquip, updateStone, checkStoneCanPutOnEquip } 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";
import { isNumber, pick } from 'underscore';
import { JewelModel } from "../../../db/Jewel";
import { getJewelRandSe } from "../../../pubUtils/itemUtils";
export default function (app: Application) {

View File

@@ -16,7 +16,6 @@ import { getFriendPointObject } from "../../../pubUtils/itemUtils";
import { RewardInter } from "../../../pubUtils/interface";
import { FriendPresentLogModel } from '../../../db/FriendPresentLog';
import { HeroModel, EPlace } from "../../../db/Hero";
import { EquipModel } from "../../../db/Equip";
import { getPlayerMainAttribute } from "../../../services/pvpService";
import { FRIEND } from "../../../pubUtils/dicParam";
import { PlayerDetail, PlayerDetailHero } from "../../../domain/battleField/guild";

View File

@@ -11,11 +11,9 @@ import { gameData, getHeroExpByLv, getHeroStarByQuality, getHeroWakeByQuality, g
import { ItemInter, RewardInter } from '../../../pubUtils/interface';
import { getDropItems, FIGURE_UNLOCK_CONDITION } from '../../../consts/constModules/itemConst'
import { pushComposeOrangeHero, pushHeroQualityUpMsg, pushHeroStarMax, pushHeroWakeUp } from '../../../services/chatService';
import { calculatetopLineup, calEquipSeids } from '../../../pubUtils/playerCe';
import { calculatetopLineup } from '../../../pubUtils/playerCe';
import { PvpDefenseModel } from '../../../db/PvpDefense';
import { checkTaskWithHero, checkTask, checkActivityTask } from '../../../services/taskService';
import { EquipModel, EquipType } from '../../../db/Equip';
import { checkEquipCanPut } from '../../../services/equipService';
import { pick } from 'underscore';
export default function (app: Application) {

View File

@@ -1,5 +1,4 @@
import { GachaData, Floor, GachaResult, Hope, GachaListReturn } from "../../domain/activityField/gachaField";;
import { ActivityModel } from "../../db/Activity";
import { DicGacha } from "../../pubUtils/dictionary/DicGacha";
import { UserGachaType, UserGachaModel } from "../../db/UserGacha";
import { shouldRefresh, getRandEelm, getRandEelmWithWeight } from "../../pubUtils/util";
@@ -221,15 +220,11 @@ export class GachaPull {
} else {
let pool: number[] = [];
if (type == GACHA_CONTENT_TYPE.HERO_PIECE) {
pool = getAllItemByQuality(IT_TYPE.HERO_PIECE, param[0], this.lv);
} else if (type == GACHA_CONTENT_TYPE.BLUEPRT) {
pool = getAllItemByQuality(IT_TYPE.BLUEPRT, param[0], this.lv);
pool = getAllItemByQuality(IT_TYPE.HERO_PIECE, param[0]);
} else if (type == GACHA_CONTENT_TYPE.JEWEL) {
pool = getAllJewelByLv(param[0]);
} else if (type == GACHA_CONTENT_TYPE.TERAPH_MATERIAL) {
pool = param;
} else if (type == GACHA_CONTENT_TYPE.SUIT_PAPER) {
pool = getSuitPaper(this.lv);
}
if(pool.length <= 0) {
@@ -497,11 +492,11 @@ export function getAllHeroByQuality(quality: number) {
return allHero;
}
function getAllItemByQuality(itid: number, quality: number, lv: number) {
function getAllItemByQuality(itid: number, quality: number) {
let allPiece: number[] = [];
for (let [id, dicGoods] of gameData.goods) {
if (dicGoods.itid == itid) {
if ((quality == 0 || dicGoods.quality == quality) && dicGoods.lvLimited <= lv) {
if (quality == 0 || dicGoods.quality == quality) {
allPiece.push(id);
}
}
@@ -510,67 +505,9 @@ function getAllItemByQuality(itid: number, quality: number, lv: number) {
}
function getAllJewelByLv(lv: number) {
let itids: number[] = [];
for (let [id, { type }] of ITID) {
if (type == CONSUME_TYPE.JEWEL) itids.push(id);
}
let items: number[] = [];
for (let [id, dicGoods] of gameData.goods) {
if (itids.includes(dicGoods.itid)) {
if (lv == 0 || dicGoods.lvLimited == lv) {
items.push(id);
}
}
for(let [id, dicStone] of gameData.stone) {
if(dicStone.lv >= lv) items.push(id);
}
return items;
}
function getSuitPaper(lv: number) {
let items: number[] = [];
for (let [id, dicGoods] of gameData.goods) {
if (dicGoods.itid == IT_TYPE.PAPER) {
if (dicGoods.lvLimited <= lv) {
items.push(id);
}
}
}
return items;
}
/**
* 根据contentId获得抽卡结果 新武将抽卡活动
* @param contentId dic_zyz_gachaContent的id
* @param lv 玩家等级
* @param goodId 大于0指定id0:随机
*/
export function getResultFromContentIdNewHeroActivity(contentId: number, goodId: number, lv: number,) {
let dic = gameData.gachaContent.get(contentId);
let { type, param, count } = dic;
if (type == GACHA_CONTENT_TYPE.HERO) {
let result = new GachaResult(contentId);
result.setHero(goodId);
return result
} else {
let pool: number[] = [];
if (type == GACHA_CONTENT_TYPE.HERO_PIECE) {
pool = getAllItemByQuality(IT_TYPE.HERO_PIECE, param[0], lv);
} else if (type == GACHA_CONTENT_TYPE.BLUEPRT) {
pool = getAllItemByQuality(IT_TYPE.BLUEPRT, param[0], lv);
} else if (type == GACHA_CONTENT_TYPE.JEWEL) {
pool = getAllJewelByLv(param[0]);
} else if (type == GACHA_CONTENT_TYPE.TERAPH_MATERIAL) {
pool = param;
} else if (type == GACHA_CONTENT_TYPE.SUIT_PAPER) {
pool = getSuitPaper(lv);
}
let item = getRandEelm(pool);
let result = new GachaResult(contentId);
result.setItem(item[0], count);
if (goodId > 0) {
result.setItem(goodId, count);
}
return result;
}
}

View File

@@ -1,153 +1,9 @@
import { mergeSameGoods, getRandEelm, getRandValueByMinMax } from '../pubUtils/util';
import { EquipModel, RandMain } from "../db/Equip";
import { EPlace, HeroModel, HeroType, Stone } from "../db/Hero";
import { getGoodById, gameData, getQuenchGradeByValue, getQuenchConsume, getQuenchByQualityAndGrade } from "../pubUtils/data";
import { calPlayerCeAndSave } from "./playerCeService";
import { CONSUME_TYPE, HERO_SYSTEM_TYPE, ITID, TASK_TYPE } from "../consts";
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 { getRandEelm, } from '../pubUtils/util';
import { EPlace, Stone } from "../db/Hero";
import { gameData } from "../pubUtils/data";
import { JewelType, RandSe } from '../db/Jewel';
import { getJewelRandSe } from '../pubUtils/itemUtils';
/**
* 校验前端传入的消耗数量是否准确并返回消耗的道具并加上特殊材料needConsumes
* @param consumes
* @param jewel
* @param jewelCount
*/
export function checkMaterialEnough(consumes: Array<{ id: number, count: number }>, jewel: number, jewelCount: number) {
let comJewelMap = new Map<number, number>(); // good_id => count
let needConsumes:{ id: number, count: number }[] = []
for(let {id, count} of consumes) {
if(!comJewelMap.has(id)) {
comJewelMap.set(id, count);
} else {
comJewelMap.set(id, comJewelMap.get(id) + count);
}
}
function checkCurMeterial(target: number, targetCount: number) {
let dic = getGoodById(target);
if(!dic) return false;
let { composeMaterial } = dic;
let isEnough = true;
for(let { id, count } of composeMaterial) {
let consumeCount = comJewelMap.get(id)||0;
let dicGood = getGoodById(id);
if(!dicGoods) { isEnough = false; break; }
let dicItid = ITID.get(dicGood.itid);
if(dicItid.type != CONSUME_TYPE.JEWEL) {
if(consumeCount < count * targetCount) {
isEnough = false; break;
} else {
comJewelMap.set(id, consumeCount - count * targetCount);
needConsumes.push({ id, count: count * targetCount });
}
} else {
if(consumeCount < count * targetCount) {
comJewelMap.set(id, 0);
needConsumes.push({ id, count: consumeCount });
isEnough = checkCurMeterial(id, count * targetCount - consumeCount);
} else {
comJewelMap.set(id, consumeCount - count * targetCount);
needConsumes.push({ id, count: count * targetCount });
}
}
}
return isEnough
}
let isEnough = checkCurMeterial(jewel, jewelCount);
return isEnough? needConsumes: false;
}
export function checkEquipCanPut(hero: HeroType, id: number) {
let hid = hero.skinId;
let dicGood = gameData.goods.get(id);
if(dicGood.lvLimited > hero.lv) return false;
let dicHero = gameData.hero.get(hid);
if(dicGood.jobLimited.indexOf(0) == -1 && dicGood.jobLimited.indexOf(dicHero.jobClass) == -1) return false;
if(dicGood.charLimited.indexOf(0) == -1 && dicGood.charLimited.indexOf(hid) == -1) return false;
return true
}
/**
* 淬火一次
* @param roleId 玩家id
* @param sid 玩家sid
* @param randMain 装备上的属性随机值
* @param dicQuench 淬火表
* @param dicGoods 物品表
* @returns
*/
export async function quenchOnce(randMain: RandMain[], dicQuench: DicQuenchQuality, dicGoods: DicGoods) {
let { quality, equipLvl } = dicGoods;
let canRandMain = randMain.filter(cur => { // 已升满的属性就不再淬火了
return cur.rand < dicQuench.singleRatioMax;
});
let randMainResult = getRandEelm(canRandMain);
if(randMainResult.length == 0) return false;
let add = new Map<number, number>(); // id => value增加的数量
let isCriticle = Math.random() * 100 < dicQuench.critProbability; // 暴击
let addAttr = isCriticle? dicQuench.critEffect * QUENCH.QUENCH_UNIT_UPRATIO: QUENCH.QUENCH_UNIT_UPRATIO;
let overAttr = randMainResult[0].rand + addAttr - dicQuench.singleRatioMax; // 如果有暴击,超出当前品相上限时
if(overAttr > 0) { // 超出,转到另一条属性
let anotherRandMain = canRandMain.filter(cur => {
return cur.id != randMainResult[0].id;
});
if(anotherRandMain.length > 0) {
let anotherOverAttr = anotherRandMain[0].rand + overAttr - dicQuench.singleRatioMax;
if(anotherOverAttr > 0) {
add.set(anotherRandMain[0].id, overAttr - anotherOverAttr);
} else {
add.set(anotherRandMain[0].id, overAttr);
}
}
add.set(randMainResult[0].id, addAttr - overAttr);
} else {
add.set(randMainResult[0].id, addAttr);
}
let value = 0;
for(let r of randMain) {
if(add.has(r.id)) {
r.rand += add.get(r.id);
}
value += r.rand;
}
let grade = getQuenchGradeByValue(quality, value/2);
// 消耗
let consumes = getQuenchConsume(equipLvl, quality);
let log = new QuenchLogParam(isCriticle, add);
return { randMain, grade, log, consumes };
}
/**
* 检查该品相是否到顶
* @param quality 品质
* @param grade 品相
* @param randMain 装备上的随机值
* @returns
*/
export function checkQuenchMaxByQualityAndGrade(quality: number, grade: number, randMain: RandMain[]) {
let isMax = true;
let dic = getQuenchByQualityAndGrade(quality, grade);
if(!dic) return true;
for(let { rand } of randMain) {
if(rand < dic.max) isMax = false;
}
return isMax;
}
export function getRandSeResult(id: number, randSe: RandSe[]) {
let { randomEffect, effectCount } = gameData.jewel.get(id);
@@ -178,38 +34,6 @@ export function getRandSeResult(id: number, randSe: RandSe[]) {
return newRandSe
}
export async function refineOnce(lv: number, refineLv: number) {
let dicRefine = gameData.refine.get(refineLv + 1);
if (!dicRefine) return false;
if(lv < dicRefine.levelLimited) return false;
return {
refineLv: refineLv + 1,
consumes: dicRefine.consume
}
}
export function checkRefineReachNextLv(oldRefineLv: number, refineLv: number) {
let oldDic = gameData.refine.get(oldRefineLv);
let dic = gameData.refine.get(refineLv);
if(!oldDic || !dic) return true;
return dic.level > oldDic.level;
}
export function calEquipCe(goodsAbility: Map<number, number>, randMain: RandMain[]) {
let ce = 0;
for(let [ id, ratio ] of gameData.equipAttributeRatio) {
let valueBase = goodsAbility.get(id);
let curRand = randMain.find(cur => cur.id == id);
let valueRand = curRand?curRand.rand: 0;
ce += Math.floor(valueBase * valueRand * ratio / 100);
}
return ce
}
export function updateStone(origin: Stone[], id: number, target: number) {
let newStones: Stone[] = [];
let hasTarget = false;

View File

@@ -1021,7 +1021,7 @@ export async function setRankRedisFromDb(type: string, args?: { serverId?: numbe
} else if (type == REDIS_KEY.HERO_RANK) {
let serverId = args.serverId;
for (let hid of gameData.dicMyHeroes) {
for (let { actorId: hid } of gameData.recruit) {
let ranks = await HeroModel.getRank(hid, serverId, HERO_SELECT.RANK_LINEUP);
let r = new Rank(type, { serverId, hid });
r.setIsInit(true);

View File

@@ -1,9 +1,8 @@
import { ITID, CONSUME_TYPE, ITEM_TABLE, REDIS_KEY, TASK_TYPE, CURRENCY, CURRENCY_TYPE, MAIL_TYPE, HANDLE_REWARD_TYPE, HERO_SYSTEM_TYPE, CURRENCY_BY_TYPE, ITEM_CHANGE_REASON, TA_USERSET_TYPE, TA_EVENT } from './../consts';
import { EquipModel, EquipType } from './../db/Equip';
import { ITID, CONSUME_TYPE, ITEM_TABLE, CURRENCY, CURRENCY_TYPE, MAIL_TYPE, HANDLE_REWARD_TYPE, HERO_SYSTEM_TYPE, CURRENCY_BY_TYPE, ITEM_CHANGE_REASON, TA_USERSET_TYPE, TA_EVENT } from './../consts';
import { getRandSingleEelm, resResult } from '../pubUtils/util';
import { RoleModel, RoleType } from '../db/Role';
import { setAp } from './actionPointService';
import { pushCalPlayerCe, pushCalAllHeroCe, calPlayerCeAndSave } from './playerCeService';
import { pushCalAllHeroCe, calPlayerCeAndSave } from './playerCeService';
import { ItemModel, ItemType } from '../db/Item';
import { STATUS } from '../consts/statusCode';
import { pinus } from 'pinus';
@@ -14,13 +13,12 @@ import { uniq } from 'underscore';
import { EPlace, HeroModel, HeroType, HeroUpdate } from '../db/Hero';
import { Figure } from '../domain/dbGeneral';
import { Rank } from './rankService';
import { checkActivityTask, checkTaskWithHero, pushActivityUpdate, pushTaskUpdate } from './taskService';
import { pushTaskUpdate } from './taskService';
import { CreateHeroParam, HeroShowParam } from '../domain/roleField/hero';
import { HeroSkin } from '../db/Hero';
import { errlogger } from '../util/logger';
import { BAG } from '../pubUtils/dicParam';
import { sendMailByContent } from './mailService';
import { calEquipSeids } from '../pubUtils/playerCe';
import { CreateHeroes } from '../pubUtils/roleUtil';
import { SkinUpdate } from '../db/Skin';
import { getInitHeroById } from './roleService';
@@ -541,6 +539,10 @@ export async function checkHeroes(roleId: string, hids: number[]) {
return true
}
export async function checkHeroEquips(roleId: string, quality: number) {
return await HeroModel.checkEquipByQuality(roleId, quality);
}
export async function unlockFigure(sid: string, roleId: string, conditions: { type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number, paramWinStreakNum?: number }[], role?: RoleType) {
let figureInfo = await pubUnlockFigure(roleId, conditions, role);
await pushFigureUpdate(roleId, sid, figureInfo);

View File

@@ -1,5 +1,3 @@
import { EquipType } from './../db/Equip';
import { EPlace, HeroType } from '../db/Hero';
import { GuildType } from '../db/Guild';
import { CHANNEL_PREFIX, HERO_GROW_MAX, HERO_INITIAL_QUALITY, MSG_SOURCE, MSG_TYPE, ON_GROUP_MSG_ROUTE, STATUS, WAR_TYPE } from '../consts';

View File

@@ -5,14 +5,13 @@ import { resResult, shouldRefresh } from '../pubUtils/util';
import { STATUS, TASK_TYPE, TASK_FUN_TYPE, SHOP_REFRESH_TYPE, WAR_TYPE } from '../consts';
import { TaskParam, TaskListReturn } from '../domain/roleField/task';
import { HeroType } from '../db/Hero';
import { EquipType } from '../db/Equip';
import { getRoleOnlineInfo } from './redisService';
import { HeroScores } from '../db/PvpHistoryOpp';
import { ItemInter } from '../pubUtils/interface';
import { UserTaskModel, UserTaskType } from '../db/UserTask';
import { UserTaskRecModel } from '../db/UserTaskRec';
import { UserTaskHistoryModel } from '../db/UserTaskHistory';
import { gameData, getGoodById } from '../pubUtils/data';
import { gameData } from '../pubUtils/data';
import { getSeconds, getZeroPointD } from '../pubUtils/timeUtil';
import { RoleStatus } from '../db/ComBattleTeam';
import { getActivities } from './activity/activityService';
@@ -35,10 +34,10 @@ export async function checkTaskWithHero(roleId: string, sid: string, taskType: n
pushTaskUpdate(roleId, sid, pushMessage);
}
export async function checkTaskWithEquip(roleId: string, sid: string, taskType: number, equip: EquipType, args?: number[]) {
let pushMessage = await taskUtil.checkTaskWithEquip(roleId, taskType, equip, args);
pushTaskUpdate(roleId, sid, pushMessage);
}
// export async function checkTaskWithEquip(roleId: string, sid: string, taskType: number, equip: EquipType, args?: number[]) {
// let pushMessage = await taskUtil.checkTaskWithEquip(roleId, taskType, equip, args);
// pushTaskUpdate(roleId, sid, pushMessage);
// }
export async function checkTaskWithArgs(roleId: string, sid: string, taskType: number, args: number[]) {
let pushMessage = await taskUtil.checkTaskWithArgs(roleId, taskType, args);

View File

@@ -709,10 +709,10 @@ export const GACHA_TO_FLOOR = new Map([
export enum GACHA_CONTENT_TYPE {
HERO = 1, // 武将 param为武将品质
HERO_PIECE = 2, // 武将碎片 武将品质
BLUEPRT = 3, // 藏宝图 藏宝图品质
// BLUEPRT = 3, // 藏宝图 藏宝图品质
JEWEL = 4, // 宝石 宝石等级
TERAPH_MATERIAL = 5, // 强化神像用的材料 材料物品id
SUIT_PAPER = 6, // 套装图纸
// SUIT_PAPER = 6, // 套装图纸
}
export const GACHA_OCCUPY_HID = 9999; // 抽卡里占位的武将

View File

@@ -1,234 +0,0 @@
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
import { COUNTER } from '../consts';
import { CounterModel } from './Counter';
import { HeroModel } from './Hero';
import { RoleModel } from './Role';
import { SearchEquipParam } from '../domain/backEndField/search';
export class RandSe {
@prop({ required: true })
id: number; // 随机属性位置id
@prop({ required: true })
seid: number; // 随机属性池id
@prop({ required: true })
rand: number; // 随机属性内需要随机的值
@prop({ required: true })
locked: boolean; // 洗炼是否锁定
}
export class Holes {
@prop({ required: true })
id: number; // 孔的id
@prop({ required: true })
isOpen: boolean; // 是否开孔
@prop({ required: true })
jewel: number; // 装备的宝石id
}
export class RandMain {
@prop({ required: true })
id: number; // 随机属性位置id
@prop({ required: true })
rand: number; // 随机属性内需要随机的值扩大100倍
}
@index({ roleId: 1, hid: 1, id: 1 })
@index({ seqId: 1 })
@modelOptions({ schemaOptions: { id: false } })
export default class Equip extends BaseModel {
@prop({ required: true })
roleId: string; // 角色 id
@prop({ required: true })
roleName: string; // 角色名称
@prop({ required: true })
seqId: number; // 装备表自增 id
@prop({ required: true })
id: number; // 装备 id
@prop({ required: true })
name: string; // 装备名称
@prop({ required: false, default: 0 })
hid: number; // 装备此装备的武将 id
@prop({ required: false, default: 0 })
ePlaceId: number; // 武将装备的部位
@prop({ required: false, default: 1 })
count: number; // 装备数量
@prop({ required: true, default: 1 })
quality: number; // 品质
@prop({ required: true, default: 0 })
suitId: number; // 套装id
@prop({ required: true, default: 0 })
randRange: number; // 固定属性随机值 // TODO 废弃字段,客户端改完之前暂时保留
@prop({ required: false, type: RandMain, default: [], _id: false })
randMain: RandMain[]; // 主属性随机
@prop({ required: true, default: 0 })
grade: number; // 品相等级
@prop({ required: false, type: RandSe, default: [], _id: false })
randSe: RandSe[]; // 强化随机属性
@prop({ required: true, type: Holes, default: [], _id: false })
holes: Holes[];
@prop({ required: false, type: RandSe, default: [], _id: false })
previewRandSe: RandSe[]; // 强化随机属性预览
public static async findbyRole(roleId: string, lean = true) {
const equips: EquipType[] = await EquipModel.find({ roleId }).lean(lean);
return equips;
}
public static async findbySeqId(seqId: number, select?: string ) {
const equip: EquipType = await EquipModel.findOne({ seqId }).select(select).lean();
return equip;
}
public static async createEquip(equipInfo: equipUpdate, lean = true) {
const seqId = await CounterModel.getNewCounter(COUNTER.EID);
const doc = new EquipModel();
const update = Object.assign(doc.toJSON(), seqId, equipInfo);
const equip: EquipType = await EquipModel.findOneAndUpdate({ seqId }, update, { upsert: true, new: true }).lean(lean);
if (equipInfo.hid > 0) {
await HeroModel.findOneAndUpdate(
{ roleId: equipInfo.roleId, hid: equipInfo.hid, 'ePlace.id': equipInfo.ePlaceId },
{ $set: { 'ePlace.$.equip': equip._id } },
{ new: true }).lean(lean);
}
return equip;
}
public static async createEquips(roleId: string, equipInfos: equipUpdate[]) {
let result: EquipType[] = [];
for(let equipInfo of equipInfos) {
let equip = await this.createEquip(equipInfo);
result.push(equip);
}
await RoleModel.increaseJewel(roleId, result.length);
return result;
}
public static async putOnOrOff(equipId: string, hid: number, lean = true) {
const equip: EquipType = await EquipModel.findOneAndUpdate({ _id: equipId }, { hid }, { new: true }).lean(lean);
return equip;
}
public static async findNotWearEquips(roleId: string) {
const equips: EquipType[] = await EquipModel.find({ roleId, hid: 0 }).lean();
return equips;
}
public static async deleteAccount(roleId: string) {
let result = await EquipModel.deleteMany({ roleId });
return result;
}
public static async deleteEquips(roleId: string, ids: Array<number>) {
let equips = await EquipModel.getEquips(roleId, ids);
await EquipModel.deleteMany({ roleId, seqId: { $in: ids } });
await RoleModel.findOneAndUpdate({ roleId }, { $inc: { equipCount: -1 * ids.length } }, { new: true });
return equips;
}
public static async getEquipsByID(ids: Array<string>) {
let result = await EquipModel.find({ _id: { $in: ids } });
return result;
}
public static async getEquips(roleId: string, ids: Array<number>) {
let result: EquipType[] = await EquipModel.find({ roleId, seqId: { $in: ids } });
return result;
}
public static async getEquip(seqId: number) {
let equip: EquipType = await EquipModel.findOne({ seqId });
return equip;
}
public static async updateEquipInfo(seqId: number, equipUpdate: equipUpdate, lean = true) {
delete equipUpdate._id;
let result: EquipType = await EquipModel.findOneAndUpdate({ seqId }, { $set: equipUpdate }, { new: true }).lean(lean);
return result;
}
public static async lock(roleId: string, seqId: number, id: number, lock: boolean) {
let result: EquipType = await EquipModel.findOneAndUpdate({ roleId, seqId, 'randSe.id': id }, { $set: { 'randSe.$.locked': lock } }, { new: true, upsert: false }).select('seqId id randSe').lean();
return result;
}
public static async updateEquipInfobyObjectId(_id: string, equipUpdate: equipUpdate, lean = true) {
delete equipUpdate._id;
let result: EquipType = await EquipModel.findOneAndUpdate({ _id }, { $set: equipUpdate }, { new: true }).lean(lean);
return result;
}
public static async getEquipByObjectId(_id: string) {
let equip: EquipType = await EquipModel.findOne({ _id });
return equip;
}
public static async findByField(field: string, value?: number | string, select?: string) {
let searchObj = {};
if (field != 'all') {
if (field == 'roleName') {
searchObj['roleName'] = { $regex: new RegExp(value.toString(), 'i') }
} else {
searchObj[field] = value;
}
}
//.select('uid tel username')
const user: EquipType[] = await EquipModel.find(searchObj).select(select).lean();
return user;
}
public static async findListByHidAndRole(roleId: string, hid: number, select?: string) {
let result: EquipType[] = await EquipModel.find({ roleId, hid }).select(select).lean();
return result;
}
public static async getEquipsByIds(roleId: string, ids: Array<number>) {
let result = await EquipModel.find({ roleId, id: { $in: ids } });
return result;
}
private static getSearchObj(form: SearchEquipParam) {
let searchObj = {};
if(form.roleId) searchObj['roleId'] = form.roleId;
if(form.roleName) searchObj['roleName'] = { $regex: new RegExp(form.roleName.toString(), 'i') };
if(form.id) searchObj['id'] = form.id;
return searchObj
}
public static async findByCondition(page: number, pageSize: number, sortField: string = 'updatedAt', sortOrder: string = 'descend', form: SearchEquipParam = {}) {
let searchObj = this.getSearchObj(form);
let sort = {};
if(sortField && sortOrder) {
if(sortOrder == 'ascend') {
sort[sortField] = 1;
} else if (sortOrder == 'descend') {
sort[sortField] = -1;
}
}
const result: EquipType[] = await EquipModel.find(searchObj).limit(pageSize).skip((page - 1) * pageSize).sort(sort).lean({ getters: true, virtuals: true });
return result;
}
public static async countByCondition(form: SearchEquipParam = {}) {
let searchObj = this.getSearchObj(form);
const result = await EquipModel.count(searchObj);
return result;
}
}
export const EquipModel = getModelForClass(Equip);
export interface EquipType extends Pick<DocumentType<Equip>, keyof Equip> {
id: number;
};
export type equipUpdate = Partial<EquipType>; // 将所有字段变成可选项

View File

@@ -205,6 +205,11 @@ export default class Hero extends BaseModel {
return hero;
}
public static async checkEquipByQuality(roleId: string, quality: number) {
const result = await HeroModel.exists({ roleId, 'ePlace.quality': { $gte: quality } });
return result;
}
public static async findMapByHidRange(hids: Array<number>, roleId: string, select?: string, getters = false) {
const hero = await HeroModel.findByHidRange(hids, roleId, select, getters);
let map = new Map<number, HeroType>();

View File

@@ -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();

View File

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

View File

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

View File

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

View File

@@ -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[] }>();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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 角色

View File

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

View File

@@ -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-私聊

View File

@@ -2,7 +2,6 @@
{
"id": 1,
"itid": 25,
"starLevel": "&",
"quality": 1,
"honourReward": 40,
"__EMPTY": 0,
@@ -13,7 +12,6 @@
{
"id": 2,
"itid": 25,
"starLevel": "&",
"quality": 2,
"honourReward": 80,
"__EMPTY": 0,
@@ -24,7 +22,6 @@
{
"id": 3,
"itid": 25,
"starLevel": "&",
"quality": 3,
"honourReward": 200,
"__EMPTY": 0,
@@ -34,8 +31,7 @@
},
{
"id": 4,
"itid": 40,
"starLevel": 1,
"itid": 41,
"quality": 1,
"honourReward": 20,
"__EMPTY": 0,
@@ -45,8 +41,7 @@
},
{
"id": 5,
"itid": 40,
"starLevel": 1,
"itid": 41,
"quality": 2,
"honourReward": 50,
"__EMPTY": 0,
@@ -56,8 +51,7 @@
},
{
"id": 6,
"itid": 40,
"starLevel": 1,
"itid": 41,
"quality": 3,
"honourReward": 70,
"__EMPTY": 0,
@@ -67,8 +61,7 @@
},
{
"id": 7,
"itid": 40,
"starLevel": 1,
"itid": 41,
"quality": 4,
"honourReward": 80,
"__EMPTY": 0,
@@ -78,8 +71,7 @@
},
{
"id": 8,
"itid": 40,
"starLevel": 2,
"itid": 41,
"quality": 1,
"honourReward": 40,
"__EMPTY": 0,
@@ -89,8 +81,7 @@
},
{
"id": 9,
"itid": 40,
"starLevel": 2,
"itid": 41,
"quality": 2,
"honourReward": 80,
"__EMPTY": 0,
@@ -100,8 +91,7 @@
},
{
"id": 10,
"itid": 40,
"starLevel": 2,
"itid": 41,
"quality": 3,
"honourReward": 90,
"__EMPTY": 0,
@@ -111,8 +101,7 @@
},
{
"id": 11,
"itid": 40,
"starLevel": 2,
"itid": 41,
"quality": 4,
"honourReward": 110,
"__EMPTY": 0,
@@ -122,8 +111,7 @@
},
{
"id": 12,
"itid": 40,
"starLevel": 3,
"itid": 41,
"quality": 1,
"honourReward": 70,
"__EMPTY": 0,
@@ -133,8 +121,7 @@
},
{
"id": 13,
"itid": 40,
"starLevel": 3,
"itid": 41,
"quality": 2,
"honourReward": 100,
"__EMPTY": 0,
@@ -144,8 +131,7 @@
},
{
"id": 14,
"itid": 40,
"starLevel": 3,
"itid": 41,
"quality": 3,
"honourReward": 130,
"__EMPTY": 0,
@@ -155,8 +141,7 @@
},
{
"id": 15,
"itid": 40,
"starLevel": 3,
"itid": 41,
"quality": 4,
"honourReward": 140,
"__EMPTY": 0,
@@ -166,8 +151,7 @@
},
{
"id": 16,
"itid": 40,
"starLevel": 4,
"itid": 41,
"quality": 1,
"honourReward": 120,
"__EMPTY": 0,
@@ -177,8 +161,7 @@
},
{
"id": 17,
"itid": 40,
"starLevel": 4,
"itid": 41,
"quality": 2,
"honourReward": 160,
"__EMPTY": 0,
@@ -188,8 +171,7 @@
},
{
"id": 18,
"itid": 40,
"starLevel": 4,
"itid": 41,
"quality": 3,
"honourReward": 190,
"__EMPTY": 0,
@@ -199,8 +181,7 @@
},
{
"id": 19,
"itid": 40,
"starLevel": 4,
"itid": 41,
"quality": 4,
"honourReward": 210,
"__EMPTY": 0,
@@ -210,8 +191,7 @@
},
{
"id": 20,
"itid": 40,
"starLevel": 5,
"itid": 41,
"quality": 1,
"honourReward": 150,
"__EMPTY": 0,
@@ -221,8 +201,7 @@
},
{
"id": 21,
"itid": 40,
"starLevel": 5,
"itid": 41,
"quality": 2,
"honourReward": 200,
"__EMPTY": 0,
@@ -232,8 +211,7 @@
},
{
"id": 22,
"itid": 40,
"starLevel": 5,
"itid": 41,
"quality": 3,
"honourReward": 220,
"__EMPTY": 0,
@@ -243,8 +221,7 @@
},
{
"id": 23,
"itid": 40,
"starLevel": 5,
"itid": 41,
"quality": 4,
"honourReward": 240,
"__EMPTY": 0,
@@ -254,8 +231,7 @@
},
{
"id": 24,
"itid": 40,
"starLevel": 6,
"itid": 41,
"quality": 1,
"honourReward": 170,
"__EMPTY": 0,
@@ -265,8 +241,7 @@
},
{
"id": 25,
"itid": 40,
"starLevel": 6,
"itid": 41,
"quality": 2,
"honourReward": 230,
"__EMPTY": 0,
@@ -276,8 +251,7 @@
},
{
"id": 26,
"itid": 40,
"starLevel": 6,
"itid": 41,
"quality": 3,
"honourReward": 260,
"__EMPTY": 0,
@@ -287,8 +261,7 @@
},
{
"id": 27,
"itid": 40,
"starLevel": 6,
"itid": 41,
"quality": 4,
"honourReward": 330,
"__EMPTY": 0,

View File

@@ -25,7 +25,7 @@
"count": "1&5",
"free": "1&1",
"cost": "22002&1",
"percent": "4&5|5&15|6&15|7&10|8&10|9&15|10&10|13&5|14&10|15&5",
"percent": "4&5|5&15|6&15|7&15|8&15|9&15|10&10|11&10",
"floorReward": 1,
"indirectId": 2
},

View File

@@ -29,83 +29,48 @@
},
{
"id": 5,
"name": "适用等级蓝色藏宝图",
"type": 3,
"name": "随机一阶地玉",
"type": 4,
"param": "1&",
"count": 4
},
{
"id": 6,
"name": "适用等级紫色藏宝图",
"type": 3,
"name": "随机二级地玉",
"type": 4,
"param": "2&",
"count": 3
},
{
"id": 7,
"name": "适用等级橙色藏宝图",
"type": 3,
"name": "随机三级地玉",
"type": 4,
"param": "3&",
"count": 2
},
{
"id": 8,
"name": "适用等级红色藏宝图",
"type": 3,
"name": "随机四级地玉",
"type": 4,
"param": "4&",
"count": 1
},
{
"id": 9,
"name": "随机一级宝石",
"type": 4,
"param": "1&",
"count": 4
},
{
"id": 10,
"name": "随机二级宝石",
"type": 4,
"param": "2&",
"count": 3
},
{
"id": 11,
"name": "随机三级宝石",
"type": 4,
"param": "3&",
"count": 2
},
{
"id": 12,
"name": "随机四级宝石",
"type": 4,
"param": "4&",
"count": 1
},
{
"id": 13,
"name": "适用等级的套装图纸",
"type": 6,
"param": "&",
"count": 1
},
{
"id": 14,
"name": "武将碎片 * 5",
"type": 2,
"param": "0&",
"count": 5
},
{
"id": 15,
"id": 10,
"name": "武将碎片 *10",
"type": 2,
"param": "0&",
"count": 10
},
{
"id": 16,
"id": 11,
"name": "强化神像素材",
"type": 5,
"param": "17054&",