mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew.git
synced 2025-05-13 11:37:33 -05:00
Implement lottery item usage
This commit is contained in:
parent
c0333265e9
commit
de7a21f0b3
1 changed files with 20 additions and 1 deletions
|
@ -49,6 +49,17 @@ lazy_static! {
|
|||
}
|
||||
cardz
|
||||
};
|
||||
static ref PRICE: JsonValue = {
|
||||
let mut cardz = object!{};
|
||||
let items = json::parse(include_str!("lottery_price.json")).unwrap();
|
||||
for (_i, data) in items.members().enumerate() {
|
||||
if cardz[data["id"].to_string()].is_null() {
|
||||
cardz[data["id"].to_string()] = object!{};
|
||||
}
|
||||
cardz[data["id"].to_string()][data["number"].to_string()] = data.clone();
|
||||
}
|
||||
cardz
|
||||
};
|
||||
}
|
||||
|
||||
pub fn tutorial(_req: HttpRequest, body: String) -> HttpResponse {
|
||||
|
@ -159,7 +170,15 @@ pub fn lottery_post(req: HttpRequest, body: String) -> HttpResponse {
|
|||
cardstogive.push(new_card).unwrap();
|
||||
} else {
|
||||
lottery_id = 1110024;
|
||||
cardstogive = get_random_cards(lottery_id, 10);
|
||||
let price = PRICE[lottery_id.to_string()][body["master_lottery_price_number"].to_string()].clone();
|
||||
|
||||
if price["consumeType"].as_i32().unwrap() == 1 {
|
||||
global::remove_gems(&mut user, price["price"].as_i64().unwrap());
|
||||
} else if price["consumeType"].as_i32().unwrap() == 4 {
|
||||
global::use_item(price["masterItemId"].as_i64().unwrap(), price["price"].as_i64().unwrap(), &mut user);
|
||||
}
|
||||
|
||||
cardstogive = get_random_cards(lottery_id, price["count"].as_usize().unwrap());
|
||||
}
|
||||
|
||||
let lottery_type = LOTTERY[lottery_id.to_string()]["category"].as_i32().unwrap();
|
||||
|
|
Loading…
Add table
Reference in a new issue