tiger_lib/ck3/data/
difficulty.rs

1use crate::block::Block;
2use crate::context::ScopeContext;
3use crate::db::{Db, DbKind};
4use crate::everything::Everything;
5use crate::game::GameFlags;
6use crate::item::{Item, ItemLoader};
7use crate::scopes::Scopes;
8use crate::token::Token;
9use crate::tooltipped::Tooltipped;
10use crate::validator::Validator;
11
12#[derive(Clone, Debug)]
13pub struct PlayableDifficultyInfo {}
14
15inventory::submit! {
16    ItemLoader::Normal(GameFlags::Ck3, Item::PlayableDifficultyInfo, PlayableDifficultyInfo::add)
17}
18
19impl PlayableDifficultyInfo {
20    pub fn add(db: &mut Db, key: Token, block: Block) {
21        db.add(Item::PlayableDifficultyInfo, key, block, Box::new(Self {}));
22    }
23}
24
25impl DbKind for PlayableDifficultyInfo {
26    fn validate(&self, key: &Token, block: &Block, data: &Everything) {
27        let mut vd = Validator::new(block, data);
28        let mut sc = ScopeContext::new(Scopes::Character, key);
29
30        data.verify_exists(Item::Localization, key);
31        vd.field_trigger("is_shown", Tooltipped::No, &mut sc);
32    }
33}