Cleanup method of giving cards
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
use json;
|
||||
use json::{array, object};
|
||||
use json::{array, object, JsonValue};
|
||||
use crate::router::global;
|
||||
use crate::encryption;
|
||||
use actix_web::{HttpResponse, HttpRequest, http::header::HeaderValue};
|
||||
@ -58,13 +58,22 @@ pub fn initialize(req: HttpRequest, body: String) -> HttpResponse {
|
||||
|
||||
let id = body["master_character_id"].to_string();
|
||||
let userr = &id[id.len() - 2..].parse::<i32>().unwrap();
|
||||
|
||||
let cardstoreward: JsonValue;
|
||||
let mut masterid = 3000000;
|
||||
if id.starts_with("2") {
|
||||
if id.starts_with("1") {
|
||||
cardstoreward = array![10010001, 10020001, 10030001, 10040001, 10050001, 10060001, 10070001, 10080001, 10090001]; //muse
|
||||
} else if id.starts_with("2") {
|
||||
cardstoreward = array![20010001, 20020001, 20030001, 20040001, 20050001, 20060001, 20070001, 20080001, 20090001]; //aqours
|
||||
masterid += 9; //muse
|
||||
} else if id.starts_with("3") {
|
||||
masterid += 9 + 9; //aquors
|
||||
cardstoreward = array![30010001, 30020001, 30030001, 30040001, 30050001, 30060001, 30070001, 30080001, 30090001, 30100001, 30110001]; //nijigasaki
|
||||
masterid += 9 + 9; //aqours
|
||||
} else if id.starts_with("4") {
|
||||
cardstoreward = array![40010001, 40020001, 40030001, 40040001, 40050001, 40060001, 40070001, 40080001, 40090001]; //liella
|
||||
masterid += 9 + 9 + 12; //nijigasaki
|
||||
} else {
|
||||
return global::error_resp();
|
||||
}
|
||||
masterid += userr;
|
||||
|
||||
@ -72,25 +81,14 @@ pub fn initialize(req: HttpRequest, body: String) -> HttpResponse {
|
||||
|
||||
// User is rewarded with all base cards in the team they chose. This makes up their new deck_list
|
||||
|
||||
//nijigasaki for now
|
||||
let cardstoreward = array![30010001, 30020001, 30030001, 30050001, 30060001, 30070001, 30080001, 30090001, 30100001, 30110001];
|
||||
|
||||
let ur = user["card_list"][user["card_list"].len() - 1]["id"].clone();
|
||||
//todo - does the user have the char already?
|
||||
for (i, data) in cardstoreward.members().enumerate() {
|
||||
let to_push = object!{
|
||||
"id": data.clone(),
|
||||
"master_card_id": data.clone(),
|
||||
"exp": 0,
|
||||
"skill_exp": 0,
|
||||
"evolve": [],
|
||||
"created_date_time": global::timestamp()
|
||||
};
|
||||
user["card_list"].push(to_push.clone()).unwrap();
|
||||
global::give_character(data.to_string(), &mut user);
|
||||
if i < 10 {
|
||||
user["deck_list"][0]["main_card_ids"][i] = data.clone();
|
||||
}
|
||||
}
|
||||
//todo - should the chosen character be in the team twice?
|
||||
user["deck_list"][0]["main_card_ids"][4] = ur;
|
||||
|
||||
userdata::save_acc(key, user.clone());
|
||||
|
Reference in New Issue
Block a user