Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Extensions/BabaEditor/LevelEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ const std::vector<ObjectEntry>& ObjectCatalog()
{ ObjectType::ICON_EMPTY, "EMPTY", "Special", ColorU8(18, 22, 32) },
{ ObjectType::ALGAE, "ALGAE", "Text: Nouns", ColorU8(238, 238, 238) },
{ ObjectType::BABA, "BABA", "Text: Nouns", ColorU8(238, 238, 238) },
{ ObjectType::BRICK, "BRICK", "Text: Nouns", ColorU8(238, 238, 238) },
{ ObjectType::CRAB, "CRAB", "Text: Nouns", ColorU8(238, 238, 238) },
{ ObjectType::FLAG, "FLAG", "Text: Nouns", ColorU8(238, 238, 238) },
{ ObjectType::GRASS, "GRASS", "Text: Nouns", ColorU8(238, 238, 238) },
Expand Down
1 change: 1 addition & 0 deletions Extensions/BabaGUI/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
text_images = {
pyBaba.ObjectType.ALGAE: "ALGAE",
pyBaba.ObjectType.BABA: "BABA",
pyBaba.ObjectType.BRICK: "BRICK",
pyBaba.ObjectType.CRAB: "CRAB",
pyBaba.ObjectType.ICE: "ICE",
pyBaba.ObjectType.JELLY: "JELLY",
Expand Down
Binary file added Extensions/BabaGUI/sprites/text/BRICK.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions Resources/Maps/brick_wall.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
15 8
132 111 132 132 132 132 132 132 132 132 132 132 132 111 132
111 132 132 170 170 170 170 170 132 132 132 132 132 132 132
132 132 132 170 4 67 77 170 132 174 174 174 174 174 174
132 132 132 170 170 170 170 170 132 174 121 121 121 174 64
132 114 132 170 170 170 170 170 132 174 121 135 121 174 67
132 132 132 170 25 67 86 170 132 174 121 121 121 174 78
132 132 132 170 170 170 170 170 132 174 174 174 174 174 174
132 132 111 132 132 132 132 132 132 132 132 132 111 132 132
39 changes: 39 additions & 0 deletions Tests/PythonTests/test_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,45 @@ def test_game_pillar_yard_forms_pillar_is_you_and_wins():
assert game.GetPlayState() == pyBaba.PlayState.WON


def test_game_brick_wall_load_and_reset_preserves_bricks():
game = pyBaba.Game("Resources/Maps/brick_wall.txt")
bricks = [
(10, 3),
(11, 3),
(12, 3),
(10, 4),
(12, 4),
(10, 5),
(11, 5),
(12, 5),
]
assert game.GetMap().GetWidth() == 15
assert game.GetMap().GetHeight() == 8
assert game.GetRuleManager().GetNumRules() == 3
assert game.GetMap().At(1, 4).HasType(pyBaba.ObjectType.ICON_BABA)
assert game.GetMap().At(5, 4).HasType(pyBaba.ObjectType.ICON_TILE)
assert game.GetMap().At(11, 4).HasType(pyBaba.ObjectType.ICON_FLAG)
assert not game.GetMap().At(11, 4).HasType(pyBaba.ObjectType.ICON_BRICK)
assert game.GetMap().GetPositions(pyBaba.ObjectType.ICON_BRICK) == bricks

game.MovePlayer(pyBaba.Direction.RIGHT)
game.Reset()
assert game.GetMap().At(1, 4).HasType(pyBaba.ObjectType.ICON_BABA)
assert game.GetMap().GetPositions(pyBaba.ObjectType.ICON_BRICK) == bricks
assert game.GetRuleManager().GetNumRules() == 3
assert game.GetPlayState() == pyBaba.PlayState.PLAYING


def test_game_brick_wall_forms_baba_is_win_and_wins():
game = pyBaba.Game("Resources/Maps/brick_wall.txt")

_move(game, "RRRRRRDDLULDLUUDRRRULL")
assert game.GetRuleManager().HasProperty(
[pyBaba.ObjectType.ICON_BABA], pyBaba.ObjectType.WIN
)
assert game.GetPlayState() == pyBaba.PlayState.WON


def test_game_sink_reparses_destroyed_rule_text():
game = pyBaba.Game("Resources/Maps/sink_rule_reparse.txt")

Expand Down
1 change: 1 addition & 0 deletions Tests/PythonTests/test_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def test_sprite_palettes_keep_colored_pixels_opaque():
"Extensions/BabaGUI/sprites/text/KEKE.gif": (((196, 90, 117),), 1),
"Extensions/BabaGUI/sprites/text/LOVE.gif": (((241, 120, 242),), 1),
"Extensions/BabaGUI/sprites/text/MOVE.gif": (((119, 171, 63),), 1),
"Extensions/BabaGUI/sprites/text/BRICK.gif": (((144, 103, 62),), 1),
"Extensions/BabaGUI/sprites/icon/ALGAE.gif": (((84, 150, 64),), 1),
"Extensions/BabaGUI/sprites/icon/KEKE.gif": (((196, 90, 117),), 2),
"Extensions/BabaGUI/sprites/icon/LOVE.gif": (((241, 120, 242),), 1),
Expand Down
38 changes: 38 additions & 0 deletions Tests/UnitTests/EditorTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,44 @@ TEST_CASE("Editor - Pillar Yard round trip and sprite assets")
}
}

