mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Add basic client AI support
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
use sea_orm_migration::prelude::*;
|
||||
|
||||
pub struct Migration;
|
||||
|
||||
impl MigrationName for Migration {
|
||||
fn name(&self) -> &str {
|
||||
"m20250918_000001_add_player_variant"
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
// Define how to apply this migration: Add player variant columns
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(crate::schema::multiplayer_game_player::Entity)
|
||||
.add_column(ColumnDef::new(crate::schema::multiplayer_game_player::Column::Variant).string().not_null().default(crate::schema::multiplayer_game_player::ClientType::Client))
|
||||
.to_owned()
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
// Define how to rollback this migration: Drop the added column
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(crate::schema::multiplayer_game_player::Entity)
|
||||
.drop_column(crate::schema::multiplayer_game_player::Column::Variant)
|
||||
.to_owned()
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ mod m20250713_000001_create_game_table;
|
||||
mod m20250713_000002_create_player_table;
|
||||
mod m20250722_000001_create_game_event_table;
|
||||
mod m20250816_000001_add_fake_players;
|
||||
mod m20250918_000001_add_player_variant;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
@@ -29,6 +30,7 @@ impl MigratorTrait for Migrator {
|
||||
Box::new(m20250713_000002_create_player_table::Migration),
|
||||
Box::new(m20250722_000001_create_game_event_table::Migration),
|
||||
Box::new(m20250816_000001_add_fake_players::Migration),
|
||||
Box::new(m20250918_000001_add_player_variant::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ pub struct Model {
|
||||
pub is_claimed: bool,
|
||||
pub public_id: String,
|
||||
pub display_name: String,
|
||||
pub variant: ClientType,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
@@ -45,3 +46,11 @@ impl Related<super::user::Entity> for Entity {
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
|
||||
#[sea_orm(rs_type = "String", db_type = "String(StringLen::None)", rename_all = "PascalCase")]
|
||||
pub enum ClientType {
|
||||
Client,
|
||||
ClientAI,
|
||||
ServerExperimental,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user