feat(config): add ENABLE_ALL_BEATMAP_PP
This commit is contained in:
@@ -54,6 +54,7 @@ ENABLE_OSU_AP=false # 启用 osu!AP 统计数据
|
|||||||
ENABLE_ALL_MODS_PP=false # 启用所有 Mod 的 PP 计算
|
ENABLE_ALL_MODS_PP=false # 启用所有 Mod 的 PP 计算
|
||||||
ENABLE_SUPPORTER_FOR_ALL_USERS=false # 启用所有新注册用户的支持者状态
|
ENABLE_SUPPORTER_FOR_ALL_USERS=false # 启用所有新注册用户的支持者状态
|
||||||
ENABLE_ALL_BEATMAP_LEADERBOARD=false # 启用所有谱面的排行榜(没有排行榜的谱面会以 APPROVED 状态返回)
|
ENABLE_ALL_BEATMAP_LEADERBOARD=false # 启用所有谱面的排行榜(没有排行榜的谱面会以 APPROVED 状态返回)
|
||||||
|
ENABLE_ALL_BEATMAP_PP=false # 允许任何谱面获得 PP
|
||||||
SEASONAL_BACKGROUNDS='[]' # 季节背景图 URL 列表
|
SEASONAL_BACKGROUNDS='[]' # 季节背景图 URL 列表
|
||||||
|
|
||||||
# 存储服务设置
|
# 存储服务设置
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ Fetcher 用于从 osu! 官方 API 获取数据,使用 osu! 官方 API 的 OAut
|
|||||||
| `ENABLE_ALL_MODS_PP` | 启用所有 Mod 的 PP 计算 | `false` |
|
| `ENABLE_ALL_MODS_PP` | 启用所有 Mod 的 PP 计算 | `false` |
|
||||||
| `ENABLE_SUPPORTER_FOR_ALL_USERS` | 启用所有新注册用户的支持者状态 | `false` |
|
| `ENABLE_SUPPORTER_FOR_ALL_USERS` | 启用所有新注册用户的支持者状态 | `false` |
|
||||||
| `ENABLE_ALL_BEATMAP_LEADERBOARD` | 启用所有谱面的排行榜 | `false` |
|
| `ENABLE_ALL_BEATMAP_LEADERBOARD` | 启用所有谱面的排行榜 | `false` |
|
||||||
|
| `ENABLE_ALL_BEATMAP_PP` | 允许任何谱面获得 PP | `false` |
|
||||||
| `SEASONAL_BACKGROUNDS` | 季节背景图 URL 列表 | `[]` |
|
| `SEASONAL_BACKGROUNDS` | 季节背景图 URL 列表 | `[]` |
|
||||||
|
|
||||||
### 存储服务设置
|
### 存储服务设置
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ class Settings(BaseSettings):
|
|||||||
enable_all_mods_pp: bool = False
|
enable_all_mods_pp: bool = False
|
||||||
enable_supporter_for_all_users: bool = False
|
enable_supporter_for_all_users: bool = False
|
||||||
enable_all_beatmap_leaderboard: bool = False
|
enable_all_beatmap_leaderboard: bool = False
|
||||||
|
enable_all_beatmap_pp: bool = False
|
||||||
seasonal_backgrounds: list[str] = []
|
seasonal_backgrounds: list[str] = []
|
||||||
|
|
||||||
# 存储设置
|
# 存储设置
|
||||||
|
|||||||
@@ -531,7 +531,12 @@ async def get_user_best_pp(
|
|||||||
|
|
||||||
|
|
||||||
async def process_user(
|
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 user.id
|
||||||
assert score.id
|
assert score.id
|
||||||
@@ -598,18 +603,6 @@ async def process_user(
|
|||||||
statistics.grade_sh -= 1
|
statistics.grade_sh -= 1
|
||||||
case Rank.A:
|
case Rank.A:
|
||||||
statistics.grade_a -= 1
|
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.ranked_score += difference
|
||||||
statistics.level_current = calculate_score_to_level(statistics.total_score)
|
statistics.level_current = calculate_score_to_level(statistics.total_score)
|
||||||
statistics.maximum_combo = max(statistics.maximum_combo, score.max_combo)
|
statistics.maximum_combo = max(statistics.maximum_combo, score.max_combo)
|
||||||
@@ -666,7 +659,7 @@ async def process_user(
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
session.add(rank_lost_event)
|
session.add(rank_lost_event)
|
||||||
if score.passed and ranked:
|
if score.passed and has_leaderboard:
|
||||||
if previous_score_best_mod is not None:
|
if previous_score_best_mod is not None:
|
||||||
previous_score_best_mod.mods = mod_for_save
|
previous_score_best_mod.mods = mod_for_save
|
||||||
previous_score_best_mod.score_id = score.id
|
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
|
previous_score_best_mod.total_score = score.total_score
|
||||||
elif (
|
elif (
|
||||||
previous_score_best is not None and previous_score_best.score_id != score.id
|
previous_score_best is not None and previous_score_best.score_id != score.id
|
||||||
):
|
) or previous_score_best is None:
|
||||||
session.add(
|
session.add(
|
||||||
BestScore(
|
BestScore(
|
||||||
user_id=user.id,
|
user_id=user.id,
|
||||||
@@ -686,6 +679,7 @@ async def process_user(
|
|||||||
mods=mod_for_save,
|
mods=mod_for_save,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
statistics.play_count += 1
|
statistics.play_count += 1
|
||||||
mouthly_playcount.count += 1
|
mouthly_playcount.count += 1
|
||||||
statistics.play_time += length
|
statistics.play_time += length
|
||||||
|
|||||||
@@ -98,14 +98,16 @@ async def submit_score(
|
|||||||
db_beatmap = await Beatmap.get_or_fetch(db, fetcher, bid=beatmap)
|
db_beatmap = await Beatmap.get_or_fetch(db, fetcher, bid=beatmap)
|
||||||
except HTTPError:
|
except HTTPError:
|
||||||
raise HTTPException(status_code=404, detail="Beatmap not found")
|
raise HTTPException(status_code=404, detail="Beatmap not found")
|
||||||
ranked = (
|
has_pp = db_beatmap.beatmap_status.has_pp() | settings.enable_all_beatmap_pp
|
||||||
db_beatmap.beatmap_status.has_pp() | settings.enable_all_beatmap_leaderboard
|
has_leaderboard = (
|
||||||
|
db_beatmap.beatmap_status.has_leaderboard()
|
||||||
|
| settings.enable_all_beatmap_leaderboard
|
||||||
)
|
)
|
||||||
beatmap_length = db_beatmap.total_length
|
beatmap_length = db_beatmap.total_length
|
||||||
score = await process_score(
|
score = await process_score(
|
||||||
current_user,
|
current_user,
|
||||||
beatmap,
|
beatmap,
|
||||||
ranked,
|
has_pp,
|
||||||
score_token,
|
score_token,
|
||||||
info,
|
info,
|
||||||
fetcher,
|
fetcher,
|
||||||
@@ -117,7 +119,9 @@ async def submit_score(
|
|||||||
await db.refresh(current_user)
|
await db.refresh(current_user)
|
||||||
score_id = score.id
|
score_id = score.id
|
||||||
score_token.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()
|
score = (await db.exec(select(Score).where(Score.id == score_id))).first()
|
||||||
assert score is not None
|
assert score is not None
|
||||||
return await ScoreResp.from_db(db, score)
|
return await ScoreResp.from_db(db, score)
|
||||||
|
|||||||
@@ -79,10 +79,7 @@ async def _recalculate_pp(
|
|||||||
time -= 1
|
time -= 1
|
||||||
await asyncio.sleep(2)
|
await asyncio.sleep(2)
|
||||||
continue
|
continue
|
||||||
ranked = (
|
ranked = db_beatmap.beatmap_status.has_pp() | settings.enable_all_beatmap_pp
|
||||||
db_beatmap.beatmap_status.has_pp()
|
|
||||||
| settings.enable_all_beatmap_leaderboard
|
|
||||||
)
|
|
||||||
if not ranked or not mods_can_get_pp(
|
if not ranked or not mods_can_get_pp(
|
||||||
MODE_TO_INT[score.gamemode], score.mods
|
MODE_TO_INT[score.gamemode], score.mods
|
||||||
):
|
):
|
||||||
|
|||||||
Reference in New Issue
Block a user