排行榜:修复排行榜奖励错误
This commit is contained in:
@@ -7,7 +7,7 @@ import { HeroModel, HeroType, HeroUpdate } from "../db/Hero";
|
|||||||
import { PVPConfigModel } from "../db/SystemConfig";
|
import { PVPConfigModel } from "../db/SystemConfig";
|
||||||
import { PvpDefenseModel } from "../db/PvpDefense";
|
import { PvpDefenseModel } from "../db/PvpDefense";
|
||||||
import { gameData } from "../pubUtils/data";
|
import { gameData } from "../pubUtils/data";
|
||||||
import { nowSeconds } from "../pubUtils/timeUtil";
|
import { getSeconds, nowSeconds } from "../pubUtils/timeUtil";
|
||||||
import { getWorldChannelSid } from "./chatChannelService";
|
import { getWorldChannelSid } from "./chatChannelService";
|
||||||
import { pinus } from "pinus";
|
import { pinus } from "pinus";
|
||||||
import { RankFirstModel, RankFirstType, RankFirstUpdateParam } from "../db/RankFirst";
|
import { RankFirstModel, RankFirstType, RankFirstUpdateParam } from "../db/RankFirst";
|
||||||
@@ -176,7 +176,7 @@ export class Rank {
|
|||||||
* @param hero 武将数据库
|
* @param hero 武将数据库
|
||||||
* @param isInc 得分是累加上的还是直接设置的
|
* @param isInc 得分是累加上的还是直接设置的
|
||||||
*/
|
*/
|
||||||
public async setRankWithHeroInfo(roleId: string, hid: number, score: number, timestamp: number, hero?: HeroType, isInc = true) {
|
public async setRankWithHeroInfo(roleId: string, hid: number, score: number, timestamp: number, hero?: HeroType, isInc = false) {
|
||||||
// 如果没有信息,更新玩家信息
|
// 如果没有信息,更新玩家信息
|
||||||
for (let infoKey of [this.infoKey, ...this.extraKeys]) {
|
for (let infoKey of [this.infoKey, ...this.extraKeys]) {
|
||||||
await this.generParamAndSet(infoKey, { roleId, hid }, { hero });
|
await this.generParamAndSet(infoKey, { roleId, hid }, { hero });
|
||||||
@@ -882,11 +882,13 @@ export class Rank {
|
|||||||
// console.log(rankId, dicRank.id, oldScore, condition, newScore);
|
// console.log(rankId, dicRank.id, oldScore, condition, newScore);
|
||||||
if(dicRank.id == rankId && oldScore < condition && newScore >= condition) {
|
if(dicRank.id == rankId && oldScore < condition && newScore >= condition) {
|
||||||
let rankFirstRec = await RankFirstModel.createRankFirst(serverId, id, rankId, { userInfo, guildInfo });
|
let rankFirstRec = await RankFirstModel.createRankFirst(serverId, id, rankId, { userInfo, guildInfo });
|
||||||
let roleServers = pinus.app.getServersByType('role');
|
if(rankFirstRec && getSeconds(rankFirstRec.createdAt) == getSeconds(rankFirstRec.updatedAt)) {
|
||||||
for(let server of roleServers) {
|
let roleServers = pinus.app.getServersByType('role');
|
||||||
pinus.app.rpc.role.roleRemote.setRankFirst.toServer(server.id, rankFirstRec);
|
for(let server of roleServers) {
|
||||||
|
pinus.app.rpc.role.roleRemote.setRankFirst.toServer(server.id, rankFirstRec);
|
||||||
|
}
|
||||||
|
rankFirstRecs.push({ ... rankFirstRec, status: 1});
|
||||||
}
|
}
|
||||||
rankFirstRecs.push({ ... rankFirstRec, status: 1});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
guildInfo: GuildRankParam; // 军团信息
|
guildInfo: GuildRankParam; // 军团信息
|
||||||
|
|
||||||
public static async createRankFirst(serverId: number, id: number, type: number, update: RankFirstUpdateParam) {
|
public static async createRankFirst(serverId: number, id: number, type: number, update: RankFirstUpdateParam) {
|
||||||
const rec: RankFirstType = await RankFirstModel.findOneAndUpdate({ serverId, id, type}, { $setOnInsert: update }, { new: true, upsert: true }).lean();
|
const rec: RankFirstType = await RankFirstModel.findOneAndUpdate({ serverId, id, type, }, { $setOnInsert: update }, { new: true, upsert: true }).lean();
|
||||||
return rec;
|
return rec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user