TEST_CASE("Editor - Brick Wall round trip and sprite assets")
{
namespace fs = std::filesystem;

LevelFile brickWall;
REQUIRE(LoadLevelFile(MAPS_DIR "brick_wall.txt", brickWall));
CHECK(brickWall.width == 15);
CHECK(brickWall.height == 8);
CHECK(brickWall.tiles[4 * brickWall.width + 10][0] ==
ObjectType::ICON_BRICK);
CHECK(brickWall.tiles[4 * brickWall.width + 11][0] ==
ObjectType::ICON_FLAG);
CHECK(brickWall.tiles[4 * brickWall.width + 11][1] ==
ObjectType::ICON_EMPTY);

const fs::path path =
fs::current_path() / "baba-is-auto-brick-wall-round-trip.txt";
std::error_code error;
CHECK(SaveLevelFile(path, brickWall));

LevelFile loaded;
REQUIRE(LoadLevelFile(path, loaded));
CHECK(loaded.tiles == brickWall.tiles);
CHECK(loaded.directions == brickWall.directions);

fs::remove(path, error);

const fs::path root = (fs::path(MAPS_DIR) / "../..").lexically_normal();

for (const char* asset : {
"Extensions/BabaGUI/sprites/text/BRICK.gif",
"Extensions/BabaGUI/sprites/icon/BRICK.gif",
})
{
CHECK(fs::is_regular_file(root / asset));
}
}

TEST_CASE("Editor - Layer tile direction updates")
{
LevelFile::LayerTile tiles{ ObjectType::ICON_EMPTY, ObjectType::ICON_EMPTY,
Expand Down
38 changes: 38 additions & 0 deletions Tests/UnitTests/GameTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <algorithm>
#include <array>
#include <string_view>
#include <vector>

using namespace baba_is_auto;

Expand Down Expand Up @@ -364,6 +365,43 @@ TEST_CASE("Game - Pillar Yard")
}
}

TEST_CASE("Game - Brick Wall")
{
SUBCASE("Loads and resets the brick layout")
{
Game game(MAPS_DIR "brick_wall.txt");
const std::vector<Position> bricks = {
{ 10, 3 }, { 11, 3 }, { 12, 3 }, { 10, 4 },
{ 12, 4 }, { 10, 5 }, { 11, 5 }, { 12, 5 },
};
CHECK(game.GetMap().GetWidth() == 15);
CHECK(game.GetMap().GetHeight() == 8);
CHECK(game.GetRuleManager().GetNumRules() == 3);
CHECK(game.GetMap().At(1, 4).HasType(ObjectType::ICON_BABA));
CHECK(game.GetMap().At(5, 4).HasType(ObjectType::ICON_TILE));
CHECK(game.GetMap().At(11, 4).HasType(ObjectType::ICON_FLAG));
CHECK_FALSE(game.GetMap().At(11, 4).HasType(ObjectType::ICON_BRICK));
CHECK(game.GetMap().GetPositions(ObjectType::ICON_BRICK) == bricks);

game.MovePlayer(Direction::RIGHT);
game.Reset();
CHECK(game.GetMap().At(1, 4).HasType(ObjectType::ICON_BABA));
CHECK(game.GetMap().GetPositions(ObjectType::ICON_BRICK) == bricks);
CHECK(game.GetRuleManager().GetNumRules() == 3);
CHECK(game.GetPlayState() == PlayState::PLAYING);
}

SUBCASE("Forms BABA IS WIN and wins")
{
Game game(MAPS_DIR "brick_wall.txt");

Move(game, "RRRRRRDDLULDLUUDRRRULL");
CHECK(game.GetRuleManager().HasProperty({ ObjectType::ICON_BABA },
ObjectType::WIN));
CHECK(game.GetPlayState() == PlayState::WON);
}
}

TEST_CASE("Game - Editor Smoke Map")
{
Game game(MAPS_DIR "editor_smoke.txt");
Expand Down
Loading