🐞 fix(稷下学宫): 修复hp,maxhp, 休整点强化更新已安装特性卡id,权重展示
This commit is contained in:
@@ -817,7 +817,7 @@ export class RougeHandler {
|
|||||||
|
|
||||||
let dbCard = await RougelikeCardModel.findByCode(gameCode, cardCode);
|
let dbCard = await RougelikeCardModel.findByCode(gameCode, cardCode);
|
||||||
if (!dbCard) return resResult(STATUS.NO_CARD);
|
if (!dbCard) return resResult(STATUS.NO_CARD);
|
||||||
let { type, cardId, charaId, lv = 0 } = dbCard;
|
let { type, cardId, charaId = 0, lv = 0 } = dbCard;
|
||||||
|
|
||||||
const passiveCardData = gameData.rougePassiveCard.get(cardId);
|
const passiveCardData = gameData.rougePassiveCard.get(cardId);
|
||||||
if (!passiveCardData) return resResult(STATUS.NO_CARD);
|
if (!passiveCardData) return resResult(STATUS.NO_CARD);
|
||||||
@@ -855,6 +855,21 @@ export class RougeHandler {
|
|||||||
const newDbCard = await RougelikeCardModel.updateByCode(gameCode, cardCode, { $set: { cardId: id }, $inc: { lv: 1 } });
|
const newDbCard = await RougelikeCardModel.updateByCode(gameCode, cardCode, { $set: { cardId: id }, $inc: { lv: 1 } });
|
||||||
const cards: CommonCard[] = formateCharasOrCards([newDbCard], ROUGE_LIKE_CARD_TYPE.PASSIVE)?.cards || [];
|
const cards: CommonCard[] = formateCharasOrCards([newDbCard], ROUGE_LIKE_CARD_TYPE.PASSIVE)?.cards || [];
|
||||||
|
|
||||||
|
if (charaId > 0) {
|
||||||
|
const dbCharas = await RougelikeCharaModel.findByGameCodeAndCharaId(gameCode, charaId);
|
||||||
|
let isEnd = false;
|
||||||
|
for (let { cards = [], charaCode } of dbCharas) {
|
||||||
|
for (let obj of cards) {
|
||||||
|
if (cardCode != obj.cardCode) continue;
|
||||||
|
obj.cardId = id;
|
||||||
|
await RougelikeCharaModel.findOneAndUpdate({ gameCode, charaCode, 'cards.cardCode': cardCode }, { 'cards.$.cardId': cardId }, { new: true, upsert: true }).lean(true);
|
||||||
|
isEnd = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (isEnd) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, { restPoints, cards, reward: { rewards }, redCoin: -realConsume, })
|
return resResult(STATUS.SUCCESS, { restPoints, cards, reward: { rewards }, redCoin: -realConsume, })
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import { clone } from 'underscore';
|
|||||||
import { RougeEffect, getSlotUnlockPoint } from './rougeEffectService';
|
import { RougeEffect, getSlotUnlockPoint } from './rougeEffectService';
|
||||||
import { BackendSession } from 'pinus';
|
import { BackendSession } from 'pinus';
|
||||||
import { checkTask } from '../task/taskService';
|
import { checkTask } from '../task/taskService';
|
||||||
|
import { RougelikeRecordModel } from '../../db/RougelikeRecord';
|
||||||
|
import { updateMaxHp } from './rougeService';
|
||||||
|
|
||||||
export class HandleAddCard {
|
export class HandleAddCard {
|
||||||
roleId: string;
|
roleId: string;
|
||||||
@@ -120,11 +122,11 @@ export class HandleAddCard {
|
|||||||
passiveCardMap.set(passiveCardData.authorType, count + 1);
|
passiveCardMap.set(passiveCardData.authorType, count + 1);
|
||||||
}
|
}
|
||||||
for (const [authorType, count] of passiveCardMap) {
|
for (const [authorType, count] of passiveCardMap) {
|
||||||
await checkTask(this.serverId, this.roleId, this.sid, TASK_TYPE.ROUGE_AUTHOR_CARD_COLLECT, { authorType, cardType: TASK_ROUGE_CARD_TYPE.PASSIVE, cardIds:this.addPassiveCards.map(cur => cur.cardId) });
|
await checkTask(this.serverId, this.roleId, this.sid, TASK_TYPE.ROUGE_AUTHOR_CARD_COLLECT, { authorType, cardType: TASK_ROUGE_CARD_TYPE.PASSIVE, cardIds: this.addPassiveCards.map(cur => cur.cardId) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.addHolyCards.length > 0) {
|
if (this.addHolyCards.length > 0) {
|
||||||
await checkTask(this.serverId, this.roleId, this.sid, TASK_TYPE.ROUGE_HOLY_COLLECT, {cardIds:this.addHolyCards.map(cur => cur.cardId)});
|
await checkTask(this.serverId, this.roleId, this.sid, TASK_TYPE.ROUGE_HOLY_COLLECT, { cardIds: this.addHolyCards.map(cur => cur.cardId) });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.addCharas.length > 0) {
|
if (this.addCharas.length > 0) {
|
||||||
@@ -166,6 +168,8 @@ export class HandleAddCard {
|
|||||||
result.addCharas = [...charasMap.values()].map(param => new CommonChara(param));
|
result.addCharas = [...charasMap.values()].map(param => new CommonChara(param));
|
||||||
result.addCards = [...cardsMap.values()].map(param => new CommonCard(param));
|
result.addCards = [...cardsMap.values()].map(param => new CommonCard(param));
|
||||||
|
|
||||||
|
const dbRecord = await RougelikeRecordModel.findByGameCode(this.gameCode);
|
||||||
|
result.addCharas = await updateMaxHp(this.roleId, this.gameCode, (dbRecord?.type || 0), (dbRecord?.grade || 0), charasMap)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,10 +127,7 @@ export class RougeEffect {
|
|||||||
if (effectType != ROUGE_EFFECT_TYPE.HOLY_CHARA_SLOT_UNLOCK_ALL) continue;
|
if (effectType != ROUGE_EFFECT_TYPE.HOLY_CHARA_SLOT_UNLOCK_ALL) continue;
|
||||||
if (effectParam.length == 0) continue;
|
if (effectParam.length == 0) continue;
|
||||||
let isUseCount = false;
|
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;
|
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) {
|
for (let val of this.dbCharas) {
|
||||||
let { charaCode, cards = [] } = val;
|
let { charaCode, cards = [] } = val;
|
||||||
let unlockNum = effectParam[0] || 0;
|
let unlockNum = effectParam[0] || 0;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { clone, result } from "underscore";
|
import { clone, result } from "underscore";
|
||||||
import { ROUGE_CHARA_INITIAL, ROUGE_CHARA_TYPE, ROUGE_EFFECT_TYPE, ROUGE_LIKE_CARD_TYPE, ROUGE_LIKE_CHOOSE_REWARD, ROUGE_LIKE_NODE_TYPE, ROUGE_LIKE_STATUS, SHOP_REFRESH_TYPE } from "../../consts";
|
import { ROUGE_CHARA_INITIAL, ROUGE_CHARA_TYPE, ROUGE_EFFECT_TYPE, ROUGE_LIKE_CARD_TYPE, ROUGE_LIKE_CHOOSE_REWARD, ROUGE_LIKE_NODE_TYPE, ROUGE_LIKE_STATUS, SHOP_REFRESH_TYPE } from "../../consts";
|
||||||
import { Card, RougelikeCharaModel, RougelikeCharaType } from "../../db/RougelikeChara";
|
import { Card, RougelikeCharaModel, RougelikeCharaPara, RougelikeCharaType } from "../../db/RougelikeChara";
|
||||||
import { RougelikeLayerModel, RougelikeLayerType } from "../../db/RougelikeLayer";
|
import { RougelikeLayerModel, RougelikeLayerType } from "../../db/RougelikeLayer";
|
||||||
import { RougelikeRecordModel, RougelikeRecordType } from "../../db/RougelikeRecord";
|
import { RougelikeRecordModel, RougelikeRecordType } from "../../db/RougelikeRecord";
|
||||||
import { gameData } from "../../pubUtils/data";
|
import { gameData } from "../../pubUtils/data";
|
||||||
@@ -299,8 +299,8 @@ export async function chooseNode(dbRecord: RougelikeRecordType, layerChooseNode:
|
|||||||
reward = result;
|
reward = result;
|
||||||
dbPara.rewards = result.rewards;
|
dbPara.rewards = result.rewards;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isDevelopEnv){
|
if (isDevelopEnv) {
|
||||||
weightRecords = dbPara.weightRecords = (result?.weightRecords || []);
|
weightRecords = dbPara.weightRecords = (result?.weightRecords || []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -311,7 +311,7 @@ export async function chooseNode(dbRecord: RougelikeRecordType, layerChooseNode:
|
|||||||
let { coin, score, tech } = layerRewardData;
|
let { coin, score, tech } = layerRewardData;
|
||||||
reward = { rewards: dbDetail.rewards || [], score: score || 0, techScore: tech || 0, takeoutReward: layerPlanData.takeoutReward || [] };
|
reward = { rewards: dbDetail.rewards || [], score: score || 0, techScore: tech || 0, takeoutReward: layerPlanData.takeoutReward || [] };
|
||||||
|
|
||||||
if(isDevelopEnv){
|
if (isDevelopEnv) {
|
||||||
weightRecords = dbDetail.weightRecords
|
weightRecords = dbDetail.weightRecords
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -603,7 +603,7 @@ export async function getPassiveCardPlan(passiveCardPlan: number, passiveCardRan
|
|||||||
if (!passiveCardData) continue;
|
if (!passiveCardData) continue;
|
||||||
const getLimit = cardsMap.get(cardId) || 0;
|
const getLimit = cardsMap.get(cardId) || 0;
|
||||||
if (getLimit >= (passiveCardData?.getLimit || 0)) continue; //处理限制获取数量
|
if (getLimit >= (passiveCardData?.getLimit || 0)) continue; //处理限制获取数量
|
||||||
|
|
||||||
weightRecord.originalWight = weight;
|
weightRecord.originalWight = weight;
|
||||||
|
|
||||||
if (chooseCardsMap.has(cardId)) {
|
if (chooseCardsMap.has(cardId)) {
|
||||||
@@ -739,12 +739,14 @@ export async function getHolyCardPlan(holyCardPlan: number, holyCardRandomNum: n
|
|||||||
}
|
}
|
||||||
if (!holyCardData.label) {
|
if (!holyCardData.label) {
|
||||||
newCards.push({ ...obj });
|
newCards.push({ ...obj });
|
||||||
|
weightRecord.finalWeight = weight;
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let labelNum = lableMap.get(holyCardData.label) || 0;
|
let labelNum = lableMap.get(holyCardData.label) || 0;
|
||||||
if (labelNum < ROUGELIKE.HOLY_LABLE_NUM || ROUGELIKE.HOLY_LABLE_NUM == 0) {
|
if (labelNum < ROUGELIKE.HOLY_LABLE_NUM || ROUGELIKE.HOLY_LABLE_NUM == 0) {
|
||||||
newCards.push({ ...obj });
|
newCards.push({ ...obj });
|
||||||
|
weightRecord.finalWeight = weight;
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -938,7 +940,7 @@ export async function getMaxHp(roleId: string, gameCode: string, charaId: number
|
|||||||
return Math.floor(maxHp);
|
return Math.floor(maxHp);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateMaxHp(roleId: string, gameCode: string, type: number, grade: number, updateCharasMap?: Map<string,RougelikeCharaType[]>) {
|
export async function updateMaxHp(roleId: string, gameCode: string, type: number, grade: number, updateCharasMap?: Map<string, RougelikeCharaPara>) {
|
||||||
let dbCharas = await RougelikeCharaModel.findByGameCode(gameCode);
|
let dbCharas = await RougelikeCharaModel.findByGameCode(gameCode);
|
||||||
if (dbCharas.length == 0) return [];
|
if (dbCharas.length == 0) return [];
|
||||||
|
|
||||||
@@ -949,7 +951,9 @@ export async function updateMaxHp(roleId: string, gameCode: string, type: number
|
|||||||
}
|
}
|
||||||
let tempMaxHp = await getMaxHp(roleId, gameCode, val.charaId, type, grade);
|
let tempMaxHp = await getMaxHp(roleId, gameCode, val.charaId, type, grade);
|
||||||
if (tempMaxHp == val.maxHp && updateCharasMap && !updateCharasMap.has(val.charaCode)) continue;
|
if (tempMaxHp == val.maxHp && updateCharasMap && !updateCharasMap.has(val.charaCode)) continue;
|
||||||
|
let preMaxHp = val.maxHp;
|
||||||
val.maxHp = tempMaxHp;
|
val.maxHp = tempMaxHp;
|
||||||
|
val.hp = Math.min(val.hp + tempMaxHp - preMaxHp, tempMaxHp);
|
||||||
result.push(val);
|
result.push(val);
|
||||||
}
|
}
|
||||||
await RougelikeCharaModel.bulkWriteUpdate(result);
|
await RougelikeCharaModel.bulkWriteUpdate(result);
|
||||||
|
|||||||
@@ -71,12 +71,12 @@ export default class RougelikeChara extends BaseModel {
|
|||||||
if (updateArr.length == 0) return [];
|
if (updateArr.length == 0) return [];
|
||||||
let num = await CounterModel.getNewCounterNum(COUNTER.ROUGE_CHARA, updateArr.length);
|
let num = await CounterModel.getNewCounterNum(COUNTER.ROUGE_CHARA, updateArr.length);
|
||||||
let resultArr: RougelikeCharaType[] = [];
|
let resultArr: RougelikeCharaType[] = [];
|
||||||
for(let index = 0; index < updateArr.length; index++) {
|
for (let index = 0; index < updateArr.length; index++) {
|
||||||
let param = updateArr[index];
|
let param = updateArr[index];
|
||||||
let seqId = num - updateArr.length + index + 1;
|
let seqId = num - updateArr.length + index + 1;
|
||||||
const { gameCode, charaCode } = param;
|
const { gameCode, charaCode } = param;
|
||||||
let data = await RougelikeCharaModel.findOneAndUpdate({ gameCode, charaCode }, { $set: { ...param, seqId }}, { new: true, upsert: true }).lean();
|
let data = await RougelikeCharaModel.findOneAndUpdate({ gameCode, charaCode }, { $set: { ...param, seqId } }, { new: true, upsert: true }).lean();
|
||||||
if(data) resultArr.push(data)
|
if (data) resultArr.push(data)
|
||||||
}
|
}
|
||||||
return resultArr
|
return resultArr
|
||||||
}
|
}
|
||||||
@@ -113,6 +113,11 @@ export default class RougelikeChara extends BaseModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async findByGameCodeAndCharaId(gameCode: string, charaId: number, lean = true) {
|
||||||
|
const result: RougelikeCharaType[] = await RougelikeCharaModel.find({ gameCode, charaId }).lean(lean);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static async bulkWriteUpdate(updateArr: RougelikeCharaPara[]) {
|
public static async bulkWriteUpdate(updateArr: RougelikeCharaPara[]) {
|
||||||
if (updateArr.length == 0) return;
|
if (updateArr.length == 0) return;
|
||||||
await RougelikeCharaModel.bulkWrite(updateArr.map((param) => {
|
await RougelikeCharaModel.bulkWrite(updateArr.map((param) => {
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ export class RandomRec {
|
|||||||
@prop({ required: false, default: 0 })
|
@prop({ required: false, default: 0 })
|
||||||
weight?: number; // 权重
|
weight?: number; // 权重
|
||||||
@prop({ required: false, type: WeightRecord, default: {}, _id: false })
|
@prop({ required: false, type: WeightRecord, default: {}, _id: false })
|
||||||
weightRecords?: WeightRecord;
|
weightRecord?: WeightRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Option {
|
export class Option {
|
||||||
|
|||||||
Reference in New Issue
Block a user