Skip to content

Commit 8758d2e

Browse files
authored
Merge pull request #123 from utilForever/pillar
Add PILLAR and the Pillar Yard level
2 parents 5bdb237 + c40d905 commit 8758d2e

10 files changed

Lines changed: 150 additions & 11 deletions

File tree

Extensions/BabaEditor/LevelEditor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ const std::vector<ObjectEntry>& ObjectCatalog()
163163
{ ObjectType::KEKE, "KEKE", "Text: Nouns", ColorU8(238, 238, 238) },
164164
{ ObjectType::LAVA, "LAVA", "Text: Nouns", ColorU8(238, 238, 238) },
165165
{ ObjectType::LOVE, "LOVE", "Text: Nouns", ColorU8(238, 238, 238) },
166+
{ ObjectType::PILLAR, "PILLAR", "Text: Nouns", ColorU8(238, 238, 238) },
166167
{ ObjectType::ROCK, "ROCK", "Text: Nouns", ColorU8(238, 238, 238) },
167168
{ ObjectType::SKULL, "SKULL", "Text: Nouns", ColorU8(238, 238, 238) },
168169
{ ObjectType::STAR, "STAR", "Text: Nouns", ColorU8(238, 238, 238) },
@@ -187,6 +188,7 @@ const std::vector<ObjectEntry>& ObjectCatalog()
187188
ColorU8(238, 238, 238) },
188189
{ ObjectType::ICON_ALGAE, "ALGAE", "Objects", ColorU8(84, 150, 64) },
189190
{ ObjectType::ICON_BABA, "BABA", "Objects", ColorU8(236, 236, 236) },
191+
{ ObjectType::ICON_BRICK, "BRICK", "Objects", ColorU8(42, 47, 39) },
190192
{ ObjectType::ICON_CRAB, "CRAB", "Objects", ColorU8(196, 90, 117) },
191193
{ ObjectType::ICON_FLAG, "FLAG", "Objects", ColorU8(237, 217, 96) },
192194
{ ObjectType::ICON_FLOWER, "FLOWER", "Objects", ColorU8(216, 52, 105) },
@@ -196,6 +198,7 @@ const std::vector<ObjectEntry>& ObjectCatalog()
196198
{ ObjectType::ICON_KEKE, "KEKE", "Objects", ColorU8(196, 90, 117) },
197199
{ ObjectType::ICON_LAVA, "LAVA", "Objects", ColorU8(225, 74, 52) },
198200
{ ObjectType::ICON_LOVE, "LOVE", "Objects", ColorU8(241, 120, 242) },
201+
{ ObjectType::ICON_PILLAR, "PILLAR", "Objects", ColorU8(81, 111, 148) },
199202
{ ObjectType::ICON_ROCK, "ROCK", "Objects", ColorU8(74, 67, 55) },
200203
{ ObjectType::ICON_SKULL, "SKULL", "Objects", ColorU8(238, 238, 238) },
201204
{ ObjectType::ICON_STAR, "STAR", "Objects", ColorU8(227, 142, 89) },

