package game_test import ( "testing" "github.com/iliadenisov/galaxy/pkg/model/game" "github.com/stretchr/testify/assert" ) func Test_ShipType(t *testing.T) { Gunship := game.ShipType{ Drive: 4, Armament: 2, Weapons: 2, Shields: 4, Cargo: 0, } assert.Equal(t, Gunship.EmptyMass(), 11.) Cruiser := game.ShipType{ Drive: 15, Armament: 1, Weapons: 15, Shields: 15, Cargo: 0, } assert.Equal(t, Cruiser.EmptyMass(), 45.) 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, upgradeCost, 225.) } func Test_CargoCapacity(t *testing.T) { test := func(cargoSize float64, expectCapacity float64) { ship := game.ShipType{ 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 Test_BombingPower(t *testing.T) { Gunship := game.ShipType{ 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) }