From 51a82a5161505c993bd50cd40539abe76a374d99 Mon Sep 17 00:00:00 2001 From: Ethan O'Brien <77750390+ethanaobrien@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:48:17 -0500 Subject: [PATCH] Fix improperly set favorite_card_evolve --- src/router/global.rs | 2 +- src/router/user.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/router/global.rs b/src/router/global.rs index 97fab05..25bfe27 100644 --- a/src/router/global.rs +++ b/src/router/global.rs @@ -330,7 +330,7 @@ pub fn give_exp(amount: i32, user: &mut JsonValue) { } } -fn get_card(id: i64, user: &JsonValue) -> JsonValue { +pub fn get_card(id: i64, user: &JsonValue) -> JsonValue { if id == 0 { return object!{}; } diff --git a/src/router/user.rs b/src/router/user.rs index 0786f8f..8d3081f 100644 --- a/src/router/user.rs +++ b/src/router/user.rs @@ -153,6 +153,7 @@ pub fn user_post(req: HttpRequest, body: String) -> HttpResponse { } if !body["favorite_master_card_id"].is_null() { user["user"]["favorite_master_card_id"] = body["favorite_master_card_id"].clone(); + user["user"]["favorite_card_evolve"] = if global::get_card(body["favorite_master_card_id"].as_i64().unwrap(), &user)["evolve"].is_empty() { 0 } else { 1 }.into(); } if !body["guest_smile_master_card_id"].is_null() { user["user"]["guest_smile_master_card_id"] = body["guest_smile_master_card_id"].clone();