mirror of
https://github.com/RustySamovar/RustySamovar.git
synced 2024-11-22 02:45:34 +00:00
Move another step towards full DB-driven server
This commit is contained in:
parent
d36f469e81
commit
efafc2a60b
26
src/dbmanager/avatar_fight_prop.rs
Normal file
26
src/dbmanager/avatar_fight_prop.rs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Database Manager
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
||||||
|
#[sea_orm(table_name = "avatar_fight_prop")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key)]
|
||||||
|
pub guid: i64,
|
||||||
|
pub prop_id: u32,
|
||||||
|
pub value: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter)]
|
||||||
|
pub enum Relation {
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RelationTrait for Relation {
|
||||||
|
fn def(&self) -> RelationDef {
|
||||||
|
match self {
|
||||||
|
_ => panic!("Unknown relation type!"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
@ -9,7 +9,7 @@ pub struct Model {
|
|||||||
pub uid: u32,
|
pub uid: u32,
|
||||||
pub character_id: u32,
|
pub character_id: u32,
|
||||||
pub avatar_type: u8,
|
pub avatar_type: u8,
|
||||||
pub guid: u64,
|
pub guid: i64,
|
||||||
pub born_time: u32,
|
pub born_time: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
26
src/dbmanager/avatar_prop.rs
Normal file
26
src/dbmanager/avatar_prop.rs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Database Manager
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
||||||
|
#[sea_orm(table_name = "avatar_prop")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key)]
|
||||||
|
pub guid: i64,
|
||||||
|
pub prop_id: u32,
|
||||||
|
pub prop_value: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter)]
|
||||||
|
pub enum Relation {
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RelationTrait for Relation {
|
||||||
|
fn def(&self) -> RelationDef {
|
||||||
|
match self {
|
||||||
|
_ => panic!("Unknown relation type!"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
@ -8,7 +8,7 @@ pub struct Model {
|
|||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
pub uid: u32,
|
pub uid: u32,
|
||||||
pub team_id: u8,
|
pub team_id: u8,
|
||||||
pub guid: u64,
|
pub guid: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, EnumIter)]
|
#[derive(Copy, Clone, Debug, EnumIter)]
|
||||||
|
@ -3,6 +3,9 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use sea_orm::{entity::*, error::*, query::*, DbConn, FromQueryResult, Database};
|
use sea_orm::{entity::*, error::*, query::*, DbConn, FromQueryResult, Database};
|
||||||
use sea_orm::entity::prelude::*;
|
use sea_orm::entity::prelude::*;
|
||||||
|
use crate::JsonManager;
|
||||||
|
use crate::server::AuthManager;
|
||||||
|
use crate::utils::IdManager;
|
||||||
|
|
||||||
pub use super::player_info::Model as PlayerInfo;
|
pub use super::player_info::Model as PlayerInfo;
|
||||||
use super::player_info::Entity as PlayerInfoEntity;
|
use super::player_info::Entity as PlayerInfoEntity;
|
||||||
@ -22,6 +25,40 @@ use super::avatar_team_info::Entity as AvatarTeamInfoEntity;
|
|||||||
pub use super::team_selection_info::Model as TeamSelectionInfo;
|
pub use super::team_selection_info::Model as TeamSelectionInfo;
|
||||||
use super::team_selection_info::Entity as TeamSelectionInfoEntity;
|
use super::team_selection_info::Entity as TeamSelectionInfoEntity;
|
||||||
|
|
||||||
|
pub use super::player_prop::Model as PlayerProp;
|
||||||
|
use super::player_prop::Entity as PlayerPropEntity;
|
||||||
|
|
||||||
|
pub use super::avatar_prop::Model as AvatarProp;
|
||||||
|
use super::avatar_prop::Entity as AvatarPropEntity;
|
||||||
|
|
||||||
|
pub use super::avatar_fight_prop::Model as AvatarFightProp;
|
||||||
|
use super::avatar_fight_prop::Entity as AvatarFightPropEntity;
|
||||||
|
|
||||||
|
pub use super::open_state::Model as OpenState;
|
||||||
|
use super::open_state::Entity as OpenStateEntity;
|
||||||
|
|
||||||
|
/* Inventory */
|
||||||
|
pub use super::material_info::Model as MaterialInfo;
|
||||||
|
use super::material_info::Entity as MaterialInfoEntity;
|
||||||
|
|
||||||
|
pub use super::reliquary_info::Model as ReliquaryInfo;
|
||||||
|
use super::reliquary_info::Entity as ReliquaryInfoEntity;
|
||||||
|
|
||||||
|
pub use super::equip_info::Model as EquipInfo;
|
||||||
|
use super::equip_info::Entity as EquipInfoEntity;
|
||||||
|
|
||||||
|
pub use super::item_info::Model as ItemInfo;
|
||||||
|
use super::item_info::Entity as ItemInfoEntity;
|
||||||
|
|
||||||
|
pub use super::weapon_affix_info::Model as WeaponAffixInfo;
|
||||||
|
use super::weapon_affix_info::Entity as WeaponAffixInfoEntity;
|
||||||
|
|
||||||
|
pub use super::reliquary_prop::Model as ReliquaryProp;
|
||||||
|
use super::reliquary_prop::Entity as ReliquaryPropEntity;
|
||||||
|
|
||||||
|
pub use super::furniture_info::Model as FurnitureInfo;
|
||||||
|
use super::furniture_info::Entity as FurnitureInfoEntity;
|
||||||
|
|
||||||
macro_rules! collection {
|
macro_rules! collection {
|
||||||
// map-like
|
// map-like
|
||||||
($($k:expr => $v:expr),* $(,)?) => {{
|
($($k:expr => $v:expr),* $(,)?) => {{
|
||||||
@ -58,65 +95,91 @@ impl DatabaseManager {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn _get_player_info(&self, uid: u32) -> Option<PlayerInfo> {
|
pub fn get_player_info(&self, uid: u32) -> Option<PlayerInfo> {
|
||||||
match PlayerInfoEntity::find_by_id(uid).one(&self.db).wait() {
|
match PlayerInfoEntity::find_by_id(uid).one(&self.db).wait() {
|
||||||
Err(_) => { println!("DB ERROR!"); None },
|
Err(_) => { println!("DB ERROR!"); None },
|
||||||
Ok(p_info) => p_info,
|
Ok(p_info) => p_info,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
pub fn get_player_info(&self, uid: u32) -> Option<PlayerInfo> {
|
pub fn _get_player_info(&self, uid: u32) -> Option<PlayerInfo> {
|
||||||
Some(PlayerInfo {
|
Some(PlayerInfo {
|
||||||
uid: uid,
|
uid: uid,
|
||||||
nick_name: "Fapper".into(),
|
nick_name: "Fapper".into(),
|
||||||
level: 56,
|
|
||||||
signature: "Hello world!".into(),
|
signature: "Hello world!".into(),
|
||||||
birthday: 0,
|
birthday: 0,
|
||||||
world_level: 8,
|
|
||||||
namecard_id: 210051,
|
namecard_id: 210051,
|
||||||
finish_achievement_num: 42,
|
finish_achievement_num: 42,
|
||||||
tower_floor_index: 1,
|
tower_floor_index: 1,
|
||||||
tower_level_index: 1,
|
tower_level_index: 1,
|
||||||
avatar_id: 10000007,
|
avatar_id: 10000007,
|
||||||
})
|
})
|
||||||
}
|
}*/
|
||||||
|
/*
|
||||||
|
pub fn _get_player_props(&self, uid: u32) -> Option<HashMap<u32, i64>> {
|
||||||
|
Some(collection! {
|
||||||
|
//proto::PropType::PropIsSpringAutoUse as u32 => 1,
|
||||||
|
//proto::PropType::PropIsFlyable as u32 => 1,
|
||||||
|
//proto::PropType::PropIsTransferable as u32 => 1,
|
||||||
|
//proto::PropType::PropPlayerLevel as u32 => 56,
|
||||||
|
//proto::PropType::PropPlayerExp as u32 => 1337,
|
||||||
|
//proto::PropType::PropPlayerHcoin as u32 => 9001,
|
||||||
|
//proto::PropType::PropPlayerScoin as u32 => 9002,
|
||||||
|
//proto::PropType::PropPlayerWorldLevel as u32 => 8,
|
||||||
|
//proto::PropType::PropPlayerResin as u32 => 159,
|
||||||
|
//proto::PropType::PropPlayerMcoin as u32 => 9003,
|
||||||
|
//proto::PropType::PropMaxStamina as u32 => 12000,
|
||||||
|
//proto::PropType::PropCurPersistStamina as u32 => 12000,
|
||||||
|
})
|
||||||
|
}*/
|
||||||
|
|
||||||
pub fn get_player_props(&self, uid: u32) -> Option<HashMap<u32, i64>> {
|
pub fn get_player_props(&self, uid: u32) -> Option<HashMap<u32, i64>> {
|
||||||
Some(collection! {
|
let props = match PlayerPropEntity::find_by_id(uid).all(&self.db).wait() {
|
||||||
proto::PropType::PropIsSpringAutoUse as u32 => 1,
|
Err(_) => { panic!("DB ERROR!") },
|
||||||
proto::PropType::PropIsFlyable as u32 => 1,
|
Ok(p_info) => p_info,
|
||||||
proto::PropType::PropIsTransferable as u32 => 1,
|
};
|
||||||
proto::PropType::PropPlayerLevel as u32 => 56,
|
|
||||||
proto::PropType::PropPlayerExp as u32 => 1337,
|
|
||||||
proto::PropType::PropPlayerHcoin as u32 => 9001,
|
|
||||||
proto::PropType::PropPlayerScoin as u32 => 9002,
|
|
||||||
proto::PropType::PropPlayerWorldLevel as u32 => 8,
|
|
||||||
proto::PropType::PropPlayerResin as u32 => 159,
|
|
||||||
proto::PropType::PropPlayerMcoin as u32 => 9003,
|
|
||||||
proto::PropType::PropMaxStamina as u32 => 120,
|
|
||||||
proto::PropType::PropCurPersistStamina as u32 => 120,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_avatar_props(&self, guid: u64) -> Option<HashMap<u32, i64>> {
|
let props = props
|
||||||
|
.into_iter()
|
||||||
|
.map(|p| (p.prop_id, p.prop_value))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
return Some(props);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
pub fn _get_avatar_props(&self, guid: u64) -> Option<HashMap<u32, i64>> {
|
||||||
let map = collection! {
|
let map = collection! {
|
||||||
proto::PropType::PropExp as u32 => 0,
|
//proto::PropType::PropExp as u32 => 0,
|
||||||
proto::PropType::PropLevel as u32 => 80,
|
//proto::PropType::PropLevel as u32 => 80,
|
||||||
proto::PropType::PropBreakLevel as u32 => 5,
|
//proto::PropType::PropBreakLevel as u32 => 5,
|
||||||
proto::PropType::PropSatiationVal as u32 => 0,
|
//proto::PropType::PropSatiationVal as u32 => 0,
|
||||||
proto::PropType::PropSatiationPenaltyTime as u32 => 0,
|
//proto::PropType::PropSatiationPenaltyTime as u32 => 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
return Some(map);
|
return Some(map);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
pub fn get_avatar_props(&self, guid: i64) -> Option<HashMap<u32, i64>> {
|
||||||
|
let props = match AvatarPropEntity::find_by_id(guid).all(&self.db).wait() {
|
||||||
|
Err(_) => { panic!("DB ERROR!") },
|
||||||
|
Ok(p_info) => p_info,
|
||||||
|
};
|
||||||
|
|
||||||
|
let props = props
|
||||||
|
.into_iter()
|
||||||
|
.map(|p| (p.prop_id, p.prop_value))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
return Some(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_avatar_equip(&self, guid: u64) -> Option<Vec<u64>> {
|
pub fn get_avatar_equip(&self, guid: i64) -> Option<Vec<i64>> {
|
||||||
let equip = vec![Self::SPOOFED_WEAPON_GUID];
|
let equip = vec![Self::SPOOFED_WEAPON_GUID];
|
||||||
|
|
||||||
return Some(equip);
|
return Some(equip);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_skill_levels(&self, guid: u64) -> Option<HashMap<u32,u32>> {
|
pub fn get_skill_levels(&self, guid: i64) -> Option<HashMap<u32,u32>> {
|
||||||
let map = collection! {
|
let map = collection! {
|
||||||
10068 => 3,
|
10068 => 3,
|
||||||
100553 => 3,
|
100553 => 3,
|
||||||
@ -126,7 +189,8 @@ impl DatabaseManager {
|
|||||||
return Some(map);
|
return Some(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_avatar_fight_props(&self, guid: u64) -> Option<HashMap<u32, f32>> {
|
pub fn get_avatar_fight_props(&self, guid: i64) -> Option<HashMap<u32, f32>> {
|
||||||
|
/*
|
||||||
let map = collection! {
|
let map = collection! {
|
||||||
proto::FightPropType::FightPropBaseHp as u32 => 9000.0,
|
proto::FightPropType::FightPropBaseHp as u32 => 9000.0,
|
||||||
proto::FightPropType::FightPropHp as u32 => 3000.0,
|
proto::FightPropType::FightPropHp as u32 => 3000.0,
|
||||||
@ -181,9 +245,23 @@ impl DatabaseManager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return Some(map);
|
return Some(map);
|
||||||
|
|
||||||
|
*/
|
||||||
|
let props = match AvatarFightPropEntity::find_by_id(guid).all(&self.db).wait() {
|
||||||
|
Err(e) => { panic!("DB ERROR {}: {}!", guid, e) },
|
||||||
|
Ok(props) => props,
|
||||||
|
};
|
||||||
|
|
||||||
|
let props = props
|
||||||
|
.into_iter()
|
||||||
|
.map(|p| (p.prop_id, p.value))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
return Some(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_open_state(&self, uid: u32) -> Option<HashMap<u32, u32>> {
|
pub fn get_open_state(&self, uid: u32) -> Option<HashMap<u32, u32>> {
|
||||||
|
/*
|
||||||
Some(collection! {
|
Some(collection! {
|
||||||
proto::OpenStateType::OpenStatePaimon as u32 => 1,
|
proto::OpenStateType::OpenStatePaimon as u32 => 1,
|
||||||
|
|
||||||
@ -217,9 +295,23 @@ impl DatabaseManager {
|
|||||||
proto::OpenStateType::OpenStateLiyueInfusedcrystal as u32 => 1,
|
proto::OpenStateType::OpenStateLiyueInfusedcrystal as u32 => 1,
|
||||||
proto::OpenStateType::OpenStateInazumaMainquestFinished as u32 => 1,
|
proto::OpenStateType::OpenStateInazumaMainquestFinished as u32 => 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
*/
|
||||||
|
let states = match OpenStateEntity::find_by_id(uid).all(&self.db).wait() {
|
||||||
|
Err(_) => { panic!("DB ERROR!") },
|
||||||
|
Ok(states) => states,
|
||||||
|
};
|
||||||
|
|
||||||
|
let states = states
|
||||||
|
.into_iter()
|
||||||
|
.map(|s| (s.state_id, s.value))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
return Some(states);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_inventory(&self, uid: u32) -> Option<Vec<proto::Item>> {
|
pub fn get_inventory(&self, uid: u32) -> Option<Vec<proto::Item>> {
|
||||||
|
|
||||||
let mut weapon = proto::Weapon::default();
|
let mut weapon = proto::Weapon::default();
|
||||||
weapon.level = 70;
|
weapon.level = 70;
|
||||||
weapon.promote_level = 4;
|
weapon.promote_level = 4;
|
||||||
@ -231,13 +323,68 @@ impl DatabaseManager {
|
|||||||
|
|
||||||
let mut item = proto::Item::default();
|
let mut item = proto::Item::default();
|
||||||
item.item_id = 11406;
|
item.item_id = 11406;
|
||||||
item.guid = Self::SPOOFED_WEAPON_GUID;
|
item.guid = Self::SPOOFED_WEAPON_GUID as u64; // FIXME
|
||||||
item.detail = Some(proto::item::Detail::Equip(equip));
|
item.detail = Some(proto::item::Detail::Equip(equip));
|
||||||
|
|
||||||
return Some(vec![item]);
|
return Some(vec![item]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Inventory item can be of three types: material, equip and furniture
|
||||||
|
Equip is further divided into relic and weapon
|
||||||
|
Sp we need to get:
|
||||||
|
1) Materials
|
||||||
|
2) Furniture
|
||||||
|
3) Relics (+their properties)
|
||||||
|
4) Weapons (+their affices)
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
let items = match ItemInfoEntity::find_by_id(uid).all(&self.db).wait() {
|
||||||
|
Err(e) => { panic!("DB ERROR: {}!", e) },
|
||||||
|
Ok(items) => items,
|
||||||
|
};
|
||||||
|
|
||||||
|
let materials: Vec<(ItemInfo, MaterialInfo)> = self.find_related_to_items(&items, MaterialInfoEntity);
|
||||||
|
|
||||||
|
let furniture: Vec<(ItemInfo, FurnitureInfo)> = self.find_related_to_items(&items, FurnitureInfoEntity);
|
||||||
|
|
||||||
|
let equip: Vec<(ItemInfo, EquipInfo)> = self.find_related_to_items(&items, EquipInfoEntity);
|
||||||
|
|
||||||
|
return None;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
fn find_related_to_items<T: sea_orm::EntityTrait>(&self, items: &Vec<ItemInfo>, entity_type: T) -> Vec<(ItemInfo, T::Model)>
|
||||||
|
where
|
||||||
|
ItemInfoEntity: sea_orm::Related<T>
|
||||||
|
{
|
||||||
|
return items.into_iter()
|
||||||
|
.map(|item| {
|
||||||
|
let ret = match item.find_related(entity_type).one(&self.db).wait() {
|
||||||
|
Err(e) => { panic!("DB ERROR: {}!", e) },
|
||||||
|
Ok(data) => data,
|
||||||
|
};
|
||||||
|
|
||||||
|
match ret {
|
||||||
|
None => None,
|
||||||
|
Some(data) => Some( (item.clone(), data) ),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.filter(|x| !x.is_none())
|
||||||
|
.map(|x| x.unwrap())
|
||||||
|
.collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_avatars(&self, uid: u32) -> Option<Vec<AvatarInfo>> {
|
pub fn get_avatars(&self, uid: u32) -> Option<Vec<AvatarInfo>> {
|
||||||
|
let avatars = match AvatarInfoEntity::find_by_id(uid).all(&self.db).wait() {
|
||||||
|
Err(_) => { panic!("DB ERROR!") },
|
||||||
|
Ok(avatars) => avatars,
|
||||||
|
};
|
||||||
|
|
||||||
|
return Some(avatars);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
pub fn _get_avatars(&self, uid: u32) -> Option<Vec<AvatarInfo>> {
|
||||||
let ai = AvatarInfo {
|
let ai = AvatarInfo {
|
||||||
uid: uid,
|
uid: uid,
|
||||||
character_id: 7,
|
character_id: 7,
|
||||||
@ -247,23 +394,55 @@ impl DatabaseManager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return Some(vec![ai]);
|
return Some(vec![ai]);
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_player_scene_info(&self, uid: u32) -> Option<SceneInfo> {
|
|
||||||
|
}*/
|
||||||
|
|
||||||
|
pub fn get_avatar(&self, guid: i64) -> Option<AvatarInfo> {
|
||||||
|
let avatar = match AvatarInfoEntity::find().filter(super::avatar_info::Column::Guid.eq(guid)).one(&self.db).wait() {
|
||||||
|
Err(_) => { panic!("DB ERROR!") },
|
||||||
|
Ok(avatar) => avatar,
|
||||||
|
};
|
||||||
|
|
||||||
|
return avatar;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
pub fn _get_avatar(&self, guid: u64) -> Option<AvatarInfo> {
|
||||||
|
let ai = AvatarInfo {
|
||||||
|
uid: AuthManager::SPOOFED_PLAYER_UID, // TODO!
|
||||||
|
character_id: 7,
|
||||||
|
avatar_type: 1,
|
||||||
|
guid: Self::SPOOFED_AVATAR_GUID,
|
||||||
|
born_time: 1633790000,
|
||||||
|
};
|
||||||
|
|
||||||
|
return Some(ai);
|
||||||
|
}*/
|
||||||
|
/*
|
||||||
|
pub fn _get_player_scene_info(&self, uid: u32) -> Option<SceneInfo> {
|
||||||
let si = SceneInfo {
|
let si = SceneInfo {
|
||||||
uid: uid,
|
uid: uid,
|
||||||
scene_id: Self::SPOOFED_SCENE_ID,
|
scene_id: Self::SPOOFED_SCENE_ID,
|
||||||
scene_token: Self::SPOOFED_SCENE_TOKEN,
|
scene_token: Self::SPOOFED_SCENE_TOKEN,
|
||||||
pos_x: -3400.0,
|
pos_x: -3400.0,
|
||||||
pos_y: 233.0,
|
pos_y: 233.0,
|
||||||
pos_z: 3427.6,
|
pos_z: -3427.6,
|
||||||
};
|
};
|
||||||
|
|
||||||
return Some(si);
|
return Some(si);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
pub fn get_player_scene_info(&self, uid: u32) -> Option<SceneInfo> {
|
||||||
|
let scene_info = match SceneInfoEntity::find_by_id(uid).one(&self.db).wait() {
|
||||||
|
Err(_) => { panic!("DB ERROR!") },
|
||||||
|
Ok(info) => info,
|
||||||
|
};
|
||||||
|
|
||||||
|
return scene_info;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_player_teams(&self, uid: u32) -> Option<Vec<TeamInfo>> {
|
pub fn get_player_teams(&self, uid: u32) -> Option<Vec<TeamInfo>> {
|
||||||
let t1 = TeamInfo {
|
/*let t1 = TeamInfo {
|
||||||
uid: uid.clone(),
|
uid: uid.clone(),
|
||||||
id: 1,
|
id: 1,
|
||||||
name: "Team 1".to_string(),
|
name: "Team 1".to_string(),
|
||||||
@ -288,9 +467,17 @@ impl DatabaseManager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return Some(vec![t1, t2, t3, t4]);
|
return Some(vec![t1, t2, t3, t4]);
|
||||||
|
*/
|
||||||
|
let teams = match TeamInfoEntity::find_by_id(uid).all(&self.db).wait() {
|
||||||
|
Err(_) => panic!("Failed to retrieve teams for user {}!", uid),
|
||||||
|
Ok(teams) => teams,
|
||||||
|
};
|
||||||
|
|
||||||
|
return Some(teams);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_player_teams_avatars(&self, uid: u32) -> Option<Vec<AvatarTeamInfo>> {
|
pub fn get_player_teams_avatars(&self, uid: u32) -> Option<Vec<AvatarTeamInfo>> {
|
||||||
|
/*
|
||||||
let a1 = AvatarTeamInfo {
|
let a1 = AvatarTeamInfo {
|
||||||
uid: uid.clone(),
|
uid: uid.clone(),
|
||||||
team_id: 1,
|
team_id: 1,
|
||||||
@ -316,9 +503,17 @@ impl DatabaseManager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return Some(vec![a1, a2, a3, a4]);
|
return Some(vec![a1, a2, a3, a4]);
|
||||||
|
*/
|
||||||
|
let teams = match AvatarTeamInfoEntity::find_by_id(uid).all(&self.db).wait() {
|
||||||
|
Err(_) => panic!("Failed to retrieve avatar teams for user {}!", uid),
|
||||||
|
Ok(teams) => teams,
|
||||||
|
};
|
||||||
|
|
||||||
|
return Some(teams);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_player_team_selection(&self, uid: u32) -> Option<TeamSelectionInfo> {
|
pub fn get_player_team_selection(&self, uid: u32) -> Option<TeamSelectionInfo> {
|
||||||
|
/*
|
||||||
let tsi = TeamSelectionInfo {
|
let tsi = TeamSelectionInfo {
|
||||||
uid: uid.clone(),
|
uid: uid.clone(),
|
||||||
avatar: Self::SPOOFED_AVATAR_GUID,
|
avatar: Self::SPOOFED_AVATAR_GUID,
|
||||||
@ -326,11 +521,18 @@ impl DatabaseManager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return Some(tsi);
|
return Some(tsi);
|
||||||
|
*/
|
||||||
|
let tsi = match TeamSelectionInfoEntity::find_by_id(uid).one(&self.db).wait() {
|
||||||
|
Err(_) => { panic!("DB ERROR!") },
|
||||||
|
Ok(info) => info,
|
||||||
|
};
|
||||||
|
|
||||||
|
return tsi;
|
||||||
}
|
}
|
||||||
|
|
||||||
const BASE_GUID: u64 = 0x2400000000000000;
|
const BASE_GUID: i64 = 0x2400000000000000;
|
||||||
const SPOOFED_AVATAR_GUID: u64 = Self::BASE_GUID + 1;
|
const SPOOFED_AVATAR_GUID: i64 = Self::BASE_GUID + 1;
|
||||||
const SPOOFED_WEAPON_GUID: u64 = Self::BASE_GUID + 2;
|
const SPOOFED_WEAPON_GUID: i64 = Self::BASE_GUID + 2;
|
||||||
const SPOOFED_SCENE_ID: u32 = 3;
|
const SPOOFED_SCENE_ID: u32 = 3;
|
||||||
const SPOOFED_SCENE_TOKEN: u32 = 0x1234;
|
const SPOOFED_SCENE_TOKEN: u32 = 0x1234;
|
||||||
}
|
}
|
||||||
|
33
src/dbmanager/equip_info.rs
Normal file
33
src/dbmanager/equip_info.rs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Database Manager
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
||||||
|
#[sea_orm(table_name = "equip_info")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key)]
|
||||||
|
pub guid: i64,
|
||||||
|
pub is_locked: bool,
|
||||||
|
pub level: u32,
|
||||||
|
pub exp: u32,
|
||||||
|
pub promote_level: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter)]
|
||||||
|
pub enum Relation {
|
||||||
|
Item,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RelationTrait for Relation {
|
||||||
|
fn def(&self) -> RelationDef {
|
||||||
|
match self {
|
||||||
|
Self::Item => Entity::belongs_to(super::item_info::Entity)
|
||||||
|
.from(Column::Guid)
|
||||||
|
.to(super::item_info::Column::Guid)
|
||||||
|
.into(),
|
||||||
|
_ => panic!("Unknown relation type!"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
30
src/dbmanager/furniture_info.rs
Normal file
30
src/dbmanager/furniture_info.rs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// Database Manager
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
||||||
|
#[sea_orm(table_name = "furniture_info")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key)]
|
||||||
|
pub guid: i64,
|
||||||
|
pub count: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter)]
|
||||||
|
pub enum Relation {
|
||||||
|
Item,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RelationTrait for Relation {
|
||||||
|
fn def(&self) -> RelationDef {
|
||||||
|
match self {
|
||||||
|
Self::Item => Entity::belongs_to(super::item_info::Entity)
|
||||||
|
.from(Column::Guid)
|
||||||
|
.to(super::item_info::Column::Guid)
|
||||||
|
.into(),
|
||||||
|
_ => panic!("Unknown relation type!"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
47
src/dbmanager/item_info.rs
Normal file
47
src/dbmanager/item_info.rs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Database Manager
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
||||||
|
#[sea_orm(table_name = "item_info")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key)]
|
||||||
|
pub uid: u32,
|
||||||
|
pub guid: i64,
|
||||||
|
pub item_id: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter)]
|
||||||
|
pub enum Relation {
|
||||||
|
Material,
|
||||||
|
Equip,
|
||||||
|
Furniture,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RelationTrait for Relation {
|
||||||
|
fn def(&self) -> RelationDef {
|
||||||
|
match self {
|
||||||
|
_ => panic!("Unknown relation type!"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::material_info::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::Material.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::equip_info::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::Equip.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::furniture_info::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::Furniture.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
32
src/dbmanager/material_info.rs
Normal file
32
src/dbmanager/material_info.rs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Database Manager
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
||||||
|
#[sea_orm(table_name = "material_info")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key)]
|
||||||
|
pub guid: i64,
|
||||||
|
pub count: u32,
|
||||||
|
pub has_delete_config: bool,
|
||||||
|
// TODO: Add MaterialDeleteInfo!
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter)]
|
||||||
|
pub enum Relation {
|
||||||
|
Item,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RelationTrait for Relation {
|
||||||
|
fn def(&self) -> RelationDef {
|
||||||
|
match self {
|
||||||
|
Self::Item => Entity::belongs_to(super::item_info::Entity)
|
||||||
|
.from(Column::Guid)
|
||||||
|
.to(super::item_info::Column::Guid)
|
||||||
|
.into(),
|
||||||
|
_ => panic!("Unknown relation type!"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
@ -8,3 +8,14 @@ mod scene_info;
|
|||||||
mod avatar_team_info;
|
mod avatar_team_info;
|
||||||
mod team_info;
|
mod team_info;
|
||||||
mod team_selection_info;
|
mod team_selection_info;
|
||||||
|
mod avatar_prop;
|
||||||
|
mod avatar_fight_prop;
|
||||||
|
mod player_prop;
|
||||||
|
mod open_state;
|
||||||
|
mod material_info;
|
||||||
|
mod reliquary_info;
|
||||||
|
mod equip_info;
|
||||||
|
mod item_info;
|
||||||
|
mod weapon_affix_info;
|
||||||
|
mod reliquary_prop;
|
||||||
|
mod furniture_info;
|
26
src/dbmanager/open_state.rs
Normal file
26
src/dbmanager/open_state.rs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Database Manager
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
||||||
|
#[sea_orm(table_name = "open_state")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key)]
|
||||||
|
pub uid: u32,
|
||||||
|
pub state_id: u32,
|
||||||
|
pub value: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter)]
|
||||||
|
pub enum Relation {
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RelationTrait for Relation {
|
||||||
|
fn def(&self) -> RelationDef {
|
||||||
|
match self {
|
||||||
|
_ => panic!("Unknown relation type!"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
@ -1,6 +1,7 @@
|
|||||||
// Database Manager
|
// Database Manager
|
||||||
|
|
||||||
use sea_orm::entity::prelude::*;
|
use sea_orm::entity::prelude::*;
|
||||||
|
use chrono::NaiveDate;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
||||||
#[sea_orm(table_name = "player_info")]
|
#[sea_orm(table_name = "player_info")]
|
||||||
@ -8,10 +9,8 @@ pub struct Model {
|
|||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
pub uid: u32,
|
pub uid: u32,
|
||||||
pub nick_name: String,
|
pub nick_name: String,
|
||||||
pub level: u8,
|
|
||||||
pub signature: String,
|
pub signature: String,
|
||||||
pub birthday: u32,
|
pub birthday: NaiveDate,
|
||||||
pub world_level: u8,
|
|
||||||
pub namecard_id: u32,
|
pub namecard_id: u32,
|
||||||
pub finish_achievement_num: u32,
|
pub finish_achievement_num: u32,
|
||||||
pub tower_floor_index: u8,
|
pub tower_floor_index: u8,
|
||||||
|
26
src/dbmanager/player_prop.rs
Normal file
26
src/dbmanager/player_prop.rs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Database Manager
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
||||||
|
#[sea_orm(table_name = "player_prop")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key)]
|
||||||
|
pub uid: u32,
|
||||||
|
pub prop_id: u32,
|
||||||
|
pub prop_value: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter)]
|
||||||
|
pub enum Relation {
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RelationTrait for Relation {
|
||||||
|
fn def(&self) -> RelationDef {
|
||||||
|
match self {
|
||||||
|
_ => panic!("Unknown relation type!"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
25
src/dbmanager/reliquary_info.rs
Normal file
25
src/dbmanager/reliquary_info.rs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// Database Manager
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
||||||
|
#[sea_orm(table_name = "reliquary_info")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key)]
|
||||||
|
pub guid: i64,
|
||||||
|
pub main_prop_id: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter)]
|
||||||
|
pub enum Relation {
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RelationTrait for Relation {
|
||||||
|
fn def(&self) -> RelationDef {
|
||||||
|
match self {
|
||||||
|
_ => panic!("Unknown relation type!"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
25
src/dbmanager/reliquary_prop.rs
Normal file
25
src/dbmanager/reliquary_prop.rs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// Database Manager
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
||||||
|
#[sea_orm(table_name = "reliquary_prop")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key)]
|
||||||
|
pub guid: i64,
|
||||||
|
pub prop_id: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter)]
|
||||||
|
pub enum Relation {
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RelationTrait for Relation {
|
||||||
|
fn def(&self) -> RelationDef {
|
||||||
|
match self {
|
||||||
|
_ => panic!("Unknown relation type!"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
@ -7,7 +7,7 @@ use sea_orm::entity::prelude::*;
|
|||||||
pub struct Model {
|
pub struct Model {
|
||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
pub uid: u32,
|
pub uid: u32,
|
||||||
pub avatar: u64,
|
pub avatar: i64,
|
||||||
pub team: u8,
|
pub team: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
26
src/dbmanager/weapon_affix_info.rs
Normal file
26
src/dbmanager/weapon_affix_info.rs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Database Manager
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
||||||
|
#[sea_orm(table_name = "weapon_affix_info")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key)]
|
||||||
|
pub guid: i64,
|
||||||
|
pub affix_id: u32,
|
||||||
|
pub affix_value: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter)]
|
||||||
|
pub enum Relation {
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RelationTrait for Relation {
|
||||||
|
fn def(&self) -> RelationDef {
|
||||||
|
match self {
|
||||||
|
_ => panic!("Unknown relation type!"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
Loading…
Reference in New Issue
Block a user