1
This commit is contained in:
@@ -31,7 +31,7 @@ class LadderService {
|
||||
const config = this.getRankConfig(player.rankId);
|
||||
|
||||
if (config.RankScore === 1) {
|
||||
// 王者分数 mechanism
|
||||
// King rank score mechanism
|
||||
this.updateRankScore(player, opponent, true);
|
||||
} else {
|
||||
// Star-based mechanism
|
||||
@@ -49,7 +49,7 @@ class LadderService {
|
||||
const config = this.getRankConfig(player.rankId);
|
||||
|
||||
if (config.RankScore === 1) {
|
||||
// 王者分数 mechanism
|
||||
// King rank score mechanism
|
||||
this.updateRankScore(player, opponent, false);
|
||||
} else {
|
||||
// Star-based mechanism
|
||||
@@ -64,8 +64,8 @@ class LadderService {
|
||||
updateStars(player, config, isWin) {
|
||||
if (isWin) {
|
||||
let starsToAdd = config.WinGetStar;
|
||||
// Add extra stars for win streak
|
||||
if (player.winStreak >= 3) {
|
||||
// Add extra stars for win streak (3+ wins)
|
||||
if (player.winStreak >= 2) { // Streak starts at 2 (after 2 wins)
|
||||
starsToAdd += config.ExtraGetStar;
|
||||
}
|
||||
player.stars += starsToAdd;
|
||||
@@ -79,7 +79,7 @@ class LadderService {
|
||||
player.stars = Math.max(0, player.stars - 1);
|
||||
|
||||
// Level down check
|
||||
if (player.stars === 0) {
|
||||
if (player.stars === 0 && config.LoseRankDown === 1) {
|
||||
this.levelDown(player, config);
|
||||
}
|
||||
}
|
||||
@@ -87,18 +87,35 @@ class LadderService {
|
||||
}
|
||||
|
||||
updateRankScore(player, opponent, isWin) {
|
||||
const config = this.getRankConfig(player.rankId);
|
||||
|
||||
if (isWin) {
|
||||
let scoreToAdd = 20;
|
||||
// Initialize rank score if not already set
|
||||
if (player.rankScore === 0) {
|
||||
player.rankScore = config.InitialRankScore || 1100;
|
||||
}
|
||||
|
||||
// Calculate score to add based on opponent's rank
|
||||
let scoreToAdd = config.WinScoreMin || 80;
|
||||
|
||||
// If opponent has a higher rank score, calculate bonus
|
||||
if (opponent.rankScore > player.rankScore) {
|
||||
const ratio = Math.min(opponent.rankScore / player.rankScore, 3);
|
||||
scoreToAdd = Math.round(ratio * 20);
|
||||
// Calculate bonus based on rank difference (simplified)
|
||||
const ratio = Math.min((opponent.rankScore - player.rankScore) / 100, 1);
|
||||
scoreToAdd = Math.round(config.WinScoreMin + ratio * (config.WinScoreMax - config.WinScoreMin));
|
||||
}
|
||||
|
||||
player.rankScore += scoreToAdd;
|
||||
} else {
|
||||
// Deduct points on loss
|
||||
const scoreToDeduct = config.LoseScore || 20;
|
||||
if (player.rankScore > 0) {
|
||||
player.rankScore = Math.max(0, player.rankScore - 20);
|
||||
player.rankScore = Math.max(0, player.rankScore - scoreToDeduct);
|
||||
}
|
||||
|
||||
// Check for level down if score is too low
|
||||
if (player.rankScore < 1000 && config.LoseRankDown === 1) {
|
||||
this.levelDown(player, config);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,6 +125,11 @@ class LadderService {
|
||||
if (nextConfig) {
|
||||
player.rankId++;
|
||||
player.stars = nextConfig.BeginStar;
|
||||
|
||||
// Initialize rank score for King rank
|
||||
if (nextConfig.RankScore === 1) {
|
||||
player.rankScore = nextConfig.InitialRankScore || 1100;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +137,14 @@ class LadderService {
|
||||
if (currentConfig.LoseRankDown === 1 && player.rankId > 1) {
|
||||
player.rankId--;
|
||||
const prevConfig = this.getRankConfig(player.rankId);
|
||||
player.stars = prevConfig.RankDownStar;
|
||||
if (prevConfig.RankScore === 1) {
|
||||
// Stay in rank score system
|
||||
player.rankScore = Math.max(prevConfig.InitialRankScore || 1100, player.rankScore - (prevConfig.LoseScore || 20));
|
||||
} else {
|
||||
// Back to star system
|
||||
player.stars = prevConfig.RankDownStar;
|
||||
player.rankScore = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user