~bigbes/game-prototype-ftl

ref: aa11b70ce5637b345f60e1a6407c21683d811a02 game-prototype-ftl/ship.go -rw-r--r-- 1.3 KiB
aa11b70c — Eugene Blikh docs(crew-movement): design a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main

// RoomRole identifies the functional purpose of a room aboard a ship.
// Rendering code maps roles to colors; ship data itself stays
// free of any renderer-specific information.
type RoomRole int

const (
	RolePilot RoomRole = iota
	RoleWeapons
	RoleShields
	RoleMedBay
	RoleEngines
)

// Room describes a rectangular cell on the ship grid.
// All coordinates and sizes are in tile units; conversion to pixels
// happens only in the renderer.
type Room struct {
	ID    int
	Name  string
	GridX int
	GridY int
	GridW int
	GridH int
	Role  RoomRole
}

// Ship is a pure-data description of a ship layout.
type Ship struct {
	Rooms []Room
}

// NewPlayerShip returns a hard-coded 5-room placeholder layout:
// Pilot front-left, Weapons mid-upper, Shields mid-center,
// MedBay mid-lower, Engines rear-right.
func NewPlayerShip() Ship {
	return Ship{
		Rooms: []Room{
			{ID: 1, Name: "Pilot", GridX: 3, GridY: 9, GridW: 3, GridH: 3, Role: RolePilot},
			{ID: 2, Name: "Weapons", GridX: 6, GridY: 6, GridW: 4, GridH: 3, Role: RoleWeapons},
			{ID: 3, Name: "Shields", GridX: 6, GridY: 9, GridW: 4, GridH: 3, Role: RoleShields},
			{ID: 4, Name: "MedBay", GridX: 6, GridY: 12, GridW: 4, GridH: 3, Role: RoleMedBay},
			{ID: 5, Name: "Engines", GridX: 10, GridY: 9, GridW: 3, GridH: 3, Role: RoleEngines},
		},
	}
}