name room and give tiles appropriate names too

This commit is contained in:
Max Bradbury 2020-11-08 15:30:39 +00:00
parent 8c92b05b74
commit f9b0f6b6db
2 changed files with 9 additions and 4 deletions

View File

@ -302,7 +302,7 @@ pub fn add_room() -> String {
let tile = Tile {
// "0" will get overwritten to a new, safe tile ID
id: "0".to_string(),
name: tile_name(&state.room_name, &(row * column)),
name: tile_name(&state.room_name, &((row * SD) + column + 1)),
wall: None,
animation_frames: vec![Image { pixels }],
colour_id: None
@ -324,7 +324,7 @@ pub fn add_room() -> String {
game.add_room(bitsy_parser::Room {
id: "0".to_string(),
palette_id,
name: None,
name: state.room_name.clone(),
tiles: tile_ids,
items: vec![],
exits: vec![],
@ -357,7 +357,7 @@ pub fn output() -> String {
#[cfg(test)]
mod test {
use crate::{add_room, load_image, load_default_game, output, get_preview};
use crate::{add_room, load_image, load_default_game, output, get_preview, set_room_name};
#[test]
fn image_to_base64() {
@ -388,8 +388,9 @@ mod test {
fn example() {
load_default_game();
load_image(include_str!("test-resources/test.png.base64").trim().to_string());
set_room_name("test".to_string());
println!("add_room(): {}", add_room());
// todo what? why are extraneous pixels appearing in the output tiles?
assert_eq!( output(), include_str!("test-resources/expected.bitsy"));
assert_eq!(output(), include_str!("test-resources/expected.bitsy"));
}
}

View File

@ -47,6 +47,7 @@ a,a,1,1,2,2,3,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
NAME test
PAL 0
TIL a
@ -69,6 +70,7 @@ TIL 1
00011000
00011000
00111100
NAME test 3
TIL 2
00111100
@ -79,6 +81,7 @@ TIL 2
00110000
01100000
01111110
NAME test 5
TIL 3
00111100
@ -89,6 +92,7 @@ TIL 3
01100110
01100110
00111100
NAME test 7
SPR A
00011000