1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Configure all death, spawn, and garage bay skins for #3

This commit is contained in:
NG (Graham)
2025-05-26 21:30:28 -04:00
parent 956bb2149d
commit ab19c723cd
14 changed files with 584 additions and 143 deletions

View File

@@ -0,0 +1,54 @@
use sea_orm_migration::prelude::*;
pub struct Migration;
impl MigrationName for Migration {
fn name(&self) -> &str {
"m20250526_000001_add_garage_customisation"
}
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
// Define how to apply this migration: Add death and spawn animation columns
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
// sqlite adapter doesn't support multiple alter operations in one declaration
manager
.alter_table(
Table::alter()
.table(crate::schema::garage::Entity)
.add_column(ColumnDef::new(crate::schema::garage::Column::SpawnAnimationId).string().not_null().default("Spawn".to_owned()))
.to_owned()
)
.await?;
manager
.alter_table(
Table::alter()
.table(crate::schema::garage::Entity)
.add_column(ColumnDef::new(crate::schema::garage::Column::DeathAnimationId).string().not_null().default("Explosion".to_owned()))
.to_owned()
)
.await
}
// Define how to rollback this migration: Drop the added colums.
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.alter_table(
Table::alter()
.table(crate::schema::garage::Entity)
.drop_column(crate::schema::garage::Column::SpawnAnimationId)
.to_owned()
)
.await?;
manager
.alter_table(
Table::alter()
.table(crate::schema::garage::Entity)
.drop_column(crate::schema::garage::Column::DeathAnimationId)
.to_owned()
)
.await
}
}

View File

@@ -5,6 +5,7 @@ mod m20250424_000002_create_user_permissions_table;
mod m20250424_000003_create_garage_table;
mod m20250424_000004_create_user_aux_table;
mod m20250424_000005_create_campaign_tables;
mod m20250526_000001_add_garage_customisation;
pub struct Migrator;
@@ -17,6 +18,7 @@ impl MigratorTrait for Migrator {
Box::new(m20250424_000003_create_garage_table::Migration),
Box::new(m20250424_000004_create_user_aux_table::Migration),
Box::new(m20250424_000005_create_campaign_tables::Migration),
Box::new(m20250526_000001_add_garage_customisation::Migration),
]
}
}

View File

@@ -21,11 +21,15 @@ pub struct Model {
pub tutorial_robot: bool,
pub starter_robot_index: Option<u32>,
pub control_type: ControlType,
// control options
pub vertical_strafing: bool,
pub sideways_driving: bool,
pub tracks_turn_on_spot: bool,
// end control options
pub mastery_level: u32,
pub bay_skin_id: String,
pub death_animation_id: String,
pub spawn_animation_id: String,
pub weapon_order: String, // csv?
pub robot_data: Vec<u8>,
pub colour_data: Vec<u8>,

View File

@@ -140,6 +140,13 @@ impl Database {
.await
}
pub async fn garage_by_uuid(&self, uuid: i64) -> Result<Option<crate::schema::garage::Model>, sea_orm::DbErr> {
crate::schema::garage::Entity::find()
.filter(crate::schema::garage::Column::Uuid.eq(uuid))
.one(&self.orm)
.await
}
pub async fn insert_garages(&self, entities: Vec<crate::schema::garage::ActiveModel>) -> Result<(), sea_orm::DbErr> {
crate::schema::garage::Entity::insert_many(entities.into_iter()).exec(&self.orm).await?;
Ok(())
@@ -175,6 +182,24 @@ impl Database {
}
}
pub async fn update_garage_by_uuid(&self, mut entity: crate::schema::garage::ActiveModel, uuid: i64) -> Result<Option<crate::schema::garage::Model>, sea_orm::DbErr> {
let id_opt = crate::schema::garage::Entity::find()
.select_only()
.column(crate::schema::garage::Column::Id)
.filter(crate::schema::garage::Column::Uuid.eq(uuid))
.into_model::<crate::schema::common_query::Id>()
.one(&self.orm)
.await?;
if let Some(id) = id_opt {
entity.id = sea_orm::ActiveValue::Set(id.id);
Ok(Some(crate::schema::garage::Entity::update(entity)
.exec(&self.orm)
.await?))
} else {
Ok(None)
}
}
pub async fn update_garage_selected_by_user_id_and_slot(&self, user_id: u32, slot: u32) -> Result<(), sea_orm::DbErr> {
self.orm.transaction(|txn| {
Box::pin(async move {