Allow two or more people to load into the same multiplayer match #30

This commit is contained in:
NG (Graham) committed 2025-07-20 18:31:08 -04:00
1 parent cd45c22d0b
commit 37cbc8d85f
24 files changed
+902 -149

No files matched your search

+2
View File
@@ -6,6 +6,8 @@ pub mod campaign;
pub mod campaign_difficulty_completion;
pub mod common_query;
pub mod sanction;
pub mod multiplayer_game;
pub mod multiplayer_game_player;
pub fn parse_int_csv(s: &str) -> Vec<u32> {
s.split(',').filter_map(|i_as_s| {
@@ -0,0 +1,58 @@
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "games")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub creation_time: i64, // seconds since unix epoch
pub guid: i64,
pub map: String,
pub mode: GameMode,
pub visibility: MapVisibility,
pub auto_heal: bool,
pub variant: GameType,
pub is_complete: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::multiplayer_game_player::Entity")]
Player,
}
impl Related<super::multiplayer_game_player::Entity> for Entity {
fn to() -> RelationDef {
Relation::Player.def()
}
}
impl ActiveModelBehavior for ActiveModel {}
#[derive(Clone, Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "String(StringLen::None)", rename_all = "PascalCase")]
pub enum GameMode {
BattleArena,
SuddenDeath,
Pit,
TestMode,
SinglePlayer,
TeamDeathmatch,
Campaign,
}
#[derive(Clone, Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "String(StringLen::None)", rename_all = "PascalCase")]
pub enum MapVisibility {
Good,
Poor,
Bad,
}
#[derive(Clone, Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "String(StringLen::None)", rename_all = "PascalCase")]
pub enum GameType {
Standard,
Ranked,
Custom,
}
@@ -0,0 +1,45 @@
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "players")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub user_id: i32,
pub game_id: i32,
pub creation_time: i64, // seconds since unix epoch
pub player_id: i16, // actually u8
pub team: i32,
pub group: Option<i32>, // probably a user id
pub is_claimed: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::multiplayer_game::Entity",
from = "Column::GameId",
to = "super::multiplayer_game::Column::Id"
)]
Game,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id"
)]
User,
}
impl Related<super::multiplayer_game::Entity> for Entity {
fn to() -> RelationDef {
Relation::Game.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}
+8
View File
@@ -23,6 +23,8 @@ pub enum Relation {
Aux,
#[sea_orm(has_many = "super::campaign::Entity")]
Campaigns,
#[sea_orm(has_many = "super::multiplayer_game_player::Entity")]
Player,
}
impl Related<super::permissions::Entity> for Entity {
@@ -49,4 +51,10 @@ impl Related<super::campaign::Entity> for Entity {
}
}
impl Related<super::multiplayer_game_player::Entity> for Entity {
fn to() -> RelationDef {
Relation::Player.def()
}
}
impl ActiveModelBehavior for ActiveModel {}