军团活动:修复bug

This commit is contained in:
luying
2021-09-28 11:33:59 +08:00
parent faf94b7296
commit 63c2da2427
3 changed files with 15 additions and 4 deletions
+10 -2
View File
@@ -58,7 +58,7 @@ export class Rank {
case REDIS_KEY.RACE_ACTIVITY:
this.valueConfig = [
new ValueConfig(true, 'score', 0, false, false),
new ValueConfig(false, 'time', 6, true, true)
new ValueConfig(false, 'time', 10, true, true)
];
break;
case REDIS_KEY.GUILD_LV_RANK:
@@ -669,6 +669,9 @@ export class Rank {
const field = rankFromDb[ii];
let myId = this.decodeFields(this.key, field);
const scores = this.decodeScore(rankFromDb[ii + 1]);
console.log('**********', scores);
const info = await redisClient().hgetAsync(this.infoKey, this.composeFields(this.infoKey, myId));
const userInfo = JSON.parse(info);
@@ -828,10 +831,15 @@ export class Rank {
private decodeScore(num: string) {
let _num = parseInt(num);
let scores: number[] = [];
this.valueConfig.forEach(({ weight }) => {
this.valueConfig.forEach(({ reverse, isTimestamp, len, weight }) => {
let pow = Math.pow(10, weight);
let score = Math.floor(_num / pow);
_num -= pow * score;
if(isTimestamp) score = this.handleTimestamp(score, len);
if(reverse) {
let pow = Math.pow(10, len);
score = pow - 1 - score;
}
scores.push(score);
})
return scores;