feat: complete in-game commands, GUIs, admin panel fixes, and launcher enhancements
This commit is contained in:
1 parent
a9ff92e1d1
commit
752f0cc43d
34 files changed
+4170
-181
No files matched your search
@@ -78,12 +78,15 @@ pub async fn get_achievements_for_user(
|
||||
title,
|
||||
description: desc,
|
||||
category: cat,
|
||||
icon_frame: frame,
|
||||
icon_frame: frame.clone(),
|
||||
frame_type: Some(frame),
|
||||
icon_item: item,
|
||||
icon_bg: bg,
|
||||
icon_border: border,
|
||||
xp_reward: xp,
|
||||
secret,
|
||||
stat_type: None,
|
||||
target_count: None,
|
||||
unlocked,
|
||||
unlocked_at,
|
||||
})
|
||||
@@ -105,6 +108,8 @@ pub struct AdminAchievementRow {
|
||||
pub requirement_type: String,
|
||||
pub requirement_key: String,
|
||||
pub requirement_value: i64,
|
||||
pub stat_type: String,
|
||||
pub target_count: i64,
|
||||
pub total_unlocked: i64,
|
||||
}
|
||||
|
||||
@@ -166,18 +171,23 @@ pub async fn admin_list_achievements(
|
||||
title,
|
||||
description: desc,
|
||||
category: cat,
|
||||
icon_frame: frame,
|
||||
icon_frame: frame.clone(),
|
||||
frame_type: Some(frame),
|
||||
icon_item: item,
|
||||
icon_bg: bg,
|
||||
icon_border: border,
|
||||
xp_reward: xp,
|
||||
secret,
|
||||
stat_type: Some(req_key.clone()),
|
||||
target_count: Some(req_val),
|
||||
unlocked: false,
|
||||
unlocked_at: None,
|
||||
},
|
||||
requirement_type: req_type,
|
||||
requirement_key: req_key,
|
||||
requirement_key: req_key.clone(),
|
||||
requirement_value: req_val,
|
||||
stat_type: req_key,
|
||||
target_count: req_val,
|
||||
total_unlocked,
|
||||
}
|
||||
},
|
||||
@@ -193,13 +203,17 @@ pub struct AchievementPayload {
|
||||
pub title: String,
|
||||
pub description: String,
|
||||
pub category: String,
|
||||
#[serde(alias = "frame_type")]
|
||||
pub icon_frame: String,
|
||||
pub icon_item: String,
|
||||
pub icon_bg: String,
|
||||
pub icon_border: String,
|
||||
pub requirement_type: String,
|
||||
pub requirement_key: String,
|
||||
pub requirement_value: i64,
|
||||
#[serde(default)]
|
||||
pub requirement_type: Option<String>,
|
||||
#[serde(default, alias = "stat_type")]
|
||||
pub requirement_key: Option<String>,
|
||||
#[serde(default, alias = "target_count")]
|
||||
pub requirement_value: Option<i64>,
|
||||
pub xp_reward: i64,
|
||||
pub secret: Option<bool>,
|
||||
}
|
||||
@@ -215,6 +229,9 @@ pub async fn admin_create_achievement(
|
||||
.filter(|s| !s.trim().is_empty())
|
||||
.unwrap_or_else(|| format!("ach_{}", uuid::Uuid::new_v4().simple()));
|
||||
let now = chrono::Utc::now().to_rfc3339();
|
||||
let req_type = payload.requirement_type.unwrap_or_else(|| "stat".into());
|
||||
let req_key = payload.requirement_key.unwrap_or_else(|| "blocks_broken".into());
|
||||
let req_val = payload.requirement_value.unwrap_or(50);
|
||||
|
||||
sqlx::query(
|
||||
"INSERT INTO achievements (id, title, description, category, icon_frame, icon_item, icon_bg, icon_border, requirement_type, requirement_key, requirement_value, xp_reward, secret, created_at)
|
||||
@@ -228,9 +245,9 @@ pub async fn admin_create_achievement(
|
||||
.bind(payload.icon_item)
|
||||
.bind(payload.icon_bg)
|
||||
.bind(payload.icon_border)
|
||||
.bind(payload.requirement_type)
|
||||
.bind(payload.requirement_key)
|
||||
.bind(payload.requirement_value)
|
||||
.bind(req_type)
|
||||
.bind(req_key)
|
||||
.bind(req_val)
|
||||
.bind(payload.xp_reward)
|
||||
.bind(payload.secret.unwrap_or(false))
|
||||
.bind(&now)
|
||||
@@ -247,6 +264,10 @@ pub async fn admin_update_achievement(
|
||||
State(state): State<AppState>,
|
||||
Json(payload): Json<AchievementPayload>,
|
||||
) -> AppResult<Json<Value>> {
|
||||
let req_type = payload.requirement_type.unwrap_or_else(|| "stat".into());
|
||||
let req_key = payload.requirement_key.unwrap_or_else(|| "blocks_broken".into());
|
||||
let req_val = payload.requirement_value.unwrap_or(50);
|
||||
|
||||
sqlx::query(
|
||||
"UPDATE achievements SET
|
||||
title = ?,
|
||||
@@ -270,9 +291,9 @@ pub async fn admin_update_achievement(
|
||||
.bind(payload.icon_item)
|
||||
.bind(payload.icon_bg)
|
||||
.bind(payload.icon_border)
|
||||
.bind(payload.requirement_type)
|
||||
.bind(payload.requirement_key)
|
||||
.bind(payload.requirement_value)
|
||||
.bind(req_type)
|
||||
.bind(req_key)
|
||||
.bind(req_val)
|
||||
.bind(payload.xp_reward)
|
||||
.bind(payload.secret)
|
||||
.bind(&id)
|
||||
|
||||
Reference in new issue
Block a user