convert palette id to int

This commit is contained in:
2020-04-13 13:30:08 +01:00
parent 48e479c189
commit 1928334b27
4 changed files with 31 additions and 7 deletions

View File

@@ -1,3 +1,5 @@
use radix_fmt::radix_36;
pub mod avatar;
pub mod colour;
pub mod dialogue;
@@ -62,3 +64,23 @@ impl AnimationFrames for Vec<Image> {
string
}
}
fn from_base36(str: &str) -> u64 {
u64::from_str_radix(str, 36).unwrap()
}
#[test]
fn test_from_base36() {
assert_eq!(from_base36("0"), 0);
assert_eq!(from_base36("0z"), 35);
assert_eq!(from_base36("11"), 37);
}
fn to_base36(input: u64) -> String {
format!("{}", radix_36(input))
}
#[test]
fn test_to_base36() {
assert_eq!(to_base36(37), "11");
}