cmd: join ship groups

This commit is contained in:
Ilia Denisov
2025-11-13 21:53:10 +03:00
parent 33efa86065
commit 126f381b04
10 changed files with 661 additions and 153 deletions
+1 -69
View File
@@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/assert"
)
func TestShipType(t *testing.T) {
func TestEmptyMass(t *testing.T) {
Freighter := game.ShipType{
ShipTypeReport: game.ShipTypeReport{
Name: "Freighter",
@@ -43,72 +43,4 @@ func TestShipType(t *testing.T) {
},
}
assert.Equal(t, 45., Cruiser.EmptyMass())
sg := game.ShipGroup{
Type: Cruiser,
Number: 1,
State: "In_Orbit",
Drive: 1.0,
Weapons: 1.0,
Shields: 1.0,
Cargo: 1.0,
}
upgradeCost := sg.UpgradeDriveCost(2.0) +
sg.UpgradeWeaponsCost(2.0) +
sg.UpgradeShieldsCost(2.0) +
sg.UpgradeCargoCost(2.0)
assert.Equal(t, 225., upgradeCost)
}
func TestCargoCapacity(t *testing.T) {
test := func(cargoSize float64, expectCapacity float64) {
ship := game.ShipType{
ShipTypeReport: game.ShipTypeReport{
Drive: 1,
Armament: 1,
Weapons: 1,
Shields: 1,
Cargo: cargoSize,
},
}
sg := game.ShipGroup{
Type: ship,
Number: 1,
State: "In_Orbit",
Drive: 1.0,
Weapons: 1.0,
Shields: 1.0,
Cargo: 1.0,
}
assert.Equal(t, expectCapacity, sg.CargoCapacity())
}
test(1, 1.05)
test(5, 6.25)
test(10, 15)
test(50, 175)
test(100, 600)
}
func TestBombingPower(t *testing.T) {
Gunship := game.ShipType{
ShipTypeReport: game.ShipTypeReport{
Drive: 60.0,
Armament: 3,
Weapons: 30.0,
Shields: 100.0,
Cargo: 0.0,
},
}
sg := game.ShipGroup{
Type: Gunship,
Number: 1,
State: "In_Orbit",
Drive: 1.0,
Weapons: 1.0,
Shields: 1.0,
Cargo: 1.0,
}
expectedBombingPower := 139.295
result := sg.BombingPower()
assert.Equal(t, expectedBombingPower, result)
}