JaneDoe-ZS/nap_gameserver/src/logic/game/fresh.rs
xeon 99123a15ef newtype fun
use newtypes for template ids, pros:
1) enforces id validation
2) ease of use (helper method for getting template struct right away)
2024-07-25 01:24:48 +03:00

42 lines
1 KiB
Rust

use data::tables::ProcedureConfigID;
use proto::{DungeonInfo, FreshSceneInfo, SceneInfo};
use crate::logic::{procedure::ProcedureManager, ESceneType};
use super::NapGameMode;
pub struct FreshGame {
pub procedure_mgr: ProcedureManager,
}
impl FreshGame {
pub fn new(start_procedure_id: ProcedureConfigID) -> Self {
Self {
procedure_mgr: ProcedureManager::new(start_procedure_id),
}
}
}
impl NapGameMode for FreshGame {
fn scene_type(&self) -> ESceneType {
ESceneType::Fresh
}
fn scene_info(&self) -> Option<SceneInfo> {
Some(SceneInfo {
scene_type: self.scene_type() as u32,
fresh_scene_info: Some(FreshSceneInfo {
beginner_procedure_id: self
.procedure_mgr
.procedure_id()
.map(|i| i.value() - 1)
.unwrap_or(0),
}),
..Default::default()
})
}
fn dungeon_info(&self) -> Option<DungeonInfo> {
None
}
}