move this function to lib so we can use it elsewhere
This commit is contained in:
parent
3bd67bcaf7
commit
5184060372
14
src/game.rs
14
src/game.rs
|
@ -1,4 +1,4 @@
|
||||||
use crate::{Avatar, Dialogue, Ending, Font, Item, Palette, Room, Sprite, TextDirection, Tile, ToBase36, Variable, transform_line_endings, segments_from_string};
|
use crate::{Avatar, Dialogue, Ending, Font, Item, Palette, Room, Sprite, TextDirection, Tile, ToBase36, Variable, transform_line_endings, segments_from_string, is_string_numeric};
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use loe::TransformMode;
|
use loe::TransformMode;
|
||||||
|
|
||||||
|
@ -221,18 +221,6 @@ impl ToString for Game {
|
||||||
segments.push(tile.to_string());
|
segments.push(tile.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
// for some reason the sprites with numeric IDs go first,
|
|
||||||
// then SPR A (avatar), then all the non-numeric IDs
|
|
||||||
fn is_string_numeric(str: String) -> bool {
|
|
||||||
for c in str.chars() {
|
|
||||||
if !c.is_numeric() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
for sprite in &self.sprites {
|
for sprite in &self.sprites {
|
||||||
if is_string_numeric(sprite.id.to_base36()) {
|
if is_string_numeric(sprite.id.to_base36()) {
|
||||||
segments.push(sprite.to_string());
|
segments.push(sprite.to_string());
|
||||||
|
|
12
src/lib.rs
12
src/lib.rs
|
@ -133,6 +133,18 @@ fn segments_from_string(string: String) -> Vec<String> {
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// for some reason the sprites with numeric IDs go first,
|
||||||
|
// then SPR A (avatar), then all the non-numeric IDs
|
||||||
|
fn is_string_numeric(str: String) -> bool {
|
||||||
|
for c in str.chars() {
|
||||||
|
if !c.is_numeric() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::{from_base36, ToBase36, optional_data_line, mock, segments_from_string};
|
use crate::{from_base36, ToBase36, optional_data_line, mock, segments_from_string};
|
||||||
|
|
Loading…
Reference in New Issue