Skip to content
/ ck3save Public

Ergonomically work with CK3 saves (regular and ironman)

License

Notifications You must be signed in to change notification settings

rakaly/ck3save

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ci Version

CK3 Save

CK3 Save is a library to ergonomically work with Crusader Kings III (CK3) saves (ironman + regular).

use ck3save::{
    models::{Gamestate, HeaderBorrowed},
    Ck3File, Encoding,
};

let data = std::fs::read("assets/saves/Jarl_Ivar_of_the_Isles_867_01_01.ck3")?;
let file = Ck3File::from_slice(&data)?;
assert_eq!(file.encoding(), Encoding::TextZip);

let meta_data = file.meta();
let meta = meta_data.parse()?;
let resolver = std::collections::HashMap::<u16, &str>::new();
let header: HeaderBorrowed = meta.deserializer(&resolver).deserialize()?;

let mut zip_sink = Vec::new();
let parsed_file = file.parse(&mut zip_sink)?;
let save: Gamestate = parsed_file.deserializer(&resolver).deserialize()?;
assert_eq!(save.meta_data.version, String::from("1.0.2"));
assert_eq!(header.meta_data.version, String::from("1.0.2"));

Ironman

Ironman saves are supported through a provided TokenResolver. Per PDS counsel, the data to construct such a TokenResolver is not distributed here.

About

Ergonomically work with CK3 saves (regular and ironman)

Topics

Resources

License

Stars

Watchers

Forks

Languages