use std::path::{Path, PathBuf};
use crate::traits::GamePlugin;
pub struct GenericGame {
id: String,
name: String,
install_path: Option<PathBuf>,
mod_dir: String,
}
impl GenericGame {
pub fn new(
id: impl Into<String>,
name: impl Into<String>,
install_path: Option<PathBuf>,
mod_dir: impl Into<String>,
) -> Self {
Self {
id: id.into(),
name: name.into(),
install_path,
mod_dir: mod_dir.into(),
}
}
}
impl GamePlugin for GenericGame {
fn game_id(&self) -> &str {
&self.id
}
fn display_name(&self) -> &str {
&self.name
}
fn detect_install(&self) -> Option<PathBuf> {
self.install_path.clone().filter(|p| p.exists())
}
fn mod_directory(&self, install: &Path) -> PathBuf {
install.join(&self.mod_dir)
}
}