Extensions/BabaGUI/main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
icon_images = {
1111
pyBaba.ObjectType.ICON_ALGAE: "ALGAE",
1212
pyBaba.ObjectType.ICON_BABA: "BABA",
13+
pyBaba.ObjectType.ICON_BRICK: "BRICK",
1314
pyBaba.ObjectType.ICON_CRAB: "CRAB",
1415
pyBaba.ObjectType.ICON_FLAG: "FLAG",
1516
pyBaba.ObjectType.ICON_ICE: "ICE",
@@ -22,6 +23,7 @@
2223
pyBaba.ObjectType.ICON_GRASS: "GRASS",
2324
pyBaba.ObjectType.ICON_LAVA: "LAVA",
2425
pyBaba.ObjectType.ICON_LOVE: "LOVE",
26+
pyBaba.ObjectType.ICON_PILLAR: "PILLAR",
2527
pyBaba.ObjectType.ICON_SKULL: "SKULL",
2628
pyBaba.ObjectType.ICON_STAR: "STAR",
2729
pyBaba.ObjectType.ICON_FLOWER: "FLOWER",
@@ -51,6 +53,7 @@
5153
pyBaba.ObjectType.MELT: "MELT",
5254
pyBaba.ObjectType.MOVE: "MOVE",
5355
pyBaba.ObjectType.HOT: "HOT",
56+
pyBaba.ObjectType.PILLAR: "PILLAR",
5457
pyBaba.ObjectType.SKULL: "SKULL",
5558
pyBaba.ObjectType.STAR: "STAR",
5659
pyBaba.ObjectType.DEFEAT: "DEFEAT",
2.65 KB
Loading
2.69 KB
Loading
2.69 KB
Loading

Resources/Maps/pillar_yard.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
24 14
2+
25 67 86 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132 132
3+
132 111 132 132 132 132 132 132 132 132 132 132 132 132 132 132 111 132 158 132 132 132 132 132
4+
132 132 132 132 132 48 67 79 132 132 158 132 132 132 132 132 132 111 132 132 132 132 111 132
5+
132 132 132 132 132 132 132 132 132 132 132 132 158 132 132 132 132 132 132 132 111 132 132 132
6+
132 132 132 121 121 121 132 121 132 121 132 132 132 132 132 132 132 132 132 132 132 132 132 132
7+
132 132 132 121 174 174 174 174 174 121 132 132 132 132 132 166 166 166 166 166 132 132 132 132
8+
64 132 132 121 174 170 170 170 174 121 132 132 132 132 121 166 121 121 121 166 132 132 132 132
9+
67 132 132 121 174 170 114 170 158 121 121 121 121 121 121 166 121 135 121 166 132 132 132 132
10+
78 132 132 121 174 170 170 170 174 121 111 132 132 132 132 166 121 121 121 166 111 132 132 132
11+
132 132 132 121 174 174 174 174 174 121 132 132 132 132 132 166 166 166 166 166 132 132 132 132
12+
132 132 132 121 121 132 132 121 121 121 132 132 132 132 132 132 132 132 132 132 132 132 132 132
13+
132 111 132 132 132 132 132 132 132 132 132 158 132 132 132 132 132 132 132 132 132 132 132 132
14+
132 132 132 132 132 4 67 77 132 132 132 132 132 132 132 111 132 158 132 111 132 132 132 132
15+
132 132 132 132 132 132 132 132 132 132 132 132 132 132 111 132 132 132 132 132 132 56 67 87

Tests/PythonTests/test_game.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,40 @@ def test_game_turns_rules_multiple_you_and_win():
454454
assert game.GetPlayState() == pyBaba.PlayState.WON
455455

456456

457+
def test_game_pillar_yard_load_and_reset():
458+
game = pyBaba.Game("Resources/Maps/pillar_yard.txt")
459+
assert game.GetMap().GetWidth() == 24
460+
assert game.GetMap().GetHeight() == 14
461+
assert game.GetRuleManager().GetNumRules() == 5
462+
assert game.GetMap().At(6, 7).HasType(pyBaba.ObjectType.ICON_BABA)
463+
assert game.GetMap().At(8, 7).HasType(pyBaba.ObjectType.ICON_PILLAR)
464+
assert game.GetMap().At(3, 4).HasType(pyBaba.ObjectType.ICON_BRICK)
465+
assert game.GetMap().At(15, 7).HasType(pyBaba.ObjectType.ICON_STAR)
466+
assert game.GetMap().At(17, 7).HasType(pyBaba.ObjectType.ICON_FLAG)
467+
468+
game.MovePlayer(pyBaba.Direction.RIGHT)
469+
game.Reset()
470+
assert game.GetMap().At(6, 7).HasType(pyBaba.ObjectType.ICON_BABA)
471+
assert game.GetMap().At(8, 7).HasType(pyBaba.ObjectType.ICON_PILLAR)
472+
assert game.GetRuleManager().GetNumRules() == 5
473+
assert game.GetPlayState() == pyBaba.PlayState.PLAYING
474+
475+
476+
def test_game_pillar_yard_forms_pillar_is_you_and_wins():
477+
game = pyBaba.Game("Resources/Maps/pillar_yard.txt")
478+
solution = (
479+
"RRRRRRUUUUUULLDDDDDLDRRRDDDDDLUUUULURRRRUUUUUULLLLLLLLL"
480+
"DDLDRRRRURDDDDDDDRDLLLLULD"
481+
)
482+
483+
_move(game, solution)
484+
assert game.GetRuleManager().HasProperty(
485+
[pyBaba.ObjectType.ICON_PILLAR], pyBaba.ObjectType.YOU
486+
)
487+
assert game.GetMap().At(17, 7).HasType(pyBaba.ObjectType.ICON_PILLAR)
488+
assert game.GetPlayState() == pyBaba.PlayState.WON
489+
490+
457491
def test_game_sink_reparses_destroyed_rule_text():
458492
game = pyBaba.Game("Resources/Maps/sink_rule_reparse.txt")
459493

Tests/PythonTests/test_gui.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""Behavior checks for GUI-owned direction decisions."""
22

3+
import importlib.util
34
from pathlib import Path
5+
import sys
46

57
import pyBaba
68

@@ -81,19 +83,25 @@ def _gif_palette_starts(data):
8183
position += 1
8284

8385

84-
def test_affection_sprite_palettes_keep_colored_pixels_opaque():
86+
def test_sprite_palettes_keep_colored_pixels_opaque():
8587
root = Path(__file__).parents[2]
8688
sprites = {
87-
"Extensions/BabaGUI/sprites/text/ALGAE.gif": ((84, 150, 64), 1),
88-
"Extensions/BabaGUI/sprites/text/KEKE.gif": ((196, 90, 117), 1),
89-
"Extensions/BabaGUI/sprites/text/LOVE.gif": ((241, 120, 242), 1),
90-
"Extensions/BabaGUI/sprites/text/MOVE.gif": ((119, 171, 63), 1),
91-
"Extensions/BabaGUI/sprites/icon/ALGAE.gif": ((84, 150, 64), 1),
92-
"Extensions/BabaGUI/sprites/icon/KEKE.gif": ((196, 90, 117), 2),
93-
"Extensions/BabaGUI/sprites/icon/LOVE.gif": ((241, 120, 242), 1),
89+
"Extensions/BabaGUI/sprites/text/ALGAE.gif": (((84, 150, 64),), 1),
90+
"Extensions/BabaGUI/sprites/text/KEKE.gif": (((196, 90, 117),), 1),
91+
"Extensions/BabaGUI/sprites/text/LOVE.gif": (((241, 120, 242),), 1),
92+
"Extensions/BabaGUI/sprites/text/MOVE.gif": (((119, 171, 63),), 1),
93+
"Extensions/BabaGUI/sprites/icon/ALGAE.gif": (((84, 150, 64),), 1),
94+
"Extensions/BabaGUI/sprites/icon/KEKE.gif": (((196, 90, 117),), 2),
95+
"Extensions/BabaGUI/sprites/icon/LOVE.gif": (((241, 120, 242),), 1),
96+
"Extensions/BabaGUI/sprites/text/PILLAR.gif": (((81, 111, 148),), 1),
97+
"Extensions/BabaGUI/sprites/icon/PILLAR.gif": (
98+
((81, 111, 148), (36, 36, 36)),
99+
2,
100+
),
101+
"Extensions/BabaGUI/sprites/icon/BRICK.gif": (((42, 47, 39),), 1),
94102
}
95103

96-
for relative, (color, transparent_index) in sprites.items():
104+
for relative, (colors, transparent_index) in sprites.items():
97105
data = (root / relative).read_bytes()
98106
assert int.from_bytes(data[6:8], "little") == 24
99107
assert int.from_bytes(data[8:10], "little") == 24
@@ -111,8 +119,10 @@ def test_affection_sprite_palettes_keep_colored_pixels_opaque():
111119
assert all(data[index + 6] == transparent_index for index in controls)
112120

113121
for start in palettes:
114-
assert tuple(data[start : start + 3]) == color
122+
for palette_index, color in enumerate(colors):
123+
offset = start + palette_index * 3
124+
assert tuple(data[offset : offset + 3]) == color
115125

116-
for palette_index in range(1, transparent_index + 1):
126+
for palette_index in range(len(colors), transparent_index + 1):
117127
offset = start + palette_index * 3
118128
assert max(data[offset : offset + 3]) <= 8

Tests/UnitTests/EditorTests.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,44 @@ TEST_CASE("Editor - Affection sprite assets")
183183
}
184184
}
185185

186+
TEST_CASE("Editor - Pillar Yard round trip and sprite assets")
187+
{
188+
namespace fs = std::filesystem;
189+
190+
LevelFile pillarYard;
191+
REQUIRE(LoadLevelFile(MAPS_DIR "pillar_yard.txt", pillarYard));
192+
CHECK(pillarYard.width == 24);
193+
CHECK(pillarYard.height == 14);
194+
CHECK(pillarYard.tiles[2 * pillarYard.width + 5][0] == ObjectType::PILLAR);
195+
CHECK(pillarYard.tiles[7 * pillarYard.width + 8][0] ==
196+
ObjectType::ICON_PILLAR);
197+
CHECK(pillarYard.tiles[4 * pillarYard.width + 3][0] ==
198+
ObjectType::ICON_BRICK);
199+
200+
const fs::path path =
201+
fs::current_path() / "baba-is-auto-pillar-yard-round-trip.txt";
202+
std::error_code error;
203+
CHECK(SaveLevelFile(path, pillarYard));
204+
205+
LevelFile loaded;
206+
REQUIRE(LoadLevelFile(path, loaded));
207+
CHECK(loaded.tiles == pillarYard.tiles);
208+
CHECK(loaded.directions == pillarYard.directions);
209+
210+
fs::remove(path, error);
211+
212+
const fs::path root = (fs::path(MAPS_DIR) / "../..").lexically_normal();
213+
214+
for (const char* asset : {
215+
"Extensions/BabaGUI/sprites/text/PILLAR.gif",
216+
"Extensions/BabaGUI/sprites/icon/PILLAR.gif",
217+
"Extensions/BabaGUI/sprites/icon/BRICK.gif",
218+
})
219+
{
220+
CHECK(fs::is_regular_file(root / asset));
221+
}
222+
}
223+
186224
TEST_CASE("Editor - Layer tile direction updates")
187225
{
188226
LevelFile::LayerTile tiles{ ObjectType::ICON_EMPTY, ObjectType::ICON_EMPTY,

Tests/UnitTests/GameTests.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,42 @@ TEST_CASE("Game - Turns")
328328
}
329329
}
330330

331+
TEST_CASE("Game - Pillar Yard")
332+
{
333+
SUBCASE("Loads and resets")
334+
{
335+
Game game(MAPS_DIR "pillar_yard.txt");
336+
CHECK(game.GetMap().GetWidth() == 24);
337+
CHECK(game.GetMap().GetHeight() == 14);
338+
CHECK(game.GetRuleManager().GetNumRules() == 5);
339+
CHECK(game.GetMap().At(6, 7).HasType(ObjectType::ICON_BABA));
340+
CHECK(game.GetMap().At(8, 7).HasType(ObjectType::ICON_PILLAR));
341+
CHECK(game.GetMap().At(3, 4).HasType(ObjectType::ICON_BRICK));
342+
CHECK(game.GetMap().At(15, 7).HasType(ObjectType::ICON_STAR));
343+
CHECK(game.GetMap().At(17, 7).HasType(ObjectType::ICON_FLAG));
344+
345+
game.MovePlayer(Direction::RIGHT);
346+
game.Reset();
347+
CHECK(game.GetMap().At(6, 7).HasType(ObjectType::ICON_BABA));
348+
CHECK(game.GetMap().At(8, 7).HasType(ObjectType::ICON_PILLAR));
349+
CHECK(game.GetRuleManager().GetNumRules() == 5);
350+
CHECK(game.GetPlayState() == PlayState::PLAYING);
351+
}
352+
353+
SUBCASE("Forms PILLAR IS YOU and wins")
354+
{
355+
Game game(MAPS_DIR "pillar_yard.txt");
356+
357+
Move(game,
358+
"RRRRRRUUUUUULLDDDDDLDRRRDDDDDLUUUULURRRRUUUUUULLLLLLLLL"
359+
"DDLDRRRRURDDDDDDDRDLLLLULD");
360+
CHECK(game.GetRuleManager().HasProperty({ ObjectType::ICON_PILLAR },
361+
ObjectType::YOU));
362+
CHECK(game.GetMap().At(17, 7).HasType(ObjectType::ICON_PILLAR));
363+
CHECK(game.GetPlayState() == PlayState::WON);
364+
}
365+
}
366+
331367
TEST_CASE("Game - Editor Smoke Map")
332368
{
333369
Game game(MAPS_DIR "editor_smoke.txt");

0 commit comments

Comments
 (0)