fix: created ships exact tech level

This commit is contained in:
Ilia Denisov
2026-02-17 19:06:26 +02:00
parent 16e281cfd6
commit 1379241967
6 changed files with 38 additions and 19 deletions
+23
View File
@@ -35,6 +35,29 @@ func TestCreateShips(t *testing.T) {
assert.Len(t, slices.Collect(c.RaceShipGroups(1)), 2)
}
func TestUnsafeCreateShips(t *testing.T) {
c, _ := newCache()
r := c.Race(Race_0_idx)
r.Tech = r.Tech.Set(game.TechDrive, 1.001)
r.Tech = r.Tech.Set(game.TechWeapons, 2.999)
r.Tech = r.Tech.Set(game.TechShields, 3.1003)
r.Tech = r.Tech.Set(game.TechCargo, 4.0005001)
sgi := c.CreateShipsUnsafe_T(Race_0_idx, c.MustShipClass(Race_0_idx, Race_0_Freighter).ID, R0_Planet_0_num, 1)
sg := c.ShipGroup(sgi)
assert.Equal(t, 1.001, sg.Tech.Value(game.TechDrive))
assert.Equal(t, 0., sg.Tech.Value(game.TechWeapons))
assert.Equal(t, 3.100, sg.Tech.Value(game.TechShields))
assert.Equal(t, 4.001, sg.Tech.Value(game.TechCargo))
sgi = c.CreateShipsUnsafe_T(Race_0_idx, c.MustShipClass(Race_0_idx, Race_0_Gunship).ID, R0_Planet_0_num, 1)
sg = c.ShipGroup(sgi)
assert.Equal(t, 1.001, sg.Tech.Value(game.TechDrive))
assert.Equal(t, 2.999, sg.Tech.Value(game.TechWeapons))
assert.Equal(t, 3.100, sg.Tech.Value(game.TechShields))
assert.Equal(t, 0., sg.Tech.Value(game.TechCargo))
}
func TestShipGroupMerge(t *testing.T) {
c, g := newCache()