feat(config): add ENABLE_ALL_BEATMAP_PP

This commit is contained in:
MingxuanGame
2025-08-14 07:01:41 +00:00
parent ebbc0b8252
commit 48b075d99d
6 changed files with 21 additions and 23 deletions

View File

@@ -54,6 +54,7 @@ ENABLE_OSU_AP=false # 启用 osu!AP 统计数据
ENABLE_ALL_MODS_PP=false # 启用所有 Mod 的 PP 计算
ENABLE_SUPPORTER_FOR_ALL_USERS=false # 启用所有新注册用户的支持者状态
ENABLE_ALL_BEATMAP_LEADERBOARD=false # 启用所有谱面的排行榜(没有排行榜的谱面会以 APPROVED 状态返回)
ENABLE_ALL_BEATMAP_PP=false # 允许任何谱面获得 PP
SEASONAL_BACKGROUNDS='[]' # 季节背景图 URL 列表
# 存储服务设置

View File

@@ -114,6 +114,7 @@ Fetcher 用于从 osu! 官方 API 获取数据,使用 osu! 官方 API 的 OAut
| `ENABLE_ALL_MODS_PP` | 启用所有 Mod 的 PP 计算 | `false` |
| `ENABLE_SUPPORTER_FOR_ALL_USERS` | 启用所有新注册用户的支持者状态 | `false` |
| `ENABLE_ALL_BEATMAP_LEADERBOARD` | 启用所有谱面的排行榜 | `false` |
| `ENABLE_ALL_BEATMAP_PP` | 允许任何谱面获得 PP | `false` |
| `SEASONAL_BACKGROUNDS` | 季节背景图 URL 列表 | `[]` |
### 存储服务设置

View File

@@ -93,6 +93,7 @@ class Settings(BaseSettings):
enable_all_mods_pp: bool = False
enable_supporter_for_all_users: bool = False
enable_all_beatmap_leaderboard: bool = False
enable_all_beatmap_pp: bool = False
seasonal_backgrounds: list[str] = []
# 存储设置

View File

@@ -531,7 +531,12 @@ async def get_user_best_pp(
async def process_user(
session: AsyncSession, user: User, score: Score, length: int, ranked: bool = False
session: AsyncSession,
user: User,
score: Score,
length: int,
ranked: bool = False,
has_leaderboard: bool = False,
):
assert user.id
assert score.id
@@ -598,18 +603,6 @@ async def process_user(
statistics.grade_sh -= 1
case Rank.A:
statistics.grade_a -= 1
else:
previous_score_best = BestScore(
user_id=user.id,
beatmap_id=score.beatmap_id,
gamemode=score.gamemode,
score_id=score.id,
total_score=score.total_score,
rank=score.rank,
mods=mod_for_save,
)
session.add(previous_score_best)
statistics.ranked_score += difference
statistics.level_current = calculate_score_to_level(statistics.total_score)
statistics.maximum_combo = max(statistics.maximum_combo, score.max_combo)
@@ -666,7 +659,7 @@ async def process_user(
},
}
session.add(rank_lost_event)
if score.passed and ranked:
if score.passed and has_leaderboard:
if previous_score_best_mod is not None:
previous_score_best_mod.mods = mod_for_save
previous_score_best_mod.score_id = score.id
@@ -674,7 +667,7 @@ async def process_user(
previous_score_best_mod.total_score = score.total_score
elif (
previous_score_best is not None and previous_score_best.score_id != score.id
):
) or previous_score_best is None:
session.add(
BestScore(
user_id=user.id,
@@ -686,6 +679,7 @@ async def process_user(
mods=mod_for_save,
)
)
statistics.play_count += 1
mouthly_playcount.count += 1
statistics.play_time += length

View File

@@ -98,14 +98,16 @@ async def submit_score(
db_beatmap = await Beatmap.get_or_fetch(db, fetcher, bid=beatmap)
except HTTPError:
raise HTTPException(status_code=404, detail="Beatmap not found")
ranked = (
db_beatmap.beatmap_status.has_pp() | settings.enable_all_beatmap_leaderboard
has_pp = db_beatmap.beatmap_status.has_pp() | settings.enable_all_beatmap_pp
has_leaderboard = (
db_beatmap.beatmap_status.has_leaderboard()
| settings.enable_all_beatmap_leaderboard
)
beatmap_length = db_beatmap.total_length
score = await process_score(
current_user,
beatmap,
ranked,
has_pp,
score_token,
info,
fetcher,
@@ -117,7 +119,9 @@ async def submit_score(
await db.refresh(current_user)
score_id = score.id
score_token.score_id = score_id
await process_user(db, current_user, score, beatmap_length, ranked)
await process_user(
db, current_user, score, beatmap_length, has_pp, has_leaderboard
)
score = (await db.exec(select(Score).where(Score.id == score_id))).first()
assert score is not None
return await ScoreResp.from_db(db, score)

View File

@@ -79,10 +79,7 @@ async def _recalculate_pp(
time -= 1
await asyncio.sleep(2)
continue
ranked = (
db_beatmap.beatmap_status.has_pp()
| settings.enable_all_beatmap_leaderboard
)
ranked = db_beatmap.beatmap_status.has_pp() | settings.enable_all_beatmap_pp
if not ranked or not mods_can_get_pp(
MODE_TO_INT[score.gamemode], score.mods
):