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