From f004ca856574ed60c90ccaf94f2c6bceed769a5f Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Sun, 2 Mar 2025 09:52:44 -0500 Subject: [PATCH] Stub out payment store web server #9, implement/fix last of login process #8 --- Cargo.lock | 10 ++++++ Cargo.toml | 2 +- rc_microtransactions/Cargo.toml | 10 ++++++ rc_microtransactions/Rocket.toml | 12 +++++++ rc_microtransactions/build_arm64.sh | 3 ++ rc_microtransactions/run_debug.sh | 3 ++ rc_microtransactions/src/main.rs | 14 ++++++++ rc_microtransactions/src/robocraft/mod.rs | 7 ++++ rc_microtransactions/src/robocraft/store.rs | 17 ++++++++++ .../src/operations/custom_games_maps.rs | 34 +++++++++---------- .../src/operations/game_event_params.rs | 4 +-- rc_services_room/src/operations/mod.rs | 3 ++ .../src/operations/reconnect_game.rs | 12 +++++++ .../src/operations/robot_sanction.rs | 11 ++++++ rc_static_data/src/robocraft/live_data.rs | 2 +- 15 files changed, 123 insertions(+), 21 deletions(-) create mode 100644 rc_microtransactions/Cargo.toml create mode 100644 rc_microtransactions/Rocket.toml create mode 100755 rc_microtransactions/build_arm64.sh create mode 100755 rc_microtransactions/run_debug.sh create mode 100644 rc_microtransactions/src/main.rs create mode 100644 rc_microtransactions/src/robocraft/mod.rs create mode 100644 rc_microtransactions/src/robocraft/store.rs create mode 100644 rc_services_room/src/operations/reconnect_game.rs diff --git a/Cargo.lock b/Cargo.lock index a0d83ad..2341b66 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1781,6 +1781,16 @@ dependencies = [ "tokio", ] +[[package]] +name = "rc_microtransactions" +version = "0.1.0" +dependencies = [ + "env_logger", + "libfj", + "log", + "rocket", +] + [[package]] name = "rc_services" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 8cefe9d..21f4690 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ members = [ "auth", "polariton_auth", "rc_services", "rc_services_room", - "rc_static_data", + "rc_static_data", "rc_microtransactions", "rc_social", "rc_social_room", "rc_chat", "rc_chat_room" ] diff --git a/rc_microtransactions/Cargo.toml b/rc_microtransactions/Cargo.toml new file mode 100644 index 0000000..66cfaca --- /dev/null +++ b/rc_microtransactions/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "rc_microtransactions" +version = "0.1.0" +edition = "2021" + +[dependencies] +rocket.workspace = true +libfj.workspace = true +log.workspace = true +env_logger.workspace = true diff --git a/rc_microtransactions/Rocket.toml b/rc_microtransactions/Rocket.toml new file mode 100644 index 0000000..1143669 --- /dev/null +++ b/rc_microtransactions/Rocket.toml @@ -0,0 +1,12 @@ +## defaults for _all_ profiles +[default] +address = "127.0.0.1" +port = 8011 + +## set only when compiled in debug mode, i.e, `cargo build` +[debug] +port = 8011 + +## set only when compiled in release mode, i.e, `cargo build --release` +[release] +address = "0.0.0.0" diff --git a/rc_microtransactions/build_arm64.sh b/rc_microtransactions/build_arm64.sh new file mode 100755 index 0000000..7010ff6 --- /dev/null +++ b/rc_microtransactions/build_arm64.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +cargo build --release --target aarch64-unknown-linux-musl diff --git a/rc_microtransactions/run_debug.sh b/rc_microtransactions/run_debug.sh new file mode 100755 index 0000000..6351ef2 --- /dev/null +++ b/rc_microtransactions/run_debug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +#cargo build +RUST_LOG=debug cargo run diff --git a/rc_microtransactions/src/main.rs b/rc_microtransactions/src/main.rs new file mode 100644 index 0000000..461238e --- /dev/null +++ b/rc_microtransactions/src/main.rs @@ -0,0 +1,14 @@ +mod robocraft; + +#[rocket::get("/")] +fn index() -> &'static str { + "Hello, world!" +} + +#[rocket::launch] +fn rocket() -> _ { + env_logger::init(); + rocket::build().mount("/", rocket::routes![index]) + .attach(robocraft::stage()) +} + diff --git a/rc_microtransactions/src/robocraft/mod.rs b/rc_microtransactions/src/robocraft/mod.rs new file mode 100644 index 0000000..3e93e82 --- /dev/null +++ b/rc_microtransactions/src/robocraft/mod.rs @@ -0,0 +1,7 @@ +mod store; + +pub fn stage() -> rocket::fairing::AdHoc { + rocket::fairing::AdHoc::on_ignite("JSON", |rocket| async { + rocket.attach(store::stage()) + }) +} diff --git a/rc_microtransactions/src/robocraft/store.rs b/rc_microtransactions/src/robocraft/store.rs new file mode 100644 index 0000000..272a61c --- /dev/null +++ b/rc_microtransactions/src/robocraft/store.rs @@ -0,0 +1,17 @@ +use rocket::{post, routes, serde::json::{json, Value}}; + +#[post("/robopay/store")] +pub fn robopay_store() -> Value { + // TODO authentication (Authorization header is "Robocraft {JWT token from auth}") + json!({ + "response": { + "data": [] + } + }) +} + +pub fn stage() -> rocket::fairing::AdHoc { + rocket::fairing::AdHoc::on_ignite("Robocraft store info", |rocket| async { + rocket.mount("/", routes![robopay_store]) + }) +} diff --git a/rc_services_room/src/operations/custom_games_maps.rs b/rc_services_room/src/operations/custom_games_maps.rs index 8944d82..354223b 100644 --- a/rc_services_room/src/operations/custom_games_maps.rs +++ b/rc_services_room/src/operations/custom_games_maps.rs @@ -14,17 +14,17 @@ pub(super) fn allowed_maps_provider() -> SimpleFunc<146, crate::UserTy, impl (Fn val_ty: 122, // obj arr items: vec![ (Typed::Str(GameMode::BattleArena.as_str().into()), Typed::ObjArr(vec![ - Typed::Str("Assets/Scenes/Planet_Neptune/RC_Planet_Neptune_02_BA".into()), - Typed::Str("Assets/Scenes/Planet_Mars/RC_Planet_Mars_03_BA".into()), - Typed::Str("Assets/Scenes/Planet_Mars/RC_Planet_Mars_02_BA".into()), - Typed::Str("Assets/Scenes/Planet_Earth/RC_Planet_Earth_02_BA".into()), - Typed::Str("Assets/Scenes/Planet_Earth/RC_Planet_Earth_01_BA".into()), - Typed::Str("Assets/Scenes/Planet_Neptune/RC_Planet_Neptune_03_BA".into()), + Typed::Str("RC_Planet_Neptune_02_BA".into()), + Typed::Str("RC_Planet_Mars_03_BA".into()), + Typed::Str("RC_Planet_Mars_02_BA".into()), + Typed::Str("RC_Planet_Earth_02_BA".into()), + Typed::Str("RC_Planet_Earth_01_BA".into()), + Typed::Str("RC_Planet_Neptune_03_BA".into()), ].into()) ), (Typed::Str(GameMode::TeamDeathmatch.as_str().into()), Typed::ObjArr(vec![ - Typed::Str("Assets/Scenes/Planet_Neptune/RC_Planet_Neptune_01_CTF".into()), - Typed::Str("Assets/Scenes/Planet_Mars/RC_Planet_Mars_01_CTF".into()), + Typed::Str("RC_Planet_Neptune_01_CTF".into()), + Typed::Str("RC_Planet_Mars_01_CTF".into()), ].into()) ), ], @@ -33,15 +33,15 @@ pub(super) fn allowed_maps_provider() -> SimpleFunc<146, crate::UserTy, impl (Fn key_ty: 115, // str val_ty: 115, // str items: vec![ - (Typed::Str("Assets/Scenes/Planet_Neptune/RC_Planet_Neptune_02_BA".into()), Typed::Str("strCustomGameMapNameRC_Planet_Neptune_02_BA".into())), - (Typed::Str("Assets/Scenes/Planet_Neptune/RC_Planet_Neptune_01_CTF".into()), Typed::Str("strCustomGameMapNameRC_Planet_Neptune_01_CTF".into())), - (Typed::Str("Assets/Scenes/Planet_Mars/RC_Planet_Mars_03_BA".into()), Typed::Str("strCustomGameMapNameRC_Planet_Mars_03_BA".into())), - (Typed::Str("Assets/Scenes/Planet_Mars/RC_Planet_Mars_02_BA".into()), Typed::Str("strCustomGameMapNameRC_Planet_Mars_02_BA".into())), - (Typed::Str("Assets/Scenes/Planet_Mars/RC_Planet_Mars_01_CTF".into()), Typed::Str("strCustomGameMapNameRC_Planet_Mars_01_CTF".into())), - (Typed::Str("Assets/Scenes/Planet_Earth/RC_Planet_Earth_02_BA".into()), Typed::Str("strCustomGameMapNameRC_Planet_Earth_02_BA".into())), - (Typed::Str("Assets/Scenes/Planet_Earth/RC_Planet_Earth_01_BA".into()), Typed::Str("strCustomGameMapNameRC_Planet_Earth_01_BA".into())), - (Typed::Str("Assets/Scenes/Planet_Neptune/RC_Planet_Neptune_03_BA".into()), Typed::Str("strCustomGameMapNameRC_Planet_Neptune_03_BA".into())), - (Typed::Str("Assets/Scenes/Planet_Test/TestRobot".into()), Typed::Str("TestRobot".into())), + (Typed::Str("RC_Planet_Neptune_02_BA".into()), Typed::Str("strCustomGameMapNameRC_Planet_Neptune_02_BA".into())), + (Typed::Str("RC_Planet_Neptune_01_CTF".into()), Typed::Str("strCustomGameMapNameRC_Planet_Neptune_01_CTF".into())), + (Typed::Str("RC_Planet_Mars_03_BA".into()), Typed::Str("strCustomGameMapNameRC_Planet_Mars_03_BA".into())), + (Typed::Str("RC_Planet_Mars_02_BA".into()), Typed::Str("strCustomGameMapNameRC_Planet_Mars_02_BA".into())), + (Typed::Str("RC_Planet_Mars_01_CTF".into()), Typed::Str("strCustomGameMapNameRC_Planet_Mars_01_CTF".into())), + (Typed::Str("RC_Planet_Earth_02_BA".into()), Typed::Str("strCustomGameMapNameRC_Planet_Earth_02_BA".into())), + (Typed::Str("RC_Planet_Earth_01_BA".into()), Typed::Str("strCustomGameMapNameRC_Planet_Earth_01_BA".into())), + (Typed::Str("RC_Planet_Neptune_03_BA".into()), Typed::Str("strCustomGameMapNameRC_Planet_Neptune_03_BA".into())), + (Typed::Str("TestRobot".into()), Typed::Str("TestRobot".into())), ], })); Ok(params.into()) diff --git a/rc_services_room/src/operations/game_event_params.rs b/rc_services_room/src/operations/game_event_params.rs index 89d02cb..32f88de 100644 --- a/rc_services_room/src/operations/game_event_params.rs +++ b/rc_services_room/src/operations/game_event_params.rs @@ -15,8 +15,8 @@ pub(super) fn event_system_params_provider() -> SimpleFunc<24, crate::UserTy, im params.insert(MAP_NAMES_PARAM_KEY, Typed::Arr(Arr { ty: 115, // str items: vec![ - Typed::Str("Assets/Scenes/Planet_Neptune/RC_Planet_Neptune_03_BA".into()), - Typed::Str("Assets/Scenes/Planet_Earth/RC_Planet_Earth_01_BA".into()), + Typed::Str("RC_Planet_Neptune_03_BA".into()), + Typed::Str("RC_Planet_Earth_01_BA".into()), ], })); params.insert(VISIBILITY_PARAM_KEY, Typed::Arr(Arr { diff --git a/rc_services_room/src/operations/mod.rs b/rc_services_room/src/operations/mod.rs index 073bf8a..2f4de58 100644 --- a/rc_services_room/src/operations/mod.rs +++ b/rc_services_room/src/operations/mod.rs @@ -71,6 +71,7 @@ mod daily_quests; mod cube_awards; mod robot_sanction; mod building_xp; +mod reconnect_game; use polariton_server::operations::OperationsHandler; @@ -155,5 +156,7 @@ pub fn handler() -> OperationsHandler { .without_state(cube_awards::cube_awards_provider()) .without_state(robot_sanction::robot_sanction_provider()) .without_state(building_xp::building_xp_save_provider()) + .without_state(robot_sanction::all_robot_sanctions_provider()) + .without_state(reconnect_game::available_reconnect_provider()) //.without_state(polariton_server::operations::Ack::<70, _>::default()) } diff --git a/rc_services_room/src/operations/reconnect_game.rs b/rc_services_room/src/operations/reconnect_game.rs new file mode 100644 index 0000000..7080e30 --- /dev/null +++ b/rc_services_room/src/operations/reconnect_game.rs @@ -0,0 +1,12 @@ +use polariton_server::operations::SimpleFunc; +use polariton::operation::{ParameterTable, Typed}; + +const PARAM_KEY: u8 = 207; + +pub(super) fn available_reconnect_provider() -> SimpleFunc<171, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result) + Sync + Sync> { + SimpleFunc::new(|params, _| { + let mut params = params.to_dict(); + params.insert(PARAM_KEY, Typed::Bool(false.into())); + Ok(params.into()) + }) +} diff --git a/rc_services_room/src/operations/robot_sanction.rs b/rc_services_room/src/operations/robot_sanction.rs index 9accdea..6ba47da 100644 --- a/rc_services_room/src/operations/robot_sanction.rs +++ b/rc_services_room/src/operations/robot_sanction.rs @@ -17,3 +17,14 @@ pub(super) fn robot_sanction_provider() -> SimpleFunc<174, crate::UserTy, impl ( Ok(params.into()) }) } + +pub(super) fn all_robot_sanctions_provider() -> SimpleFunc<176, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result) + Sync + Sync> { + SimpleFunc::new(|params, _| { + let mut params = params.to_dict(); + params.insert(SANCTION_JSONS_PARAM_KEY, Typed::Arr(Arr { + ty: 115, // str + items: Vec::default(), + })); + Ok(params.into()) + }) +} diff --git a/rc_static_data/src/robocraft/live_data.rs b/rc_static_data/src/robocraft/live_data.rs index 1f81d55..e25fdab 100644 --- a/rc_static_data/src/robocraft/live_data.rs +++ b/rc_static_data/src/robocraft/live_data.rs @@ -16,7 +16,7 @@ pub fn static_live_data() -> Json { ErrorLogAddress: "logs.freejamgames.com:4561".into(), ServerErrorLogAddress: "logs.freejamgames.com:4562".into(), authUrl: "http://127.0.0.1:8001/".into(), // originally "https://auth-backend.freejamgames.com/" - paymentUrl: "https://pay.robocraftgame.com/".into(), + paymentUrl: "http://127.0.0.1:8011/".into(), enterBattleLogGenerationTimeout: "60".into(), GameServerConnectionTestTimeout: 10, AvatarCdnUrl: "https://rc-cdn-images.robocraftgame.com/customavatar/Live/".into(),