Implement factory in main database, close #80

This commit is contained in:
NG (Graham) committed 2026-02-01 18:14:16 -05:00
1 parent a346299de8
commit 3b909327d8
33 files changed
+741 -78

No files matched your search

+4
View File
@@ -41,6 +41,10 @@ impl AccountProvider {
})
}
pub fn factory_impl(&self) -> oj_rc_database::FactoryDatabase {
self.db.vehicle_factory(self.cdn.clone())
}
pub async fn multiplayer_init(&self) -> Result<(), oj_rc_database::sea_orm::DbErr> {
self.db.complete_all_games().await
}
+4
View File
@@ -6,6 +6,10 @@ fn u64_negative_on_err<E>(result: Result<u64, E>) -> i64 {
#[async_trait::async_trait]
impl super::CommonUser for UserData {
fn account_id(&self) -> i32 {
self.account.id
}
fn public_id(&self) -> &'_ str {
&self.account.public_id
}
+2
View File
@@ -23,6 +23,8 @@ impl super::FactoryUser for UserData {
thumbnail: vehicle.thumbnail,
added_by: self.account.public_id.clone(),
added_by_display_name: self.account.display_name.clone(),
added_by_id: self.account.id,
garage_id: slot.id,
cpu: slot.total_robot_cpu as u32,
total_robot_ranking: slot.total_robot_ranking as u32,
build_version: vehicle.version,
+1
View File
@@ -410,6 +410,7 @@ pub struct ResolvedVehicle {
#[async_trait::async_trait]
pub trait CommonUser: Send + Sync {
fn account_id(&self) -> i32;
async fn resolve_config_vehicle(&self, vehicle: &crate::persist::config::VehicleInfo, factory: &dyn oj_rc_factory::VehicleFactoryAdapter, weapon_order: &crate::cubes::WeaponListParser, cpu_counter: &crate::cubes::CpuListParser) -> Result<ResolvedVehicle, polariton_server::operations::SimpleOpError>;
fn public_id(&self) -> &'_ str;
fn is_mod(&self) -> bool;