Admin rules: starting balance, guild claim/member limits, market listing limit; panel UI
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DjMbLQujBHunCCu5GpsHaT
This commit is contained in:
8 files changed
+166
-12
No files matched your search
@@ -116,3 +116,40 @@ async fn a_rank_milestone_can_grant_more_than_its_title() {
|
||||
t.call("POST", "/api/server/v1/player/xp", Some(&key), Some(json!({"operation_id": "lv2", "uuid": alex, "scope": "global", "amount": 100}))).await;
|
||||
assert!(t.call("POST", "/api/server/v1/rewards/poll", Some(&key), Some(json!({}))).await.1["deliveries"].as_array().unwrap().is_empty());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn admin_rules_change_balances_claims_and_membership() {
|
||||
let t = setup().await;
|
||||
let admin = t.login("admin", "supersecret").await;
|
||||
for n in ["Leader", "Joiner", "Extra"] {
|
||||
t.call("POST", "/api/admin/users", Some(&admin), Some(json!({"username": n, "password": "password123"}))).await;
|
||||
}
|
||||
let leader = t.login("Leader", "password123").await;
|
||||
let (_, srv) = t.call("POST", "/api/admin/servers", Some(&admin), Some(json!({"name": "SMP", "instance_id": "smp"}))).await;
|
||||
let key = srv["token"].as_str().unwrap().to_string();
|
||||
let (_, settings) = t.call("GET", "/api/admin/progression", Some(&admin), None).await;
|
||||
let mut s = settings["settings"].clone();
|
||||
s["rules"] = json!({"starting_balance": 250.0, "guild_base_claims": 10, "guild_claims_per_member": 3, "guild_claims_per_level": 0, "guild_max_members": 2, "market_max_listings": 1});
|
||||
let (st, body) = t.call("PUT", "/api/admin/progression", Some(&admin), Some(s)).await;
|
||||
assert_eq!(st, StatusCode::OK, "{body}");
|
||||
|
||||
// New players start with the configured balance.
|
||||
let uuid = t.uuid("Leader").await;
|
||||
let (_, bal) = t.call("POST", "/api/server/v1/economy/balance", Some(&key), Some(json!({"uuid": uuid, "username": "Leader"}))).await;
|
||||
assert_eq!(bal["balance"].as_f64(), Some(250.0), "{bal}");
|
||||
|
||||
// A guild starts with the configured claims, grows with members, and stops at the member limit.
|
||||
let (_, g) = t.call("POST", "/api/v1/guilds", Some(&leader), Some(json!({"instance_id": "smp", "name": "Iron", "tag": "IRON"}))).await;
|
||||
let id = g["id"].as_str().unwrap().to_string();
|
||||
let max = || async { t.call("GET", &format!("/api/v1/guilds/{id}"), Some(&leader), None).await.1["max_claims"].as_i64() };
|
||||
assert_eq!(max().await, Some(10));
|
||||
let add = |name: &str| {
|
||||
let (t, leader, id, name) = (&t, leader.clone(), id.clone(), name.to_string());
|
||||
async move { t.call("POST", &format!("/api/v1/guilds/{id}/members"), Some(&leader), Some(json!({"username": name}))).await }
|
||||
};
|
||||
let (st, body) = add("Joiner").await;
|
||||
assert_eq!(st, StatusCode::OK, "{body}");
|
||||
assert_eq!(max().await, Some(13), "+3 per member beyond the leader");
|
||||
let (st, body) = add("Extra").await;
|
||||
assert_eq!(st, StatusCode::BAD_REQUEST, "the guild is full at 2 members: {body}");
|
||||
}
|
||||
Reference in new issue
Block a user