mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Complete factory rating support
This commit is contained in:
@@ -47,6 +47,10 @@ async fn do_handling(params: ParameterTable<()>, user: &crate::UserTy, factory:
|
||||
};
|
||||
user_info.save_slot(to_save, cpu_counter).await?;
|
||||
user_info.currency_debit(oj_rc_core::persist::user::CurrencyType::Free, free_cost as _).await?;
|
||||
factory.purchase(factory_id).await.map_err(|e| {
|
||||
log::error!("Failed to track factory purchase of vehicle {}: {}", factory_id, e);
|
||||
oj_rc_core::data::error_codes::WebServicesError::DatabaseError as i16
|
||||
})?;
|
||||
if paid_cost > 0 {
|
||||
user_info.currency_debit(oj_rc_core::persist::user::CurrencyType::Paid, paid_cost as _).await?;
|
||||
}
|
||||
|
||||
47
rc_services_room/src/operations/crf_rate_vehicle.rs
Normal file
47
rc_services_room/src/operations/crf_rate_vehicle.rs
Normal file
@@ -0,0 +1,47 @@
|
||||
use polariton_server::operations::{SimpleOpError, SimpleOperation, SimpleOpImpl};
|
||||
use polariton::operation::{ParameterTable, Typed};
|
||||
use oj_rc_factory::VehicleFactoryAdapter;
|
||||
|
||||
const CODE: u8 = 90;
|
||||
|
||||
const SLOT_PARAM_KEY: u8 = 43; // int; in
|
||||
const COMBAT_PARAM_KEY: u8 = 97; // int; in
|
||||
const COSMETIC_PARAM_KEY: u8 = 98; // bool; int
|
||||
//const BUILD_NUMBER_PARAM_KEY: u8 = 99; // str; in
|
||||
|
||||
pub(super) struct CrfItemRater {
|
||||
factory: std::sync::Arc<oj_rc_core::factory::Factory>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl SimpleOperation<()> for CrfItemRater {
|
||||
type User = crate::UserTy;
|
||||
const CODE: u8 = CODE;
|
||||
|
||||
async fn handle(&self, mut params: ParameterTable, user: &Self::User) -> Result<ParameterTable, SimpleOpError> {
|
||||
if let Some(Typed::Int(slot)) = params.remove(&SLOT_PARAM_KEY) {
|
||||
if let Some(Typed::Int(combat_rating)) = params.remove(&COMBAT_PARAM_KEY) {
|
||||
if let Some(Typed::Int(cosmetic_rating)) = params.remove(&COSMETIC_PARAM_KEY) {
|
||||
log::warn!("Slot {}", slot);
|
||||
let user_info = user.user()?;
|
||||
if let Some(factory_id) = user_info.rate_vehicle(slot, combat_rating, cosmetic_rating).await? {
|
||||
self.factory.rate_vehicle(factory_id, combat_rating, cosmetic_rating).await.map_err(|e| {
|
||||
log::error!("Failed to rate factory vehicle {}: {}", factory_id, e);
|
||||
SimpleOpError::with_message(
|
||||
oj_rc_core::data::error_codes::WebServicesError::DatabaseError as i16,
|
||||
format!("Failed to rate factory vehicle: {}", e),
|
||||
)
|
||||
})?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(params)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn crf_rating_provider(factory: &std::sync::Arc<oj_rc_core::factory::Factory>) -> SimpleOpImpl<(), crate::UserTy, CrfItemRater> {
|
||||
SimpleOpImpl::new(CrfItemRater {
|
||||
factory: factory.to_owned(),
|
||||
})
|
||||
}
|
||||
@@ -101,6 +101,7 @@ mod steam_promo;
|
||||
mod campaign_save_result;
|
||||
mod item_shop_purchase;
|
||||
mod code_redeem;
|
||||
mod crf_rate_vehicle;
|
||||
|
||||
use polariton_server::operations::OperationsHandler;
|
||||
|
||||
@@ -222,7 +223,7 @@ pub fn handler(init_ctx: &crate::InitConfig) -> OperationsHandler<crate::UserTy>
|
||||
.add(garage_slot_name::garage_slot_rename_provider())
|
||||
.add(garage_slot_copy::garage_slot_copy_provider())
|
||||
.add(polariton_server::operations::Ack::<12, _>::default()) // TODO handle UpdatePlayerDailyQuestProgressRequest instead of ignoring it
|
||||
.add(polariton_server::operations::Ack::<90, _>::default()) // TODO handle SubmitCRFRatingRequest instead of ignoring it
|
||||
.add(crf_rate_vehicle::crf_rating_provider(&init_ctx.factory))
|
||||
//.add(polariton_server::operations::Ack::<97, _>::default()) // TODO handle UpdateShopRobotOffsetRequest instead of ignoring it (this seems to break newly-uploaded vehicles for now)
|
||||
.add(steam_promo::steam_promos_provider())
|
||||
.add(item_shop_purchase::item_purchase_provider(&init_ctx.cubes))
|
||||
|
||||
Reference in New Issue
Block a user