Compare commits
No commits in common. "591c0a5ac724b6e5d4ffac7e94c363ae5e3216fa" and "29128094e71dfa640304be26c2b439fb0bbc2493" have entirely different histories.
591c0a5ac7
...
29128094e7
3 changed files with 27 additions and 131 deletions
|
@ -26,7 +26,6 @@ pub mod exchange;
|
|||
pub mod items;
|
||||
pub mod databases;
|
||||
pub mod location;
|
||||
pub mod event_ranking;
|
||||
|
||||
use actix_web::{
|
||||
HttpResponse,
|
||||
|
|
|
@ -12,7 +12,7 @@ const STAR_EVENT_IDS: [u32; 3] = [127, 135, 139];
|
|||
fn get_event_data(key: &str, event_id: u32) -> JsonValue {
|
||||
let mut event = userdata::get_acc_event(key);
|
||||
let is_star_event = STAR_EVENT_IDS.contains(&event_id);
|
||||
//println!("is_star_event: {}, {}", is_star_event, event_id);
|
||||
println!("is_star_event: {}, {}", is_star_event, event_id);
|
||||
|
||||
if event[event_id.to_string()].is_empty() {
|
||||
event[event_id.to_string()] = json::parse(&include_file!("src/router/userdata/new_user_event.json")).unwrap();
|
||||
|
@ -28,7 +28,6 @@ fn get_event_data(key: &str, event_id: u32) -> JsonValue {
|
|||
event["star_last_reset"][event_id.to_string()] = (global::timestamp_since_midnight() + (24 * 60 * 60)).into();
|
||||
event[event_id.to_string()]["star_event"]["star_event_bonus_daily_count"] = 0.into();
|
||||
}
|
||||
|
||||
event[event_id.to_string()].clone()
|
||||
}
|
||||
|
||||
|
@ -98,66 +97,21 @@ pub fn event(req: HttpRequest, body: String) -> Option<JsonValue> {
|
|||
let body = &encryption::decrypt_packet(&body).unwrap();
|
||||
let body: EventGet = serde_json::from_str(body).unwrap();
|
||||
|
||||
let mut event = get_event_data(&key, body.master_event_id);
|
||||
|
||||
let is_star_event = STAR_EVENT_IDS.contains(&body.master_event_id);
|
||||
|
||||
if is_star_event {
|
||||
let user = userdata::get_acc(&key);
|
||||
let old = event["star_event"]["star_level"].as_i64().unwrap();
|
||||
event["star_event"]["star_level"] = get_star_rank(get_points(body.master_event_id, &user)).into();
|
||||
let leveled = old != event["star_event"]["star_level"].as_i64().unwrap();
|
||||
|
||||
let mut all_clear = 1;
|
||||
for data in event["star_event"]["star_music_list"].members() {
|
||||
if data["is_cleared"] == 0 {
|
||||
all_clear = 0;
|
||||
}
|
||||
}
|
||||
if all_clear == 1 {
|
||||
event["star_event"]["star_music_list"] = array![];
|
||||
switch_music(&mut event, 1);
|
||||
switch_music(&mut event, 2);
|
||||
switch_music(&mut event, 3);
|
||||
switch_music(&mut event, 4);
|
||||
switch_music(&mut event, 5);
|
||||
save_event_data(&key, body.master_event_id, event.clone());
|
||||
}
|
||||
|
||||
|
||||
event["point_ranking"]["point"] = get_points(body.master_event_id, &user).into();
|
||||
event["point_ranking"]["rank"] = get_rank(body.master_event_id, user["user"]["id"].as_u64().unwrap()).into();
|
||||
|
||||
if leveled {
|
||||
save_event_data(&key, body.master_event_id, event.clone());
|
||||
event["star_event"]["is_star_event_update"] = 1.into();
|
||||
} else {
|
||||
save_event_data(&key, body.master_event_id, event.clone());
|
||||
}
|
||||
}
|
||||
let event = get_event_data(&key, body.master_event_id);
|
||||
|
||||
Some(event)
|
||||
}
|
||||
|
||||
pub fn star_event(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let user = userdata::get_acc(&key);
|
||||
|
||||
let body = &encryption::decrypt_packet(&body).unwrap();
|
||||
let body: StarEvent = serde_json::from_str(body).unwrap();
|
||||
|
||||
let mut event = get_event_data(&key, body.master_event_id);
|
||||
|
||||
let mut star_event = event["star_event"].clone();
|
||||
star_event["is_inherited_level_reward"] = 0.into();
|
||||
|
||||
event["star_event"]["star_level"] = get_star_rank(get_points(body.master_event_id, &user)).into();
|
||||
star_event["is_star_level_up"] = 1.into();
|
||||
|
||||
save_event_data(&key, body.master_event_id, event.clone());
|
||||
let event = get_event_data(&key, body.master_event_id);
|
||||
|
||||
Some(object!{
|
||||
star_event: star_event,
|
||||
star_event: event["star_event"].clone(),
|
||||
gift_list: [],
|
||||
reward_list: []
|
||||
})
|
||||
|
@ -201,82 +155,18 @@ pub fn set_member(req: HttpRequest, body: String) -> Option<JsonValue> {
|
|||
})
|
||||
}
|
||||
|
||||
fn get_rank(event: u32, user_id: u64) -> u32 {
|
||||
let scores = crate::router::event_ranking::get_raw_info(event);
|
||||
|
||||
let mut i=1;
|
||||
for score in scores.members() {
|
||||
if score["user"] == user_id {
|
||||
return i;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
0
|
||||
}
|
||||
|
||||
pub fn ranking(_req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let body = &encryption::decrypt_packet(&body).unwrap();
|
||||
let body: EventRankingGet = serde_json::from_str(body).unwrap();
|
||||
let scores = crate::router::event_ranking::get_scores_json()[body.master_event_id.to_string()].clone();
|
||||
let mut rv = array![];
|
||||
let mut i=1;
|
||||
let start = if body.user_id == 0 { body.start_rank } else { get_rank(body.master_event_id, body.user_id) };
|
||||
for score in scores.members() {
|
||||
if i >= start && start + body.count >= i {
|
||||
rv.push(score.clone()).unwrap();
|
||||
i += 1;
|
||||
}
|
||||
if start + body.count >= i {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ranking(_req: HttpRequest, _body: String) -> Option<JsonValue> {
|
||||
Some(object!{
|
||||
ranking_detail_list: rv
|
||||
ranking_detail_list: []
|
||||
})
|
||||
}
|
||||
|
||||
const POINTS_PER_LEVEL: i64 = 65;
|
||||
const POINTS_PER_LEVEL: i64 = 55;
|
||||
|
||||
fn get_star_rank(points: i64) -> i64 {
|
||||
((points - (points % POINTS_PER_LEVEL)) / POINTS_PER_LEVEL) + 1
|
||||
}
|
||||
|
||||
const LIMIT_COINS: i64 = 2000000000;
|
||||
|
||||
fn give_event_points(event_id: u32, amount: i64, user: &mut JsonValue) -> bool {
|
||||
let mut has = false;
|
||||
for data in user["event_point_list"].members_mut() {
|
||||
if data["type"] == 1 {
|
||||
has = true;
|
||||
let new_amount = data["amount"].as_i64().unwrap() + amount;
|
||||
if new_amount > LIMIT_COINS {
|
||||
return true;
|
||||
}
|
||||
data["amount"] = new_amount.into();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if !has {
|
||||
user["event_point_list"].push(object!{
|
||||
master_event_id: event_id,
|
||||
type: 1,
|
||||
amount: amount,
|
||||
reward_status: []
|
||||
}).unwrap();
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
fn get_points(event_id: u32, user: &JsonValue) -> i64 {
|
||||
for data in user["event_point_list"].members() {
|
||||
if data["type"] == 1 && data["master_event_id"] == event_id {
|
||||
return data["amount"].as_i64().unwrap()
|
||||
}
|
||||
}
|
||||
0
|
||||
}
|
||||
|
||||
pub fn event_live(req: HttpRequest, body: String, skipped: bool) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body_temp = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
|
@ -290,7 +180,6 @@ pub fn event_live(req: HttpRequest, body: String, skipped: bool) -> Option<JsonV
|
|||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let mut event = get_event_data(&key, event_id);
|
||||
let mut user = userdata::get_acc(&key);
|
||||
|
||||
let live_id = databases::LIVE_LIST[body["master_live_id"].to_string()]["masterMusicId"].as_i64().unwrap();
|
||||
let raw_score = body["live_score"]["score"].as_u64().unwrap_or(resp["high_score"].as_u64().unwrap());
|
||||
|
@ -311,16 +200,23 @@ pub fn event_live(req: HttpRequest, body: String, skipped: bool) -> Option<JsonV
|
|||
}
|
||||
}
|
||||
|
||||
if all_clear == 1 {
|
||||
switch_music(&mut event, 1);
|
||||
switch_music(&mut event, 2);
|
||||
switch_music(&mut event, 3);
|
||||
switch_music(&mut event, 4);
|
||||
switch_music(&mut event, 5);
|
||||
}
|
||||
|
||||
if cleared {
|
||||
event["star_event"]["star_event_bonus_daily_count"] = (event["star_event"]["star_event_bonus_daily_count"].as_u32().unwrap() + 1).into();
|
||||
event["star_event"]["star_event_bonus_count"] = (event["star_event"]["star_event_bonus_count"].as_u32().unwrap() + 1).into();
|
||||
event["star_event"]["star_event_play_times_bonus_count"] = (event["star_event"]["star_event_play_times_bonus_count"].as_u32().unwrap() + 1).into();
|
||||
|
||||
give_event_points(event_id, 31, &mut user);
|
||||
userdata::save_acc(&key, user.clone());
|
||||
}
|
||||
|
||||
crate::router::event_ranking::live_completed(event_id, user["user"]["id"].as_i64().unwrap(), get_points(event_id, &user), event["star_event"]["star_level"].as_i64().unwrap());
|
||||
event["point_ranking"]["point"] = (event["point_ranking"]["point"].as_i64().unwrap_or(0) + 31).into();
|
||||
event["star_event"]["star_level"] = get_star_rank(event["point_ranking"]["point"].as_i64().unwrap()).into();
|
||||
}
|
||||
|
||||
resp["star_event_bonus_list"] = object!{
|
||||
"star_event_bonus": bonus_event,
|
||||
|
@ -331,12 +227,11 @@ pub fn event_live(req: HttpRequest, body: String, skipped: bool) -> Option<JsonV
|
|||
"card_bonus_score": 0
|
||||
};
|
||||
|
||||
|
||||
resp["event_point_list"] = user["event_point_list"].clone();
|
||||
resp["event_point_list"] = array![];
|
||||
resp["event_ranking_data"] = object! {
|
||||
"event_point_rank": event["point_ranking"]["point"].clone(),
|
||||
"next_reward_rank_point": 0,
|
||||
"event_score_rank": get_rank(event_id, user["user"]["id"].as_u64().unwrap()),
|
||||
"event_score_rank": 0,
|
||||
"next_reward_rank_score": 0,
|
||||
"next_reward_rank_level": 0
|
||||
};
|
||||
|
@ -349,7 +244,7 @@ pub fn event_live(req: HttpRequest, body: String, skipped: bool) -> Option<JsonV
|
|||
|
||||
save_event_data(&key, event_id, event);
|
||||
|
||||
//println!("{}", resp);
|
||||
println!("{}", resp);
|
||||
Some(resp)
|
||||
}
|
||||
|
||||
|
@ -388,6 +283,7 @@ struct StarEvent {
|
|||
master_event_id: u32
|
||||
}
|
||||
|
||||
/*
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct EventRankingGet {
|
||||
master_event_id: u32,
|
||||
|
@ -395,6 +291,7 @@ struct EventRankingGet {
|
|||
ranking_group_type: i32,
|
||||
user_id: u64,
|
||||
start_rank: u32,
|
||||
count: u32,
|
||||
count: u64,
|
||||
group_id: u64
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -66,19 +66,19 @@ function Help() {
|
|||
<p>Works well enough. The server itself takes up not even 20mb of storage, and it's written in rust. I personally think it's pretty well written.</p>
|
||||
|
||||
<h2>Could my computer/laptop run a server?</h2>
|
||||
<p>Very very likely. If the platform is <a href="https://doc.rust-lang.org/nightly/rustc/platform-support.html">supported by rust</a>, then the answer is yes! It is recommended to manually compile the project until I get the time to setup actions. <a href="https://git.ethanthesleepy.one/ethanaobrien/ew">ew repo</a></p>
|
||||
<p>Very very likely. If the platform is <a href="https://doc.rust-lang.org/nightly/rustc/platform-support.html">supported by rust</a>, then the answer is yes! It is recommended to manually compile the project until I get the time to setup GitHub actions. <a href="https://github.com/ethanaobrien/ew">ew github repo</a></p>
|
||||
|
||||
<h2>Is the server down right now? I can't connect</h2>
|
||||
<p>Assuming you have just loaded this page on the server you use, then the answer is no, otherwise please contact your server admin.</p>
|
||||
|
||||
<h2>Do events work?</h2>
|
||||
<p>Most events do not, though most should not crash the game. Star events are partially implemented. You can get your rank up, and compete with other players in a ranking table, but no rewards are currently implemented.</p>
|
||||
<p>No, sadly events are the only thing not implemented, and it's not entirely on my road map either. If you want it to happen, feel free to contribute.</p>
|
||||
|
||||
<h2>But then, how do I get event URs?</h2>
|
||||
<p>There are serial codes for several things, one of which includes all the event URs. I don't remember what does what but it is recommended to look at the serial code file to get the latest codes.</p>
|
||||
|
||||
<h2>Why does the game crash when I do x?</h2>
|
||||
<p>This likely means something on the server is broken. If you're self hosting, please contact me via matrix. Otherwise, contact your server admin and ask them to report the issue.</p>
|
||||
<p>This likely means something on the server is broken. If you're self hosting, please open a GitHub issue. Otherwise, contact your server admin and ask them to report the issue.</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue