|
| 1 | +## The Approve Shield shows as a bubble around Hoppy, not as a tint on the sprite. |
| 2 | +## |
| 3 | +## Runs headless against Bay Area Blitz, the shared platformer level. Covers: the bubble is |
| 4 | +## hidden on spawn, appears when the shield is gained, replaces the old green tint, pops when |
| 5 | +## the shield absorbs a hit (and the hit still costs no health), hides once the pop finishes, |
| 6 | +## reopens for a second pickup, and clears instantly on death. |
| 7 | +extends SceneTree |
| 8 | +var failures := 0 |
| 9 | +var level |
| 10 | +var player |
| 11 | + |
| 12 | + |
| 13 | +func _initialize() -> void: call_deferred("run") |
| 14 | + |
| 15 | + |
| 16 | +func frames(count: int) -> void: |
| 17 | + for i in count: await physics_frame |
| 18 | + |
| 19 | + |
| 20 | +func check(ok: bool, message: String) -> void: |
| 21 | + print("PASS: " if ok else "FAIL: ", message) |
| 22 | + if not ok: failures += 1 |
| 23 | + |
| 24 | + |
| 25 | +func run() -> void: |
| 26 | + change_scene_to_file("res://scenes/platformer/bay_area_blitz.tscn") |
| 27 | + await frames(12) |
| 28 | + level = current_scene |
| 29 | + player = level.player |
| 30 | + await process_frame |
| 31 | + level._resume() |
| 32 | + var bubble: Node2D = player.bubble |
| 33 | + check(bubble != null and bubble.get_parent() == player, "The player owns a shield bubble child") |
| 34 | + check(bubble.get_index() > player.sprite.get_index() and bubble.z_index >= player.sprite.z_index, |
| 35 | + "The bubble draws in front of Hoppy's sprite") |
| 36 | + check(not bubble.visible and not bubble.active, "The bubble is hidden before any pickup") |
| 37 | + player.boost = 0 |
| 38 | + player.invulnerable = 0 |
| 39 | + player.shield = true |
| 40 | + check(bubble.visible and bubble.active, "Gaining the shield raises the bubble") |
| 41 | + await frames(3) |
| 42 | + check(player.sprite.modulate == Color.WHITE, "The shield no longer tints Hoppy green") |
| 43 | + check(bubble.visible and bubble.active, "The bubble stays while the shield holds") |
| 44 | + player.hp = 3 |
| 45 | + player.damage(0) |
| 46 | + check(player.hp == 3 and not player.shield, "The shield still absorbs one hit without health loss") |
| 47 | + check(not bubble.active, "Absorbing a hit pops the bubble") |
| 48 | + await frames(30) |
| 49 | + check(not bubble.visible, "The popped bubble is hidden once its pop animation ends") |
| 50 | + # The blink and boost tints survive the change. |
| 51 | + check(player.invulnerable > 0, "Absorbing a hit still grants invulnerability") |
| 52 | + player.boost = 5 |
| 53 | + await frames(2) |
| 54 | + check(player.sprite.modulate.r < 1.0, "The LGTM boost tint still shows") |
| 55 | + player.boost = 0 |
| 56 | + player.invulnerable = 0 |
| 57 | + # A second pickup reopens the bubble even if it was still popping. |
| 58 | + player.shield = true |
| 59 | + player.shield = false |
| 60 | + player.shield = true |
| 61 | + check(bubble.visible and bubble.active and bubble.modulate.a == 1.0, |
| 62 | + "A new shield reopens a popping bubble at full strength") |
| 63 | + player.shield = true |
| 64 | + check(bubble.active, "Setting an already-held shield is a no-op") |
| 65 | + # The level's real pickup path raises it too. |
| 66 | + player.shield = false |
| 67 | + await frames(30) |
| 68 | + var shield_item: Dictionary = {} |
| 69 | + for item in level.pickups: |
| 70 | + if item.kind == "approve_shield": shield_item = item |
| 71 | + check(not shield_item.is_empty(), "Bay Area still has an Approve Shield pickup") |
| 72 | + if not shield_item.is_empty(): |
| 73 | + player.invulnerable = 999 |
| 74 | + player.position = shield_item.origin |
| 75 | + player.velocity = Vector2.ZERO |
| 76 | + await frames(4) |
| 77 | + check(player.shield and bubble.visible and bubble.active, |
| 78 | + "Collecting the pickup raises the bubble") |
| 79 | + # Death clears it without waiting on an animation. |
| 80 | + player.invulnerable = 0 |
| 81 | + player.hp = 1 |
| 82 | + player.shield = true |
| 83 | + player.shield = false |
| 84 | + player.damage(0) |
| 85 | + check(player.hp == 0 and not bubble.visible and not bubble.active, |
| 86 | + "Death clears the bubble at once") |
| 87 | + print("Shield bubble suite finished with %d failure(s)" % failures) |
| 88 | + await process_frame |
| 89 | + quit(1 if failures > 0 else 0) |
0 commit comments