mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew.git
synced 2025-05-13 11:37:33 -05:00
Implement /api/live/continue
This commit is contained in:
parent
5a2482d028
commit
e735215141
3 changed files with 39 additions and 0 deletions
|
@ -144,6 +144,9 @@ async fn live_retire(req: HttpRequest, body: String) -> HttpResponse { router::l
|
||||||
#[get("/api/live/clearRate")]
|
#[get("/api/live/clearRate")]
|
||||||
async fn live_clearrate(req: HttpRequest) -> HttpResponse { router::live::clearrate(req) }
|
async fn live_clearrate(req: HttpRequest) -> HttpResponse { router::live::clearrate(req) }
|
||||||
|
|
||||||
|
#[post("/api/live/continue")]
|
||||||
|
async fn live_continue(req: HttpRequest, body: String) -> HttpResponse { router::live::continuee(req, body) }
|
||||||
|
|
||||||
#[get("/api/mission")]
|
#[get("/api/mission")]
|
||||||
async fn mission(req: HttpRequest) -> HttpResponse { router::mission::mission(req) }
|
async fn mission(req: HttpRequest) -> HttpResponse { router::mission::mission(req) }
|
||||||
|
|
||||||
|
@ -254,6 +257,7 @@ async fn main() -> std::io::Result<()> {
|
||||||
.service(debug_error)
|
.service(debug_error)
|
||||||
.service(login_bonus)
|
.service(login_bonus)
|
||||||
.service(reward)
|
.service(reward)
|
||||||
|
.service(live_continue)
|
||||||
.service(live_guest)
|
.service(live_guest)
|
||||||
.service(live_mission)
|
.service(live_mission)
|
||||||
.service(live_ranking)
|
.service(live_ranking)
|
||||||
|
|
|
@ -33,6 +33,25 @@ pub fn get_item_info(id: i64) -> JsonValue {
|
||||||
ITEM_INFO[id.to_string()].clone()
|
ITEM_INFO[id.to_string()].clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn remove_gems(user: &mut JsonValue, amount: i64) {
|
||||||
|
let mut amount = amount;
|
||||||
|
let mut free = user["gem"]["free"].as_i64().unwrap();
|
||||||
|
let mut paid = user["gem"]["charge"].as_i64().unwrap();
|
||||||
|
|
||||||
|
free -= amount;
|
||||||
|
if free < 0 {
|
||||||
|
amount = -free;
|
||||||
|
free = 0;
|
||||||
|
}
|
||||||
|
paid -= amount;
|
||||||
|
if paid < 0 {
|
||||||
|
paid = 0;
|
||||||
|
}
|
||||||
|
user["gem"]["free"] = free.into();
|
||||||
|
user["gem"]["charge"] = paid.into();
|
||||||
|
user["gem"]["total"] = (free + paid).into();
|
||||||
|
}
|
||||||
|
|
||||||
fn get_uuid(input: &str) -> Option<String> {
|
fn get_uuid(input: &str) -> Option<String> {
|
||||||
let key = "sk1bdzb310n0s9tl";
|
let key = "sk1bdzb310n0s9tl";
|
||||||
let key_index = match input.find(key) {
|
let key_index = match input.find(key) {
|
||||||
|
|
|
@ -124,6 +124,22 @@ pub fn start(_req: HttpRequest, _body: String) -> HttpResponse {
|
||||||
global::send(resp)
|
global::send(resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn continuee(req: HttpRequest, body: String) -> HttpResponse {
|
||||||
|
let key = global::get_login(req.headers(), &body);
|
||||||
|
let mut user = userdata::get_acc(&key);
|
||||||
|
|
||||||
|
global::remove_gems(&mut user, 100);
|
||||||
|
|
||||||
|
userdata::save_acc(&key, user.clone());
|
||||||
|
|
||||||
|
let resp = object!{
|
||||||
|
"code": 0,
|
||||||
|
"server_time": global::timestamp(),
|
||||||
|
"gem": user["gem"].clone()
|
||||||
|
};
|
||||||
|
global::send(resp)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn update_live_data(user: &mut JsonValue, data: &JsonValue) -> JsonValue {
|
pub fn update_live_data(user: &mut JsonValue, data: &JsonValue) -> JsonValue {
|
||||||
if user["tutorial_step"].as_i32().unwrap() < 130 {
|
if user["tutorial_step"].as_i32().unwrap() < 130 {
|
||||||
return JsonValue::Null;
|
return JsonValue::Null;
|
||||||
|
|
Loading…
Add table
Reference in a new issue