Admin progression controls: quest limits/rotation, XP rates, level curve, manual XP adjustments
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DjMbLQujBHunCCu5GpsHaT
This commit is contained in:
10 files changed
+821
-43
No files matched your search
@@ -9,30 +9,7 @@ use scopenet_shared::{ServerLevelInfo, UserLevelInfo};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
|
||||
/// XP required to reach level L.
|
||||
pub fn xp_for_level(lvl: i64) -> i64 {
|
||||
if lvl <= 1 {
|
||||
return 0;
|
||||
}
|
||||
((lvl as f64).powf(1.5) * 100.0).round() as i64
|
||||
}
|
||||
|
||||
/// Computes (level, current_level_xp, next_level_span, progress_pct) from total XP.
|
||||
pub fn level_from_xp(xp: i64) -> (i64, i64, i64, f64) {
|
||||
if xp <= 0 {
|
||||
return (1, 0, 100, 0.0);
|
||||
}
|
||||
let mut lvl = 1;
|
||||
while xp >= xp_for_level(lvl + 1) {
|
||||
lvl += 1;
|
||||
}
|
||||
let curr_req = xp_for_level(lvl);
|
||||
let next_req = xp_for_level(lvl + 1);
|
||||
let span = (next_req - curr_req).max(1);
|
||||
let progress_in_lvl = (xp - curr_req).max(0);
|
||||
let pct = (progress_in_lvl as f64 / span as f64 * 100.0).clamp(0.0, 100.0);
|
||||
(lvl, progress_in_lvl, span, pct)
|
||||
}
|
||||
pub use crate::progression::{level_from_xp, xp_for_level};
|
||||
|
||||
/// Award each configured entitlement once in the transaction which earned it.
|
||||
/// Achievement XP is credited automatically via the `achievement_xp` DB trigger;
|
||||
|
||||
Reference in new issue
Block a user