Compare commits
10 commits
002070ad91
...
66c23ff582
Author | SHA1 | Date | |
---|---|---|---|
66c23ff582 | |||
330cddaf72 | |||
1a77c1e602 | |||
b826692764 | |||
b6a49a7080 | |||
61789f0165 | |||
|
a72a1e7dd6 | ||
541850128b | |||
4334c8dc22 | |||
1bdf0d5811 |
10 changed files with 200 additions and 63 deletions
|
@ -26,3 +26,5 @@ mime = "0.3.17"
|
||||||
sha2 = "0.10.8"
|
sha2 = "0.10.8"
|
||||||
include-flate-codegen = "0.3.0"
|
include-flate-codegen = "0.3.0"
|
||||||
libflate = "2.1.0"
|
libflate = "2.1.0"
|
||||||
|
serde_json = "1.0.120"
|
||||||
|
serde = { version = "1.0.204", features = ["derive"] }
|
||||||
|
|
|
@ -3,7 +3,7 @@ FROM docker.io/library/debian:latest as builder
|
||||||
# First - build
|
# First - build
|
||||||
|
|
||||||
RUN apt update && apt install -y curl libssl-dev perl git gcc make
|
RUN apt update && apt install -y curl libssl-dev perl git gcc make
|
||||||
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash
|
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash
|
||||||
RUN apt update && apt install -y nodejs
|
RUN apt update && apt install -y nodejs
|
||||||
RUN curl -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain stable --profile minimal
|
RUN curl -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain stable --profile minimal
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,13 @@ services:
|
||||||
DIRECTORY: /data/
|
DIRECTORY: /data/
|
||||||
HTTPS: false
|
HTTPS: false
|
||||||
NPPS4_ADDRESS: "http://127.0.0.1:51376"
|
NPPS4_ADDRESS: "http://127.0.0.1:51376"
|
||||||
|
|
||||||
|
#Everything below is for the "Help" page
|
||||||
|
ANDROID_GLOBAL: "link.to/patched/android/global.apk"
|
||||||
|
ANDROID_JAPAN: "link.to/patched/android/japan.apk"
|
||||||
|
IOS_GLOBAL: "link.to/ios/global.ipa"
|
||||||
|
IOS_JAPAN: "link.to/ios/japan.ipa"
|
||||||
|
ASSET_URL: "link.to/client/assets/"
|
||||||
ports:
|
ports:
|
||||||
- 8081:8081
|
- 8081:8081
|
||||||
volumes:
|
volumes:
|
||||||
|
|
|
@ -7,4 +7,4 @@ npps4="${NPPS4_ADDRESS:-http://127.0.0.1:51376}"
|
||||||
|
|
||||||
https=$([ "$HTTPS" = "true" ] && echo "--https" || echo "")
|
https=$([ "$HTTPS" = "true" ] && echo "--https" || echo "")
|
||||||
|
|
||||||
/root/ew/ew --path $directory --port $port --npps4 $npps4 $https
|
/root/ew/ew --path $directory --port $port --npps4 $npps4 $https --global-android "$ANDROID_GLOBAL" --japan-android "$ANDROID_JAPAN" --global-ios "$IOS_GLOBAL" --japan-ios "$IOS_JAPAN" --assets-url "$ASSET_URL"
|
||||||
|
|
|
@ -78,6 +78,8 @@ async fn api_req(req: HttpRequest, body: String) -> HttpResponse {
|
||||||
"/api/live/ranking" => clear_rate::ranking(req, body),
|
"/api/live/ranking" => clear_rate::ranking(req, body),
|
||||||
"/api/event" => event::event(req, body),
|
"/api/event" => event::event(req, body),
|
||||||
"/api/event/star_event" => event::star_event(req, body),
|
"/api/event/star_event" => event::star_event(req, body),
|
||||||
|
"/api/event/set/member" => event::set_member(req, body),
|
||||||
|
"/api/event/ranking" => event::ranking(req, body),
|
||||||
"/api/event_star_live/change_target_music" => event::change_target_music(req, body),
|
"/api/event_star_live/change_target_music" => event::change_target_music(req, body),
|
||||||
"/api/event_star_live/start" => live::event_start(req, body),
|
"/api/event_star_live/start" => live::event_start(req, body),
|
||||||
"/api/event_star_live/end" => live::event_end(req, body),
|
"/api/event_star_live/end" => live::event_end(req, body),
|
||||||
|
|
|
@ -82,6 +82,9 @@ lazy_static! {
|
||||||
}
|
}
|
||||||
info
|
info
|
||||||
};
|
};
|
||||||
|
pub static ref LIVES: JsonValue = {
|
||||||
|
json::parse(&include_file!("src/router/databases/json/live.json")).unwrap()
|
||||||
|
};
|
||||||
pub static ref MISSION_DATA: JsonValue = {
|
pub static ref MISSION_DATA: JsonValue = {
|
||||||
json::parse(&include_file!("src/router/databases/json/live_mission.json")).unwrap()
|
json::parse(&include_file!("src/router/databases/json/live_mission.json")).unwrap()
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,64 +1,190 @@
|
||||||
use json::{JsonValue, object};
|
use json::{JsonValue, object};
|
||||||
use actix_web::{HttpRequest};
|
use actix_web::HttpRequest;
|
||||||
|
use rand::Rng;
|
||||||
|
|
||||||
use crate::router::{userdata, global};
|
use crate::encryption;
|
||||||
|
use crate::include_file;
|
||||||
|
use crate::router::{userdata, global, databases};
|
||||||
|
|
||||||
pub fn event(req: HttpRequest, body: String) -> Option<JsonValue> {
|
fn get_event_data(key: &str, event_id: u32) -> JsonValue {
|
||||||
let key = global::get_login(req.headers(), &body);
|
let mut event = userdata::get_acc_event(key);
|
||||||
let mut event = userdata::get_acc_event(&key);
|
|
||||||
|
|
||||||
init_star_event(&mut event);
|
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();
|
||||||
userdata::save_acc_event(&key, event.clone());
|
let mut ev = event[event_id.to_string()].clone();
|
||||||
|
init_star_event(&mut ev);
|
||||||
Some(event["event_data"].clone())
|
save_event_data(key, event_id, ev);
|
||||||
|
event = userdata::get_acc_event(key);
|
||||||
|
}
|
||||||
|
event[event_id.to_string()].clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn switch_music(event: &mut JsonValue, music_id: i32, target_score: i64, index: i32) {
|
fn save_event_data(key: &str, event_id: u32, data: JsonValue) {
|
||||||
if index <= 4 {
|
let mut event = userdata::get_acc_event(key);
|
||||||
//todo
|
|
||||||
|
// Check for old version of event data
|
||||||
|
if !event["event_data"].is_empty() {
|
||||||
|
event = object!{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event[event_id.to_string()] = data;
|
||||||
|
|
||||||
|
userdata::save_acc_event(key, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_random_song() -> JsonValue {
|
||||||
|
let mut rng = rand::thread_rng();
|
||||||
|
let random_number = rng.gen_range(0..=databases::LIVES.len());
|
||||||
|
object!{
|
||||||
|
song: databases::LIVES[random_number]["masterMusicId"].clone(),
|
||||||
|
score: (databases::LIVES[random_number]["scoreC"].as_f64().unwrap() * 1.75).round() as i64
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn switch_music(event: &mut JsonValue, index: i32) {
|
||||||
|
if index > 5 || index < 1 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut i = 0;
|
||||||
|
for (j, live) in event["star_event"]["star_music_list"].members().enumerate() {
|
||||||
|
if live["position"] == index {
|
||||||
|
i = j;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if i != 0 {
|
||||||
|
event["star_event"]["star_music_list"].array_remove(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
let random_song = get_random_song();
|
||||||
let to_push = object!{
|
let to_push = object!{
|
||||||
master_music_id: music_id,
|
master_music_id: random_song["song"].clone(),
|
||||||
position: event["event_data"]["star_event"]["star_music_list"].len(),
|
position: index,
|
||||||
is_cleared: 0,
|
is_cleared: 0,
|
||||||
goal_score: target_score
|
goal_score: random_song["score"].clone()
|
||||||
};
|
};
|
||||||
event["event_data"]["star_event"]["star_music_list"].push(to_push).unwrap();
|
event["star_event"]["star_music_list"].push(to_push).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_star_event(event: &mut JsonValue) {
|
fn init_star_event(event: &mut JsonValue) {
|
||||||
if event["event_data"]["star_event"]["star_level"].as_i32().unwrap() != 0 {
|
if event["star_event"]["star_level"].as_i32().unwrap() != 0 {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event["event_data"]["star_event"]["star_level"] = 1.into();
|
event["star_event"]["star_level"] = 1.into();
|
||||||
switch_music(event, 1014, 53407, 5);
|
switch_music(event, 1);
|
||||||
switch_music(event, 2101, 34557, 5);
|
switch_music(event, 2);
|
||||||
switch_music(event, 2120, 38222, 5);
|
switch_music(event, 3);
|
||||||
switch_music(event, 2151, 46076, 5);
|
switch_music(event, 4);
|
||||||
switch_music(event, 2160, 21991, 5);
|
switch_music(event, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn event(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||||
|
let key = global::get_login(req.headers(), &body);
|
||||||
|
|
||||||
|
let body = &encryption::decrypt_packet(&body).unwrap();
|
||||||
|
let body: EventGet = serde_json::from_str(body).unwrap();
|
||||||
|
|
||||||
|
let event = get_event_data(&key, body.master_event_id);
|
||||||
|
|
||||||
|
Some(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn star_event(req: HttpRequest, body: String) -> Option<JsonValue> {
|
pub fn star_event(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||||
let key = global::get_login(req.headers(), &body);
|
let key = global::get_login(req.headers(), &body);
|
||||||
let mut event = userdata::get_acc_event(&key);
|
|
||||||
init_star_event(&mut event);
|
|
||||||
|
|
||||||
userdata::save_acc_event(&key, event.clone());
|
let body = &encryption::decrypt_packet(&body).unwrap();
|
||||||
|
let body: StarEvent = serde_json::from_str(body).unwrap();
|
||||||
|
|
||||||
|
let event = get_event_data(&key, body.master_event_id);
|
||||||
|
|
||||||
Some(object!{
|
Some(object!{
|
||||||
star_event: event["event_data"]["star_event"].clone(),
|
star_event: event["star_event"].clone(),
|
||||||
gift_list: [],
|
gift_list: [],
|
||||||
reward_list: []
|
reward_list: []
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo - randomize
|
|
||||||
pub fn change_target_music(req: HttpRequest, body: String) -> Option<JsonValue> {
|
pub fn change_target_music(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||||
let key = global::get_login(req.headers(), &body);
|
let key = global::get_login(req.headers(), &body);
|
||||||
let event = userdata::get_acc_event(&key);
|
|
||||||
|
|
||||||
//event["star_event"]["music_change_count"] += 1;
|
let body = &encryption::decrypt_packet(&body).unwrap();
|
||||||
|
let body: StarEventChangeTargetMusic = serde_json::from_str(body).unwrap();
|
||||||
|
|
||||||
Some(event["event_data"]["star_event"].clone())
|
let mut event = get_event_data(&key, body.master_event_id);
|
||||||
|
|
||||||
|
event["star_event"]["music_change_count"] = (event["star_event"]["music_change_count"].as_i32().unwrap() + 1).into();
|
||||||
|
|
||||||
|
switch_music(&mut event, body.position as i32);
|
||||||
|
|
||||||
|
save_event_data(&key, body.master_event_id, event.clone());
|
||||||
|
|
||||||
|
Some(event["star_event"].clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_member(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||||
|
let key = global::get_login(req.headers(), &body);
|
||||||
|
|
||||||
|
let body = &encryption::decrypt_packet(&body).unwrap();
|
||||||
|
let body: EventSetMember = serde_json::from_str(body).unwrap();
|
||||||
|
|
||||||
|
let mut event = get_event_data(&key, body.master_event_id);
|
||||||
|
|
||||||
|
event["member_ranking"] = object!{
|
||||||
|
master_character_id: body.master_character_id,
|
||||||
|
rank: 0,
|
||||||
|
point: 0
|
||||||
|
};
|
||||||
|
|
||||||
|
save_event_data(&key, body.master_event_id, event.clone());
|
||||||
|
|
||||||
|
Some(object!{
|
||||||
|
event_member: event["member_ranking"].clone()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn ranking(_req: HttpRequest, _body: String) -> Option<JsonValue> {
|
||||||
|
Some(object!{
|
||||||
|
ranking_detail_list: []
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start request structs
|
||||||
|
// These start with CJsonSendParam in the source
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
struct StarEventChangeTargetMusic {
|
||||||
|
master_event_id: u32,
|
||||||
|
position: u32
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
struct EventGet {
|
||||||
|
master_event_id: u32
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
struct EventSetMember {
|
||||||
|
master_event_id: u32,
|
||||||
|
master_character_id: u32
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
struct StarEvent {
|
||||||
|
master_event_id: u32
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
struct EventRankingGet {
|
||||||
|
master_event_id: u32,
|
||||||
|
ranking_type: i32,
|
||||||
|
ranking_group_type: i32,
|
||||||
|
user_id: u64,
|
||||||
|
start_rank: u32,
|
||||||
|
count: u64,
|
||||||
|
group_id: u64
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
|
@ -136,7 +136,7 @@ fn add_user_to_database(uid: i64, user: JsonValue, user_home: JsonValue, user_mi
|
||||||
));
|
));
|
||||||
DATABASE.lock_and_exec("INSERT INTO event (user_id, event) VALUES (?1, ?2)", params!(
|
DATABASE.lock_and_exec("INSERT INTO event (user_id, event) VALUES (?1, ?2)", params!(
|
||||||
uid,
|
uid,
|
||||||
include_file!("src/router/userdata/new_user_event.json")
|
"{}"
|
||||||
));
|
));
|
||||||
DATABASE.lock_and_exec("INSERT INTO eventloginbonus (user_id, eventloginbonus) VALUES (?1, ?2)", params!(
|
DATABASE.lock_and_exec("INSERT INTO eventloginbonus (user_id, eventloginbonus) VALUES (?1, ?2)", params!(
|
||||||
uid,
|
uid,
|
||||||
|
@ -254,7 +254,7 @@ pub fn get_acc_chats(auth_key: &str) -> JsonValue {
|
||||||
pub fn get_acc_event(auth_key: &str) -> JsonValue {
|
pub fn get_acc_event(auth_key: &str) -> JsonValue {
|
||||||
let event = get_data(auth_key, "event");
|
let event = get_data(auth_key, "event");
|
||||||
if event.is_empty() {
|
if event.is_empty() {
|
||||||
return json::parse(&include_file!("src/router/userdata/new_user_event.json")).unwrap();
|
return object!{};
|
||||||
}
|
}
|
||||||
event
|
event
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
"event_data": {
|
|
||||||
"point_ranking": {
|
"point_ranking": {
|
||||||
"point": 0
|
"point": 0
|
||||||
},
|
},
|
||||||
|
@ -19,6 +18,4 @@
|
||||||
"star_event_play_times_bonus_count": 0,
|
"star_event_play_times_bonus_count": 0,
|
||||||
"star_assist_bonus": 1
|
"star_assist_bonus": 1
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"server_event_data": {}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue