✨ feat(稷下学宫): 添加圣物效果升级特性卡推送
This commit is contained in:
@@ -152,7 +152,7 @@ export class HandleAddCard {
|
||||
let charasMap = (this.addCharas || []).reduce((result, cur) => { result.set(cur.charaCode, cur); return result; }, new Map<string, RougelikeCharaPara>());
|
||||
let cardsMap = [...(this.addPassiveCards || []), ...(this.addHolyCards || [])].reduce((result, cur) => { result.set(cur.cardCode, cur); return result; }, new Map<string, RougelikeCardPara>());
|
||||
if ((this.addHolyCards || []).length > 0) {
|
||||
let rougeEffect = new RougeEffect(this.roleId, this.gameCode);
|
||||
let rougeEffect = new RougeEffect(this.roleId, this.gameCode, this.sid);
|
||||
let holyIds = clone(this.addHolyCards.map(cur => { return { cardCode: cur.cardCode, cardId: cur.cardId, useCount: cur.useCount } }));
|
||||
|
||||
let { charas, cards } = await rougeEffect.getEffectImmediate(holyIds);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ABI_TYPE } from "../../consts/constModules/abilityConst";
|
||||
import { ROUGELIKE_SKILLTYPE, ROUGE_EFFECT_TYPE, ROUGE_EFFECT_TYPE_KIND, ROUGE_LIKE_CARD_TYPE, ROUGE_SLOT_LIMIT } from "../../consts";
|
||||
import { PUSH_ROUTE, ROUGELIKE_SKILLTYPE, ROUGE_EFFECT_TYPE, ROUGE_EFFECT_TYPE_KIND, ROUGE_LIKE_CARD_TYPE, ROUGE_SLOT_LIMIT } from "../../consts";
|
||||
import { RougelikeCardModel, RougelikeCardPara, RougelikeCardType } from "../../db/RougelikeCard";
|
||||
import { Card, RougelikeCharaModel, RougelikeCharaPara, RougelikeCharaType } from "../../db/RougelikeChara";
|
||||
import { RougelikeRecordModel } from "../../db/RougelikeRecord";
|
||||
@@ -10,6 +10,7 @@ import { RougelikeTechModel } from "../../db/RougelikeTech";
|
||||
import { getAuthorTypeCardNum } from "./rougeService";
|
||||
import * as util from 'util';
|
||||
import { DicRougePassiveCard } from "../../pubUtils/dictionary/DicRougePassiveCard";
|
||||
import { sendMessageToUserWithSuc } from "../pushService";
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +24,7 @@ export class holyId {
|
||||
export class RougeEffect {
|
||||
roleId: string;
|
||||
gameCode: string;
|
||||
sid: string;
|
||||
newEffect: { effectType: number, effectParam: number[], cardCode?: string }[] = [];
|
||||
holyMap = new Map<string, { cardCode: string, cardId: number, useCount: number }>();
|
||||
updateHolyMap = new Map<string, RougelikeCardType>();
|
||||
@@ -31,9 +33,10 @@ export class RougeEffect {
|
||||
dbCharas: RougelikeCharaType[] = [];
|
||||
dbCards: RougelikeCardType[] = [];
|
||||
|
||||
constructor(roleId: string, gameCode: string) {
|
||||
constructor(roleId: string, gameCode: string, sid?: string) {
|
||||
this.roleId = roleId || '';
|
||||
this.gameCode = gameCode || '';
|
||||
this.sid = sid || '';
|
||||
|
||||
}
|
||||
|
||||
@@ -185,28 +188,33 @@ export class RougeEffect {
|
||||
|
||||
// 随机升级X个已装备的特性 2006
|
||||
private async getRandomCardLv() {
|
||||
let cards: RougelikeCardType[] = [];
|
||||
if (this.newEffect.length == 0 || this.dbCards.length == 0) return cards;
|
||||
if (this.newEffect.length == 0 || this.dbCards.length == 0) return;
|
||||
let pushCards: RougelikeCardType[] = [];
|
||||
for (const { effectParam, effectType, cardCode } of this.newEffect) {
|
||||
if (effectType != ROUGE_EFFECT_TYPE.HOLY_PASSIVE_UPDATE_RAND) continue;
|
||||
if (effectParam.length == 0) continue;
|
||||
if (!getHolyCardIsUse(this.holyMap.get(cardCode))) continue;
|
||||
const randomNum = effectParam[0] || 0;
|
||||
let random = this.dbCards.filter(cur => cur.type == ROUGE_LIKE_CARD_TYPE.PASSIVE && cur.charaId && cur.charaId != 0 && cur.lv < (gameData.rougePassiveCard.get(cur.cardId)?.lv || 0))
|
||||
for (let cur of this.dbCards) {
|
||||
if (cur.type != ROUGE_LIKE_CARD_TYPE.PASSIVE || cur.charaId == 0) continue;
|
||||
let random = this.dbCards.filter(cur => cur.type == ROUGE_LIKE_CARD_TYPE.PASSIVE && cur.charaId && cur.charaId != 0);
|
||||
let newRandom: RougelikeCardType[] = [];
|
||||
for (let cur of random) {
|
||||
// if (cur.type != ROUGE_LIKE_CARD_TYPE.PASSIVE || cur.charaId == 0) continue;
|
||||
let passiveCardDataMap = this.getPassiveData(cur.cardId);
|
||||
if (!passiveCardDataMap.has(cur.lv + 1)) continue;
|
||||
random.push({ ...cur, cardId: passiveCardDataMap.get(cur.lv + 1).id, lv: cur.lv + 1 })
|
||||
newRandom.push({ ...cur, cardId: passiveCardDataMap.get(cur.lv + 1).id, lv: cur.lv + 1 });
|
||||
}
|
||||
|
||||
if (random && random.length > 0) {
|
||||
let cards = getRandEelm(random, randomNum);
|
||||
if (newRandom && newRandom.length > 0) {
|
||||
let cards = getRandEelm(newRandom, randomNum);
|
||||
cards.forEach(async cur => { this.updateCardMap.set(cur.cardCode, cur), await this.updateCharaCards(cur, cardCode, cur.cardId); });
|
||||
pushCards.push(...cards);
|
||||
|
||||
this.updateHolyMapUseCount(this.holyMap.get(cardCode));
|
||||
}
|
||||
}
|
||||
if(pushCards.length > 0){
|
||||
await sendMessageToUserWithSuc(this.roleId, PUSH_ROUTE.ROUGE_PASSIVE_CARD_UP_LV, { upLvCards: pushCards }, this.sid);
|
||||
}
|
||||
}
|
||||
|
||||
private getPassiveData(cardId: number) {
|
||||
@@ -222,6 +230,7 @@ export class RougeEffect {
|
||||
// 获得该圣物时立即升级所有X星特性卡 2012
|
||||
private async getPassiveLv() {
|
||||
if (this.newEffect.length == 0) return;
|
||||
let pushCards: RougelikeCardType[] = [];
|
||||
for (const { effectParam, effectType, cardCode } of this.newEffect) {
|
||||
if (effectType != ROUGE_EFFECT_TYPE.HOLY_UPDATE_PASSIVE_BY_LV) continue;
|
||||
if (effectParam.length == 0) continue;
|
||||
@@ -235,6 +244,7 @@ export class RougeEffect {
|
||||
if (!passiveCardDataMap.has(lv + 1)) continue;
|
||||
let id = passiveCardDataMap.get(lv + 1).id;
|
||||
this.updateCardMap.set(cardCode, { ...val, lv: lv + 1, cardId: passiveCardDataMap.get(lv + 1).id });
|
||||
pushCards.push({ ...val, lv: lv + 1, cardId: passiveCardDataMap.get(lv + 1).id });
|
||||
|
||||
if (val.charaId && val.charaId > 0) {
|
||||
await this.updateCharaCards(val, cardCode, id);
|
||||
@@ -244,6 +254,9 @@ export class RougeEffect {
|
||||
}
|
||||
if (isUseCount) this.updateHolyMapUseCount(this.holyMap.get(cardCode));
|
||||
}
|
||||
if(pushCards.length > 0){
|
||||
await sendMessageToUserWithSuc(this.roleId, PUSH_ROUTE.ROUGE_PASSIVE_CARD_UP_LV, { upLvCards: pushCards }, this.sid);
|
||||
}
|
||||
}
|
||||
|
||||
private async updateCharaCards(val: RougelikeCardType, cardCode: string, id: number) {
|
||||
@@ -350,7 +363,7 @@ export class RougeEffect {
|
||||
this.updateHolyMapUseCount(this.holyMap.get(cardCode));
|
||||
|
||||
}
|
||||
|
||||
|
||||
return addRatio;
|
||||
}
|
||||
|
||||
@@ -661,9 +674,9 @@ export async function checkCanReRandomReward(roleId: string, gameCode: string, r
|
||||
}
|
||||
|
||||
|
||||
export function getHolyCardIsUse(holy: { cardId: number, useCount: number, cardCode:string}) {
|
||||
export function getHolyCardIsUse(holy: { cardId: number, useCount: number, cardCode: string }) {
|
||||
const { useCount = 0, cardId, cardCode } = (holy || {});
|
||||
if(!cardCode) return true;//法阵不存在cardCode
|
||||
if (!cardCode) return true;//法阵不存在cardCode
|
||||
if (!cardId) return;
|
||||
const holyCardData = gameData.rougeHolyCard.get(cardId)
|
||||
if (!holyCardData) return;
|
||||
|
||||
@@ -214,5 +214,6 @@ export const PUSH_ROUTE = {
|
||||
GVG_REC_ADD: 'onGVGRecAdd', // 动态更新
|
||||
ROUGE_COLLECT_UPDATE: 'onRougeCollectUpdate', // 更新图鉴
|
||||
ROUGE_CHALLENGE_UPDATE: 'onRougeChallengeUpdate', //更新学宫挑战进度
|
||||
ROUGE_PASSIVE_CARD_UP_LV:'onRougePassiveCardUpLv', // 升级特性卡
|
||||
LADDER_OR_GVG_ICON_SHOW: 'onLadderOrGvgIconShow', //名将擂台icon提示
|
||||
}
|
||||
Reference in New Issue
Block a user