mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew.git
synced 2025-05-13 11:37:33 -05:00
Implement claiming most items from gift box
This commit is contained in:
parent
e6b58d064f
commit
ab3bcef17f
2 changed files with 29 additions and 63 deletions
|
@ -136,13 +136,7 @@ pub fn lottery_post(req: HttpRequest, body: String) -> HttpResponse {
|
||||||
let mut new_ids = array![];
|
let mut new_ids = array![];
|
||||||
for (_i, data) in cardstogive.members().enumerate() {
|
for (_i, data) in cardstogive.members().enumerate() {
|
||||||
if !global::give_character(data["master_card_id"].to_string(), &mut user) {
|
if !global::give_character(data["master_card_id"].to_string(), &mut user) {
|
||||||
let to_push = object!{
|
global::give_item(19100001, 20, &mut user);
|
||||||
"id": 6600,
|
|
||||||
"master_item_id": 19100001,
|
|
||||||
"amount": 20,
|
|
||||||
"expire_date_time": null
|
|
||||||
};
|
|
||||||
user["item_list"].push(to_push).unwrap();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
new_ids.push(data["master_lottery_item_id"].to_string()).unwrap();
|
new_ids.push(data["master_lottery_item_id"].to_string()).unwrap();
|
||||||
|
|
|
@ -47,7 +47,7 @@ pub fn user(req: HttpRequest) -> HttpResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref LOTTERY_INFO: JsonValue = {
|
static ref LOGIN_REWARDS: JsonValue = {
|
||||||
let mut info = object!{};
|
let mut info = object!{};
|
||||||
let items = json::parse(include_str!("json/login_bonus_reward.json")).unwrap();
|
let items = json::parse(include_str!("json/login_bonus_reward.json")).unwrap();
|
||||||
for (_i, data) in items.members().enumerate() {
|
for (_i, data) in items.members().enumerate() {
|
||||||
|
@ -57,8 +57,8 @@ lazy_static! {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_info_from_id(id: i64) -> JsonValue {
|
pub fn get_info_from_id(id: i64) -> JsonValue {
|
||||||
LOTTERY_INFO[id.to_string()].clone()
|
LOGIN_REWARDS[id.to_string()].clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn gift(req: HttpRequest, body: String) -> HttpResponse {
|
pub fn gift(req: HttpRequest, body: String) -> HttpResponse {
|
||||||
|
@ -77,65 +77,34 @@ pub fn gift(req: HttpRequest, body: String) -> HttpResponse {
|
||||||
if data["id"].to_string() != gift_id.to_string() {
|
if data["id"].to_string() != gift_id.to_string() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let info = get_info_from_id(data["id"].as_i64().unwrap());
|
let limit_reached;
|
||||||
//println!("{}", json::stringify(info.clone()));
|
//println!("{}", json::stringify(data.clone()));
|
||||||
|
if data["reward_type"].to_string() == "1" {
|
||||||
if info["giveType"].to_string() == "1" {
|
|
||||||
if info["type"].to_string() == "1" {
|
|
||||||
// basically primogems!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
// basically primogems!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
userr["gem"]["free"] = (userr["gem"]["free"].as_i64().unwrap() + info["amount"].as_i64().unwrap()).into();
|
limit_reached = global::give_primogems(data["amount"].as_i64().unwrap(), &mut userr);
|
||||||
} else if info["type"].to_string() == "2" {
|
} else if data["reward_type"].to_string() == "2" {
|
||||||
//character
|
//character
|
||||||
global::give_character(info["value"].to_string(), &mut userr);
|
global::give_character(data["value"].to_string(), &mut userr);
|
||||||
} else if info["type"].to_string() == "3" {
|
limit_reached = false;
|
||||||
let mut has = false;
|
} else if data["reward_type"].to_string() == "3" {
|
||||||
for (_k, data2) in userr["item_list"].members_mut().enumerate() {
|
limit_reached = global::give_item(data["value"].as_i64().unwrap(), data["amount"].as_i64().unwrap(), &mut userr);
|
||||||
if data2["master_item_id"].to_string() == info["value"].to_string() {
|
} else if data["reward_type"].to_string() == "4" {
|
||||||
has = true;
|
|
||||||
data2["amount"] = (data2["amount"].as_i64().unwrap() + info["amount"].as_i64().unwrap()).into();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !has {
|
|
||||||
userr["item_list"].push(object!{
|
|
||||||
id: info["value"].clone(),
|
|
||||||
master_item_id: info["value"].clone(),
|
|
||||||
amount: info["amount"].clone(),
|
|
||||||
expire_date_time: null
|
|
||||||
}).unwrap();
|
|
||||||
}
|
|
||||||
} else if info["type"].to_string() == "4" {
|
|
||||||
// basically moraa!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
// basically moraa!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
let mut has = false;
|
limit_reached = global::give_points(data["reward_type"].as_i64().unwrap(), data["amount"].as_i64().unwrap(), &mut userr);
|
||||||
for (_k, data2) in userr["point_list"].members_mut().enumerate() {
|
|
||||||
if data2["type"].to_string() == info["type"].to_string() {
|
|
||||||
has = true;
|
|
||||||
data2["amount"] = (data2["amount"].as_i64().unwrap() + info["amount"].as_i64().unwrap()).into();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !has {
|
|
||||||
userr["point_list"].push(object!{
|
|
||||||
type: info["type"].clone(),
|
|
||||||
amount: info["amount"].clone()
|
|
||||||
}).unwrap();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
println!("Redeeming reward not implimented for reward id {}", info["id"].to_string());
|
println!("Redeeming reward not implimented for reward type {}", data["reward_type"].to_string());
|
||||||
failed.push(gift_id.clone()).unwrap();
|
limit_reached = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} else {
|
if limit_reached {
|
||||||
println!("Redeeming reward not implimented for give type {}", info["giveType"].to_string());
|
|
||||||
failed.push(gift_id.clone()).unwrap();
|
failed.push(gift_id.clone()).unwrap();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let to_push = object!{
|
let to_push = object!{
|
||||||
give_type: info["giveType"].clone(),
|
give_type: 2,
|
||||||
type: data["reward_type"].clone(),
|
type: data["reward_type"].clone(),
|
||||||
value: info["value"].clone(),
|
value: data["value"].clone(),
|
||||||
level: info["level"].clone(),
|
level: data["level"].clone(),
|
||||||
amount: info["amount"].clone()
|
amount: data["amount"].clone()
|
||||||
};
|
};
|
||||||
rewards.push(to_push).unwrap();
|
rewards.push(to_push).unwrap();
|
||||||
to_remove = j + 1;
|
to_remove = j + 1;
|
||||||
|
@ -201,6 +170,9 @@ pub fn user_post(req: HttpRequest, body: String) -> HttpResponse {
|
||||||
if !body["main_deck_slot"].is_null() {
|
if !body["main_deck_slot"].is_null() {
|
||||||
user["user"]["main_deck_slot"] = body["main_deck_slot"].clone();
|
user["user"]["main_deck_slot"] = body["main_deck_slot"].clone();
|
||||||
}
|
}
|
||||||
|
if !body["master_title_ids"].is_null() {
|
||||||
|
user["user"]["master_title_ids"][0] = body["master_title_ids"][0].clone();
|
||||||
|
}
|
||||||
|
|
||||||
userdata::save_acc(&key, user.clone());
|
userdata::save_acc(&key, user.clone());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue