diff --git a/models/calc.go b/models/calc.go index 597354f..f40cb3c 100644 --- a/models/calc.go +++ b/models/calc.go @@ -132,6 +132,103 @@ func EnergyMineCost(ilvl int64) Resources { return cost } +func FussionReactorCost(ilvl int64) Resources { + lvl := float64(ilvl) + base := Resources{ + Metal: 900, + Crystal: 360, + Deuterium: 180, + Energy: 0, + } + // cost = base * 1.8^(lvl-1) + cost := Resources{} + cost.Metal = int64(float64(base.Metal) * math.Pow(1.8, lvl-1)) + cost.Crystal = int64(float64(base.Crystal) * math.Pow(1.8, lvl-1)) + cost.Deuterium = int64(float64(base.Deuterium) * math.Pow(1.8, lvl-1)) + cost.Energy = int64(float64(base.Energy) * math.Pow(1.8, lvl-1)) + return cost +} +func RoboticsFactoryCost(ilvl int64) Resources { + lvl := float64(ilvl) + base := Resources{ + Metal: 400, + Crystal: 120, + Deuterium: 200, + Energy: 0, + } + // cost = base * 2^(lvl-1) + cost := Resources{} + cost.Metal = int64(float64(base.Metal) * math.Pow(2, lvl-1)) + cost.Crystal = int64(float64(base.Crystal) * math.Pow(2, lvl-1)) + cost.Deuterium = int64(float64(base.Deuterium) * math.Pow(2, lvl-1)) + cost.Energy = int64(float64(base.Energy) * math.Pow(2, lvl-1)) + return cost +} +func ShipyardCost(ilvl int64) Resources { + lvl := float64(ilvl) + base := Resources{ + Metal: 400, + Crystal: 200, + Deuterium: 100, + Energy: 0, + } + // cost = base * 2^(lvl-1) + cost := Resources{} + cost.Metal = int64(float64(base.Metal) * math.Pow(2, lvl-1)) + cost.Crystal = int64(float64(base.Crystal) * math.Pow(2, lvl-1)) + cost.Deuterium = int64(float64(base.Deuterium) * math.Pow(2, lvl-1)) + cost.Energy = int64(float64(base.Energy) * math.Pow(2, lvl-1)) + return cost +} +func MetalStorageCost(ilvl int64) Resources { + lvl := float64(ilvl) + base := Resources{ + Metal: 1000, + Crystal: 0, + Deuterium: 0, + Energy: 0, + } + // cost = base * 2^(lvl-1) + cost := Resources{} + cost.Metal = int64(float64(base.Metal) * math.Pow(2, lvl-1)) + cost.Crystal = 0 + cost.Deuterium = 0 + cost.Energy = 0 + return cost +} +func CrystalStorageCost(ilvl int64) Resources { + lvl := float64(ilvl) + base := Resources{ + Metal: 1000, + Crystal: 500, + Deuterium: 0, + Energy: 0, + } + // cost = base * 2^(lvl-1) + cost := Resources{} + cost.Metal = int64(float64(base.Metal) * math.Pow(2, lvl-1)) + cost.Crystal = int64(float64(base.Crystal) * math.Pow(2, lvl-1)) + cost.Deuterium = 0 + cost.Energy = 0 + return cost +} +func DeuteriumStorageCost(ilvl int64) Resources { + lvl := float64(ilvl) + base := Resources{ + Metal: 1000, + Crystal: 1000, + Deuterium: 0, + Energy: 0, + } + // cost = base * 2^(lvl-1) + cost := Resources{} + cost.Metal = int64(float64(base.Metal) * math.Pow(2, lvl-1)) + cost.Crystal = int64(float64(base.Crystal) * math.Pow(2, lvl-1)) + cost.Deuterium = int64(float64(base.Deuterium) * math.Pow(2, lvl-1)) + cost.Energy = int64(float64(base.Energy) * math.Pow(2, lvl-1)) + return cost +} + func RessearchLabCost(ilvl int64) Resources { lvl := float64(ilvl) base := Resources{ @@ -140,7 +237,55 @@ func RessearchLabCost(ilvl int64) Resources { Deuterium: 200, Energy: 0, } - // cost = base * 1.5^(lvl-1) + // cost = base * 2^(lvl-1) + cost := Resources{} + cost.Metal = int64(float64(base.Metal) * math.Pow(2, lvl-1)) + cost.Crystal = int64(float64(base.Crystal) * math.Pow(2, lvl-1)) + cost.Deuterium = int64(float64(base.Deuterium) * math.Pow(2, lvl-1)) + cost.Energy = int64(float64(base.Energy) * math.Pow(2, lvl-1)) + return cost +} +func AllianceDepotCost(ilvl int64) Resources { + lvl := float64(ilvl) + base := Resources{ + Metal: 20000, + Crystal: 40000, + Deuterium: 0, + Energy: 0, + } + // cost = base * 2^(lvl-1) + cost := Resources{} + cost.Metal = int64(float64(base.Metal) * math.Pow(2, lvl-1)) + cost.Crystal = int64(float64(base.Crystal) * math.Pow(2, lvl-1)) + cost.Deuterium = int64(float64(base.Deuterium) * math.Pow(2, lvl-1)) + cost.Energy = int64(float64(base.Energy) * math.Pow(2, lvl-1)) + return cost +} +func MissileSiloCost(ilvl int64) Resources { + lvl := float64(ilvl) + base := Resources{ + Metal: 20000, + Crystal: 20000, + Deuterium: 1000, + Energy: 0, + } + // cost = base * 2^(lvl-1) + cost := Resources{} + cost.Metal = int64(float64(base.Metal) * math.Pow(2, lvl-1)) + cost.Crystal = int64(float64(base.Crystal) * math.Pow(2, lvl-1)) + cost.Deuterium = int64(float64(base.Deuterium) * math.Pow(2, lvl-1)) + cost.Energy = int64(float64(base.Energy) * math.Pow(2, lvl-1)) + return cost +} +func SpaceDockCost(ilvl int64) Resources { + lvl := float64(ilvl) + base := Resources{ + Metal: 20000, + Crystal: 20000, + Deuterium: 1000, + Energy: 0, + } + // cost = base * 2^(lvl-1) cost := Resources{} cost.Metal = int64(float64(base.Metal) * math.Pow(2, lvl-1)) cost.Crystal = int64(float64(base.Crystal) * math.Pow(2, lvl-1)) diff --git a/models/calc_test.go b/models/calc_test.go index da48250..2c90650 100644 --- a/models/calc_test.go +++ b/models/calc_test.go @@ -55,8 +55,53 @@ func TestMineCost(t *testing.T) { assert.Equal(t, Resources{Metal: 112, Crystal: 45}, EnergyMineCost(2)) assert.Equal(t, Resources{Metal: 21894, Crystal: 8757}, EnergyMineCost(15)) + // FussionReactorCost + assert.Equal(t, Resources{Metal: 900, Crystal: 360, Deuterium: 180}, FussionReactorCost(1)) + assert.Equal(t, Resources{Metal: 1620, Crystal: 648, Deuterium: 324}, FussionReactorCost(2)) + assert.Equal(t, Resources{Metal: 3373320, Crystal: 1349328, Deuterium: 674664}, FussionReactorCost(15)) + + // roboticsfactory + assert.Equal(t, Resources{Metal: 400, Crystal: 120, Deuterium: 200}, RoboticsFactoryCost(1)) + assert.Equal(t, Resources{Metal: 800, Crystal: 240, Deuterium: 400}, RoboticsFactoryCost(2)) + assert.Equal(t, Resources{Metal: 6553600, Crystal: 1966080, Deuterium: 3276800}, RoboticsFactoryCost(15)) + + // shipyard + assert.Equal(t, Resources{Metal: 400, Crystal: 200, Deuterium: 100}, ShipyardCost(1)) + assert.Equal(t, Resources{Metal: 800, Crystal: 400, Deuterium: 200}, ShipyardCost(2)) + assert.Equal(t, Resources{Metal: 6553600, Crystal: 3276800, Deuterium: 1638400}, ShipyardCost(15)) + + // metalstorage + assert.Equal(t, Resources{Metal: 1000}, MetalStorageCost(1)) + assert.Equal(t, Resources{Metal: 2000}, MetalStorageCost(2)) + assert.Equal(t, Resources{Metal: 16384000}, MetalStorageCost(15)) + + // crystalstorage + assert.Equal(t, Resources{Metal: 1000, Crystal: 500}, CrystalStorageCost(1)) + assert.Equal(t, Resources{Metal: 2000, Crystal: 1000}, CrystalStorageCost(2)) + assert.Equal(t, Resources{Metal: 16384000, Crystal: 8192000}, CrystalStorageCost(15)) + + // deuteriumstorage + assert.Equal(t, Resources{Metal: 1000, Crystal: 1000}, DeuteriumStorageCost(1)) + assert.Equal(t, Resources{Metal: 2000, Crystal: 2000}, DeuteriumStorageCost(2)) + assert.Equal(t, Resources{Metal: 16384000, Crystal: 16384000}, DeuteriumStorageCost(15)) + // researchlab assert.Equal(t, Resources{Metal: 200, Crystal: 400, Deuterium: 200}, RessearchLabCost(1)) assert.Equal(t, Resources{Metal: 400, Crystal: 800, Deuterium: 400}, RessearchLabCost(2)) assert.Equal(t, Resources{Metal: 3276800, Crystal: 6553600, Deuterium: 3276800}, RessearchLabCost(15)) + + // alliancedepot + assert.Equal(t, Resources{Metal: 20000, Crystal: 40000}, AllianceDepotCost(1)) + assert.Equal(t, Resources{Metal: 40000, Crystal: 80000}, AllianceDepotCost(2)) + assert.Equal(t, Resources{Metal: 327680000, Crystal: 655360000}, AllianceDepotCost(15)) + + // missilesilo + assert.Equal(t, Resources{Metal: 20000, Crystal: 20000, Deuterium: 1000}, MissileSiloCost(1)) + assert.Equal(t, Resources{Metal: 40000, Crystal: 40000, Deuterium: 2000}, MissileSiloCost(2)) + assert.Equal(t, Resources{Metal: 327680000, Crystal: 327680000, Deuterium: 16384000}, MissileSiloCost(15)) + + // spacedock + assert.Equal(t, Resources{Metal: 20000, Crystal: 20000, Deuterium: 1000}, SpaceDockCost(1)) + assert.Equal(t, Resources{Metal: 40000, Crystal: 40000, Deuterium: 2000}, SpaceDockCost(2)) + assert.Equal(t, Resources{Metal: 327680000, Crystal: 327680000, Deuterium: 16384000}, SpaceDockCost(15)) }