✨ feat(稷下学宫): c67747d87到5ff932e83
This commit is contained in:
@@ -9,6 +9,7 @@ import { getRandEelm } from "../../pubUtils/util";
|
||||
import { RougelikeTechModel } from "../../db/RougelikeTech";
|
||||
import { getAuthorTypeCardNum } from "./rougeService";
|
||||
import * as util from 'util';
|
||||
import { DicRougePassiveCard } from "../../pubUtils/dictionary/DicRougePassiveCard";
|
||||
|
||||
|
||||
|
||||
@@ -98,6 +99,7 @@ export class RougeEffect {
|
||||
ROUGE_EFFECT_TYPE.HOLY_PASSIVE_UPDATE_RAND, //2006
|
||||
ROUGE_EFFECT_TYPE.HOLY_UPDATE_PASSIVE_BY_LV, //2012
|
||||
ROUGE_EFFECT_TYPE.HOLY_REPAIRE_HOLY, //2015
|
||||
ROUGE_EFFECT_TYPE.HOLY_CHARA_SLOT_UNLOCK_POINT,//2023
|
||||
], holyIds)
|
||||
|
||||
await this.getCharaSlot();
|
||||
@@ -110,6 +112,8 @@ export class RougeEffect {
|
||||
|
||||
await this.getRecoveryHoly();
|
||||
|
||||
await this.getSlotUnlockPoint()
|
||||
|
||||
result = { charas: this.updateCharaMap, cards: this.updateCardMap };
|
||||
|
||||
return result;
|
||||
@@ -119,9 +123,14 @@ export class RougeEffect {
|
||||
// 获得该圣物时,所有学员立刻解锁X个特性槽 2002
|
||||
private async getCharaSlot() {
|
||||
if (this.newEffect.length == 0 || this.dbCharas.length == 0) return;
|
||||
for (const { effectParam, effectType } of this.newEffect) {
|
||||
for (const { effectParam, effectType, cardCode } of this.newEffect) {
|
||||
if (effectType != ROUGE_EFFECT_TYPE.HOLY_CHARA_SLOT_UNLOCK_ALL) continue;
|
||||
if (effectParam.length == 0) continue;
|
||||
let isUseCount = false;
|
||||
console.log("xx-x-x-x-x-x-x-x-11111-x-xx-x-x- cardCode", cardCode)
|
||||
console.log("xx-x-x-x-x-x-x-x-11111-x-xx-x-x- this.holyMap", this.holyMap)
|
||||
if (!getHolyCardIsUse(this.holyMap.get(cardCode))) continue;
|
||||
console.log("xx-x-x-x-x-x-x-x--x-xx-x-x- this.holyMap", this.holyMap)
|
||||
for (let val of this.dbCharas) {
|
||||
let { charaCode, cards = [] } = val;
|
||||
let unlockNum = effectParam[0] || 0;
|
||||
@@ -133,18 +142,32 @@ export class RougeEffect {
|
||||
cards.push({ index, cardCode: '', cardId: 0 });
|
||||
this.updateCharaMap.set(charaCode, val);
|
||||
unlockNum--;
|
||||
isUseCount = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isUseCount) this.updateHolyMapUseCount(this.holyMap.get(cardCode));
|
||||
}
|
||||
}
|
||||
|
||||
private updateHolyMapUseCount(holy: { cardCode: string, cardId: number, useCount: number }) {
|
||||
let { cardCode, useCount = 0, cardId } = (holy || {});
|
||||
if (!cardId || !cardCode) return;
|
||||
let val = this.dbCards.find(cur => cur.cardCode == cardCode);
|
||||
if (val == undefined) return;
|
||||
useCount = (useCount + 1) >= 0 ? (useCount + 1) : 0
|
||||
this.updateCardMap.set(cardCode, { ...val, useCount });
|
||||
this.holyMap.set(cardCode, { cardCode, cardId, useCount });
|
||||
}
|
||||
|
||||
// 获得该圣物时,随机解锁X个学员的Y个特性槽 2003
|
||||
private async getRandCharaSlot() {
|
||||
if (this.newEffect.length == 0 || this.dbCharas.length == 0) return;
|
||||
for (const { effectParam, effectType } of this.newEffect) {
|
||||
for (const { effectParam, effectType, cardCode } of this.newEffect) {
|
||||
if (effectType != ROUGE_EFFECT_TYPE.HOLY_CHARA_SLOT_UNLOCK_RAND) continue;
|
||||
if (effectParam.length == 0) continue;
|
||||
let isUseCount = false;
|
||||
if (!getHolyCardIsUse(this.holyMap.get(cardCode))) continue;
|
||||
const randomNum = effectParam[0] || 0;
|
||||
let unlockNum = effectParam[1] || 0;
|
||||
let charas = getRandEelm(this.dbCharas.filter(cur => cur.cards.length < ROUGE_SLOT_LIMIT), randomNum);
|
||||
@@ -156,8 +179,10 @@ export class RougeEffect {
|
||||
cards.push({ index, cardCode: '', cardId: 0 });
|
||||
this.updateCharaMap.set(charaCode, val);
|
||||
unlockNum--;
|
||||
isUseCount = true;
|
||||
}
|
||||
}
|
||||
if (isUseCount) this.updateHolyMapUseCount(this.holyMap.get(cardCode));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,61 +190,129 @@ export class RougeEffect {
|
||||
private async getRandomCardLv() {
|
||||
let cards: RougelikeCardType[] = [];
|
||||
if (this.newEffect.length == 0 || this.dbCards.length == 0) return cards;
|
||||
for (const { effectParam, effectType } of this.newEffect) {
|
||||
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 != 0 && cur.lv < (gameData.rougePassiveCard.get(cur.cardId)?.lv || 0))
|
||||
let cards = getRandEelm(random, randomNum);
|
||||
cards.forEach(cur => {
|
||||
cur.lv += 1;
|
||||
this.updateCardMap.set(cur.cardCode, cur);
|
||||
});
|
||||
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 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 })
|
||||
}
|
||||
|
||||
if (random && random.length > 0) {
|
||||
let cards = getRandEelm(random, randomNum);
|
||||
cards.forEach(async cur => { this.updateCardMap.set(cur.cardCode, cur), await this.updateCharaCards(cur, cardCode, cur.cardId); });
|
||||
|
||||
this.updateHolyMapUseCount(this.holyMap.get(cardCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private getPassiveData(cardId: number) {
|
||||
let passiveCardDataMap = new Map<number, DicRougePassiveCard>()
|
||||
const passiveCardData = gameData.rougePassiveCard.get(cardId);
|
||||
if (!passiveCardData) return passiveCardDataMap;
|
||||
const passiveCardByGroupData = gameData.rougePassiveCardByGroup.get(passiveCardData.group || 0);
|
||||
if (passiveCardByGroupData.length == 0 || passiveCardByGroupData.length == 1) return passiveCardDataMap;
|
||||
passiveCardDataMap = passiveCardByGroupData.reduce((result, cur) => { result.set(cur.lv, cur); return result; }, new Map<number, DicRougePassiveCard>());
|
||||
return passiveCardDataMap;
|
||||
}
|
||||
|
||||
// 获得该圣物时立即升级所有X星特性卡 2012
|
||||
private async getPassiveLv() {
|
||||
if (this.newEffect.length == 0) return;
|
||||
for (const { effectParam, effectType } of this.newEffect) {
|
||||
for (const { effectParam, effectType, cardCode } of this.newEffect) {
|
||||
if (effectType != ROUGE_EFFECT_TYPE.HOLY_UPDATE_PASSIVE_BY_LV) continue;
|
||||
if (effectParam.length == 0) continue;
|
||||
let isUseCount = false;
|
||||
if (!getHolyCardIsUse(this.holyMap.get(cardCode))) continue;
|
||||
const level = effectParam[0] || 0;
|
||||
for (let val of this.dbCards) {
|
||||
let { lv, cardId, cardCode } = val;
|
||||
const passiveCardData = gameData.rougePassiveCard.get(cardId);
|
||||
if (level != passiveCardData?.quality || 0 || lv >= passiveCardData?.lv || 0) continue;
|
||||
lv += 1;
|
||||
this.updateCardMap.set(cardCode, val);
|
||||
if (lv != level) continue;
|
||||
let passiveCardDataMap = this.getPassiveData(cardId);
|
||||
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 });
|
||||
|
||||
if (val.charaId && val.charaId > 0) {
|
||||
await this.updateCharaCards(val, cardCode, id);
|
||||
}
|
||||
|
||||
isUseCount = true;
|
||||
}
|
||||
if (isUseCount) this.updateHolyMapUseCount(this.holyMap.get(cardCode));
|
||||
}
|
||||
}
|
||||
|
||||
private async updateCharaCards(val: RougelikeCardType, cardCode: string, id: number) {
|
||||
for (let obj of this.dbCharas) {
|
||||
if (obj.charaId != val.charaId) continue;
|
||||
for (let card of (obj.cards || [])) {
|
||||
if (card.cardCode != cardCode) continue;
|
||||
card.cardId = id;
|
||||
}
|
||||
this.updateCharaMap.set(obj.charaCode, obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 获得该圣物时,随机修复X个已损毁的圣物 2015
|
||||
private async getRecoveryHoly() {
|
||||
if (this.newEffect.length == 0) return;
|
||||
for (const { effectParam, effectType } of this.newEffect) {
|
||||
for (const { effectParam, effectType, cardCode } of this.newEffect) {
|
||||
if (effectType != ROUGE_EFFECT_TYPE.HOLY_REPAIRE_HOLY) continue;
|
||||
if (effectParam.length == 0) continue;
|
||||
let isUseCount = false;
|
||||
if (!getHolyCardIsUse(this.holyMap.get(cardCode))) continue;
|
||||
const num = effectParam[0] || 0;
|
||||
let canRandomCards: RougelikeCardType[] = []
|
||||
this.dbCards.forEach(cur => {
|
||||
const { cardCode, cardId, useCount = 0, type } = cur;
|
||||
const holyCardData = gameData.rougeHolyCard.get(cardId);
|
||||
let tempUseCount = holyCardData?.useCount || 0;
|
||||
if (tempUseCount > 0 && useCount < tempUseCount && type == ROUGE_LIKE_CARD_TYPE.HOLY) canRandomCards.push(cur);
|
||||
if (tempUseCount > 0 && useCount > 0 && type == ROUGE_LIKE_CARD_TYPE.HOLY) canRandomCards.push(cur);
|
||||
})
|
||||
|
||||
let randomCards = getRandEelm(canRandomCards, num);
|
||||
for (let val of randomCards) {
|
||||
let { cardCode, cardId } = val;
|
||||
val.useCount += 1;
|
||||
// if (this.holyMap.has(cardCode)) this.holyMap.set(cardCode, { cardCode, cardId, useCount });
|
||||
this.updateCardMap.set(cardCode, val)
|
||||
val.useCount -= 1;
|
||||
this.updateCardMap.set(cardCode, val);
|
||||
|
||||
if (this.holyMap.has(cardCode)) this.holyMap.set(cardCode, { cardCode, cardId, useCount: val.useCount });
|
||||
isUseCount = true;
|
||||
}
|
||||
|
||||
if (isUseCount) this.updateHolyMapUseCount(this.holyMap.get(cardCode));
|
||||
}
|
||||
}
|
||||
|
||||
//2023
|
||||
private async getSlotUnlockPoint() {
|
||||
if (this.newEffect.length == 0) return;
|
||||
for (const { effectParam, effectType, cardCode } of this.newEffect) {
|
||||
if (effectType != ROUGE_EFFECT_TYPE.HOLY_CHARA_SLOT_UNLOCK_POINT) continue;
|
||||
if (effectParam.length == 0) continue;
|
||||
let isUseCount = false;
|
||||
if (!getHolyCardIsUse(this.holyMap.get(cardCode))) continue;
|
||||
const num = effectParam[0] || 0;
|
||||
const index = effectParam[0] || 0;
|
||||
for (let val of this.dbCharas) {
|
||||
let { cards = [], charaCode } = val
|
||||
if (cards.find(cur => cur.index == index) == undefined) {
|
||||
cards.push({ index, cardCode: '', cardId: 0 });
|
||||
this.updateCharaMap.set(charaCode, val);
|
||||
isUseCount = true;
|
||||
}
|
||||
}
|
||||
if (isUseCount) this.updateHolyMapUseCount(this.holyMap.get(cardCode));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 和圣物相关maxhp
|
||||
@@ -235,6 +328,9 @@ export class RougeEffect {
|
||||
|
||||
addRatio += await this.getMaxHpByBase();
|
||||
|
||||
|
||||
await updateCards([...this.updateCardMap.values()]);
|
||||
|
||||
return addRatio;
|
||||
}
|
||||
|
||||
@@ -244,7 +340,8 @@ export class RougeEffect {
|
||||
const dbRecord = await RougelikeRecordModel.findByGameCode(this.gameCode);
|
||||
let coinTotal = dbRecord?.coin || 0;
|
||||
if (this.newEffect.length == 0) return addRatio;
|
||||
for (const { effectParam, effectType } of this.newEffect) {
|
||||
for (const { effectParam, effectType, cardCode } of this.newEffect) {
|
||||
if (!getHolyCardIsUse(this.holyMap.get(cardCode))) continue;
|
||||
if (effectType != ROUGE_EFFECT_TYPE.HOLY_CHARA_MAIN_ATTR_UP_BY_COIN) continue;
|
||||
if (effectParam.length == 0) continue;
|
||||
const count = effectParam[0] || 0;
|
||||
@@ -252,6 +349,9 @@ export class RougeEffect {
|
||||
const value = effectParam[2] || 0;
|
||||
if (count == 0 || id != ABI_TYPE.ABI_HP || value == 0) continue;
|
||||
addRatio += Math.floor(coinTotal / count * value)
|
||||
|
||||
this.updateHolyMapUseCount(this.holyMap.get(cardCode));
|
||||
|
||||
}
|
||||
|
||||
return addRatio;
|
||||
@@ -261,13 +361,15 @@ export class RougeEffect {
|
||||
private async getMaxHpByBase() {
|
||||
let addRatio = 0;
|
||||
if (this.newEffect.length == 0) return addRatio;
|
||||
for (const { effectParam, effectType } of this.newEffect) {
|
||||
for (const { effectParam, effectType, cardCode } of this.newEffect) {
|
||||
if (effectType != ROUGE_EFFECT_TYPE.HOLY_CHARA_MAIN_ATTR_UP && effectType != ROUGE_EFFECT_TYPE.TECH_CHARA_MAIN_ATTR_UP) continue;
|
||||
if (effectParam.length == 0) continue;
|
||||
if (!getHolyCardIsUse(this.holyMap.get(cardCode))) continue;
|
||||
const id = effectParam[0] || 0;
|
||||
const value = effectParam[1] || 0;
|
||||
if (id != ABI_TYPE.ABI_HP || value == 0) continue;
|
||||
addRatio += value;
|
||||
this.updateHolyMapUseCount(this.holyMap.get(cardCode));
|
||||
}
|
||||
return addRatio;
|
||||
}
|
||||
@@ -283,9 +385,11 @@ export async function getCharaHp(roleId: string, gameCode: string) {
|
||||
ROUGE_EFFECT_TYPE.HOLY_CHARA_HP_RECOVERY_UP,// 2001
|
||||
]);
|
||||
if (newEffect.length == 0) return hpRatio;
|
||||
for (const { effectType, effectParam } of newEffect) {
|
||||
for (const { effectType, effectParam, cardCode } of newEffect) {
|
||||
if (effectParam.length == 0) continue;
|
||||
if (!getHolyCardIsUse(holyMap.get(cardCode))) continue;
|
||||
hpRatio += (effectParam[0] || 0);
|
||||
await updateHolyUseCount(holyMap.get(cardCode), gameCode)
|
||||
}
|
||||
return hpRatio;
|
||||
}
|
||||
@@ -300,17 +404,19 @@ export async function getAddCoin(roleId: string, gameCode: string, nodeType: num
|
||||
ROUGE_EFFECT_TYPE.TECH_COIN_UP_BY_NODE_TYPE, //3007
|
||||
]);
|
||||
if (newEffect.length == 0) return { coinRatio, coinAdd };
|
||||
for (const { effectType, effectParam } of newEffect) {
|
||||
for (const { effectType, effectParam, cardCode } of newEffect) {
|
||||
if (effectParam.length == 0) continue;
|
||||
if (!getHolyCardIsUse(holyMap.get(cardCode))) continue;
|
||||
if (effectType == ROUGE_EFFECT_TYPE.HOLY_COIN_UP) {
|
||||
const type = effectParam[0] || 0;
|
||||
const value = effectParam[1] || 0;
|
||||
if (type == 1) coinAdd += value;
|
||||
else if (type == 2) coinRatio += value;
|
||||
await updateHolyUseCount(holyMap.get(cardCode), gameCode)
|
||||
}
|
||||
if (effectType == ROUGE_EFFECT_TYPE.TECH_COIN_UP_BY_NODE_TYPE) {
|
||||
let [targetNodeType = 0, value = 0] = effectParam;
|
||||
if (targetNodeType == nodeType) coinRatio += value;
|
||||
let [value = 0, ...targetNodeType] = effectParam;
|
||||
if (targetNodeType && targetNodeType.includes(nodeType)) coinRatio += value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -318,7 +424,6 @@ export async function getAddCoin(roleId: string, gameCode: string, nodeType: num
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 获得圣物后,X流派特性卡的权重增加Y 2007
|
||||
export async function getAddPassiveWeight(roleId: string, gameCode: string, authorType: number) {
|
||||
let addPassiveWeight = 0;
|
||||
@@ -327,12 +432,14 @@ export async function getAddPassiveWeight(roleId: string, gameCode: string, auth
|
||||
ROUGE_EFFECT_TYPE.HOLY_PASSIVE_WEIGHT_UP_BY_AUTHOR,//2007
|
||||
]);
|
||||
if (newEffect.length == 0) return addPassiveWeight;
|
||||
for (const { effectParam } of newEffect) {
|
||||
for (const { effectParam, cardCode } of newEffect) {
|
||||
if (effectParam.length == 0) continue;
|
||||
if (!getHolyCardIsUse(holyMap.get(cardCode))) continue;
|
||||
const type = effectParam[0] || 0;
|
||||
const value = effectParam[1] || 0;
|
||||
if (type != authorType) continue;
|
||||
addPassiveWeight += value;
|
||||
await updateHolyUseCount(holyMap.get(cardCode), gameCode)
|
||||
}
|
||||
return addPassiveWeight;
|
||||
}
|
||||
@@ -344,6 +451,12 @@ export async function getNoBossRecoveryHp(roleId: string, gameCode: string) {
|
||||
ROUGE_EFFECT_TYPE.HOLY_REVIVE_ALL,//2009
|
||||
]);
|
||||
if (newEffect.length == 0) return false;
|
||||
for (const { effectParam, cardCode } of newEffect) {
|
||||
if (!getHolyCardIsUse(holyMap.get(cardCode))) continue;
|
||||
await updateHolyUseCount(holyMap.get(cardCode), gameCode)
|
||||
}
|
||||
|
||||
|
||||
return true; // 拿到true 将所有学员更新和hp=maxHp
|
||||
}
|
||||
|
||||
@@ -357,9 +470,11 @@ export async function getBattleRecoveryNum(roleId: string, gameCode: string) {
|
||||
]);
|
||||
if (newEffect.length == 0) return recoveryNum;
|
||||
|
||||
for (const { effectParam } of newEffect) {
|
||||
for (const { effectParam, cardCode } of newEffect) {
|
||||
if (effectParam.length == 0) continue;
|
||||
if (!getHolyCardIsUse(holyMap.get(cardCode))) continue;
|
||||
recoveryNum += (effectParam[0] || 0)
|
||||
await updateHolyUseCount(holyMap.get(cardCode), gameCode)
|
||||
}
|
||||
return recoveryNum;
|
||||
}
|
||||
@@ -373,10 +488,12 @@ export async function getShopDiscount(roleId: string, gameCode: string) {
|
||||
ROUGE_EFFECT_TYPE.HOLY_SHOP_DISCOUNT,//2011
|
||||
]);
|
||||
if (newEffect.length == 0) return discount;
|
||||
for (const { effectParam } of newEffect) {
|
||||
for (const { effectParam, cardCode } of newEffect) {
|
||||
if (effectParam.length == 0) continue;
|
||||
if (!getHolyCardIsUse(holyMap.get(cardCode))) continue;
|
||||
const tempDiscount = effectParam[0] || 0;
|
||||
discount *= (tempDiscount / 100);
|
||||
await updateHolyUseCount(holyMap.get(cardCode), gameCode)
|
||||
}
|
||||
return Math.floor(discount);
|
||||
}
|
||||
@@ -390,15 +507,20 @@ export async function getChooseQualityPassives(roleId: string, gameCode: string,
|
||||
ROUGE_EFFECT_TYPE.HOLY_PASSIVE_CHOOSE_FIX,//2013
|
||||
]);
|
||||
if (newEffect.length == 0) return targetPassives;
|
||||
for (const { effectParam } of newEffect) {
|
||||
for (const { effectParam, cardCode } of newEffect) {
|
||||
let isUseCount = false;
|
||||
if (effectParam.length == 0) continue;
|
||||
if (!getHolyCardIsUse(holyMap.get(cardCode))) continue;
|
||||
const level = effectParam[0] || 0;
|
||||
for (let val of passiveCards) {
|
||||
const { cardId } = val;
|
||||
const passiveCardData = gameData.rougePassiveCard.get(cardId);
|
||||
if (level != passiveCardData?.lv || 0) continue;
|
||||
targetPassives.push(val);
|
||||
isUseCount = true;
|
||||
}
|
||||
if (isUseCount) await updateHolyUseCount(holyMap.get(cardCode), gameCode);
|
||||
|
||||
}
|
||||
return targetPassives;
|
||||
}
|
||||
@@ -410,10 +532,12 @@ export async function getAddChoosePassive(roleId: string, gameCode: string) {
|
||||
let { newEffect, holyMap } = await rougeEffect.getEffectData([
|
||||
ROUGE_EFFECT_TYPE.HOLY_PASSIVE_CHOOSE_NUM_UP,//2014
|
||||
]);
|
||||
for (const { effectParam } of newEffect) {
|
||||
for (const { effectParam, cardCode } of newEffect) {
|
||||
if (effectParam.length == 0) continue;
|
||||
if (!getHolyCardIsUse(holyMap.get(cardCode))) continue;
|
||||
const num = effectParam[0] || 0;
|
||||
addChooseNum += num;
|
||||
await updateHolyUseCount(holyMap.get(cardCode), gameCode);
|
||||
}
|
||||
return addChooseNum
|
||||
}
|
||||
@@ -425,27 +549,26 @@ export async function getSlotUnlockPoint(roleId: string, gameCode: string, dbCha
|
||||
let { newEffect, holyMap } = await rougeEffect.getEffectData([
|
||||
ROUGE_EFFECT_TYPE.HOLY_CHARA_SLOT_UNLOCK_POINT,//2023
|
||||
]);
|
||||
for (const { effectParam } of newEffect) {
|
||||
for (const { effectParam, cardCode } of newEffect) {
|
||||
if (effectParam.length == 0) continue;
|
||||
let isUseCount = false;
|
||||
if (!getHolyCardIsUse(holyMap.get(cardCode))) continue;
|
||||
const index = effectParam[0] || 0;
|
||||
for (let { cards = [] } of dbCharas) {
|
||||
if (cards.length == 0) {
|
||||
cards.push({ index, cardCode: '', cardId: 0 });
|
||||
isUpdate = true;
|
||||
continue;
|
||||
}
|
||||
if (cards.find(cur => cur.index == index) == undefined) {
|
||||
isUpdate = true
|
||||
cards.push({ index, cardCode: '', cardId: 0 });
|
||||
isUseCount = true;
|
||||
}
|
||||
}
|
||||
if (isUseCount) await updateHolyUseCount(holyMap.get(cardCode), gameCode);
|
||||
}
|
||||
|
||||
return { isUpdate, dbCharas };
|
||||
}
|
||||
|
||||
|
||||
// 休整点额外恢复X%的生命 2017 3006
|
||||
// 休整点额外恢复上限X%的生命 2017 3006
|
||||
export async function getRecoveryExtendHp(roleId: string, gameCode: string) {
|
||||
let hpRatio = 0;
|
||||
let rougeEffect = new RougeEffect(roleId, gameCode);
|
||||
@@ -454,9 +577,11 @@ export async function getRecoveryExtendHp(roleId: string, gameCode: string) {
|
||||
ROUGE_EFFECT_TYPE.TECH_RECOVERY_POINT_UP, // 3006
|
||||
]);
|
||||
if (newEffect.length == 0) return hpRatio;
|
||||
for (const { effectType, effectParam } of newEffect) {
|
||||
for (const { effectType, effectParam, cardCode } of newEffect) {
|
||||
if (effectParam.length == 0) continue;
|
||||
if (!getHolyCardIsUse(holyMap.get(cardCode))) continue;
|
||||
hpRatio += (effectParam[0] || 0);
|
||||
await updateHolyUseCount(holyMap.get(cardCode), gameCode);
|
||||
}
|
||||
return hpRatio;
|
||||
}
|
||||
@@ -471,10 +596,13 @@ export async function getTrainCardDiscount(roleId: string, gameCode: string) {
|
||||
ROUGE_EFFECT_TYPE.TECH_TRAIN_POINT_DISCOUNT, // 3009
|
||||
]);
|
||||
if (newEffect.length == 0) return discount;
|
||||
for (const { effectParam } of newEffect) {
|
||||
for (const { effectParam, cardCode } of newEffect) {
|
||||
if (effectParam.length == 0) continue;
|
||||
if (!getHolyCardIsUse(holyMap.get(cardCode))) continue;
|
||||
const tempDiscount = effectParam[0] || 0;
|
||||
discount *= (tempDiscount / 100);
|
||||
await updateHolyUseCount(holyMap.get(cardCode), gameCode);
|
||||
|
||||
}
|
||||
return Math.floor(discount);
|
||||
}
|
||||
@@ -533,4 +661,25 @@ export async function checkCanReRandomReward(roleId: string, gameCode: string, r
|
||||
});
|
||||
if (!curParam) return { canReRandom: false, costCoin: 0 }
|
||||
return { canReRandom: true, costCoin: curParam.effectParam[1] || 0 };
|
||||
}
|
||||
|
||||
|
||||
export function getHolyCardIsUse(holy: { cardId: number, useCount: number }) {
|
||||
const { useCount = 0, cardId } = (holy || {});
|
||||
if (!cardId) return;
|
||||
const holyCardData = gameData.rougeHolyCard.get(cardId)
|
||||
if (!holyCardData) return;
|
||||
if ((holyCardData?.useCount || 0) <= useCount) return;
|
||||
return true
|
||||
}
|
||||
|
||||
export async function updateHolyUseCount(holy: { cardId: number, useCount: number, cardCode: string }, gameCode: string) {
|
||||
const { cardId, cardCode } = (holy || {});
|
||||
if (!cardId || !cardCode) return;
|
||||
await RougelikeCardModel.updateByCode(gameCode, cardCode, { $inc: { useCount: 1 } })
|
||||
}
|
||||
|
||||
export async function updateCards(updateCards: RougelikeCardPara[]) {
|
||||
if (updateCards.length == 0) return;
|
||||
await RougelikeCardModel.bulkWriteUpdate(updateCards)
|
||||
}
|
||||
Reference in New Issue
Block a user