@@ 31,6 31,19 @@ type Ship struct {
Rooms []Room
}
+// NewEnemyShip returns a 5-room layout that mirrors NewPlayerShip but with
+// every room shifted +24 tiles along the X axis so the enemy ship sits on
+// the right half of the virtual screen.
+func NewEnemyShip() Ship {
+ player := NewPlayerShip()
+ rooms := make([]Room, len(player.Rooms))
+ for i, r := range player.Rooms {
+ r.GridX += 24
+ rooms[i] = r
+ }
+ return Ship{Rooms: rooms}
+}
+
// NewPlayerShip returns a hard-coded 5-room placeholder layout:
// Pilot front-left, Weapons mid-upper, Shields mid-center,
// MedBay mid-lower, Engines rear-right.
@@ 0,0 1,48 @@
+package main
+
+import "testing"
+
+// TestNewEnemyShip_roomCount verifies that NewEnemyShip returns exactly 5 rooms.
+func TestNewEnemyShip_roomCount(t *testing.T) {
+ enemy := NewEnemyShip()
+ if len(enemy.Rooms) != 5 {
+ t.Fatalf("expected 5 rooms, got %d", len(enemy.Rooms))
+ }
+}
+
+// TestNewEnemyShip_shifted verifies that each enemy room has GridX shifted by +24
+// relative to the corresponding player room, while GridY/GridW/GridH/Role/Name
+// are unchanged.
+func TestNewEnemyShip_shifted(t *testing.T) {
+ player := NewPlayerShip()
+ enemy := NewEnemyShip()
+
+ if len(enemy.Rooms) != len(player.Rooms) {
+ t.Fatalf("room count mismatch: enemy %d, player %d", len(enemy.Rooms), len(player.Rooms))
+ }
+
+ for i := range player.Rooms {
+ p := player.Rooms[i]
+ e := enemy.Rooms[i]
+
+ wantGridX := p.GridX + 24
+ if e.GridX != wantGridX {
+ t.Errorf("rooms[%d] GridX = %d, want %d (player %d + 24)", i, e.GridX, wantGridX, p.GridX)
+ }
+ if e.GridY != p.GridY {
+ t.Errorf("rooms[%d] GridY = %d, want %d", i, e.GridY, p.GridY)
+ }
+ if e.GridW != p.GridW {
+ t.Errorf("rooms[%d] GridW = %d, want %d", i, e.GridW, p.GridW)
+ }
+ if e.GridH != p.GridH {
+ t.Errorf("rooms[%d] GridH = %d, want %d", i, e.GridH, p.GridH)
+ }
+ if e.Role != p.Role {
+ t.Errorf("rooms[%d] Role = %v, want %v", i, e.Role, p.Role)
+ }
+ if e.Name != p.Name {
+ t.Errorf("rooms[%d] Name = %q, want %q", i, e.Name, p.Name)
+ }
+ }
+}