use crate::resources::Resource;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InventoryConfig {
pub enabled: bool,
pub default_capacity: usize,
pub allow_stacking: bool,
pub max_stack_size: u32,
}
impl Resource for InventoryConfig {}
impl Default for InventoryConfig {
fn default() -> Self {
Self {
enabled: true,
default_capacity: 0, allow_stacking: true,
max_stack_size: 99,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_default_config() {
let config = InventoryConfig::default();
assert_eq!(config.default_capacity, 0);
assert!(config.allow_stacking);
assert_eq!(config.max_stack_size, 99);
}
#[test]
fn test_custom_config() {
let config = InventoryConfig {
enabled: false,
default_capacity: 20,
allow_stacking: false,
max_stack_size: 1,
};
assert!(!config.enabled);
assert_eq!(config.default_capacity, 20);
assert!(!config.allow_stacking);
assert_eq!(config.max_stack_size, 1);
}
}