You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
5.0 KiB

  1. package models
  2. import (
  3. "testing"
  4. "github.com/arnaucube/gogame/constants"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func TestGrowth(t *testing.T) {
  8. // metal
  9. assert.Equal(t, int64(33), MetalGrowth(1, 60)/constants.MineVelocity)
  10. assert.Equal(t, int64(66), MetalGrowth(1, 120)/constants.MineVelocity)
  11. assert.Equal(t, int64(72), MetalGrowth(2, 60)/constants.MineVelocity)
  12. // crystal
  13. assert.Equal(t, int64(22), CrystalGrowth(1, 60)/constants.MineVelocity)
  14. assert.Equal(t, int64(44), CrystalGrowth(1, 120)/constants.MineVelocity)
  15. assert.Equal(t, int64(48), CrystalGrowth(2, 60)/constants.MineVelocity)
  16. // deuterium
  17. assert.Equal(t, int64(8), DeuteriumGrowth(1, 60)/constants.MineVelocity)
  18. assert.Equal(t, int64(17), DeuteriumGrowth(1, 120)/constants.MineVelocity)
  19. assert.Equal(t, int64(19), DeuteriumGrowth(2, 60)/constants.MineVelocity)
  20. // solar
  21. assert.Equal(t, int64(22), SolarGrowth(1, 60)/constants.MineVelocity)
  22. assert.Equal(t, int64(44), SolarGrowth(1, 120)/constants.MineVelocity)
  23. assert.Equal(t, int64(48), SolarGrowth(2, 60)/constants.MineVelocity)
  24. // fusion
  25. assert.Equal(t, int64(31), FusionGrowth(1, 1, 60)/constants.MineVelocity)
  26. assert.Equal(t, int64(63), FusionGrowth(1, 1, 120)/constants.MineVelocity)
  27. assert.Equal(t, int64(34), FusionGrowth(2, 2, 60)/constants.MineVelocity)
  28. }
  29. func TestMineCost(t *testing.T) {
  30. // metalmine
  31. assert.Equal(t, Resources{Metal: 60, Crystal: 15}, MetalMineCost(1))
  32. assert.Equal(t, Resources{Metal: 90, Crystal: 22}, MetalMineCost(2))
  33. assert.Equal(t, Resources{Metal: 17515, Crystal: 4378}, MetalMineCost(15))
  34. // crystalmine
  35. assert.Equal(t, Resources{Metal: 48, Crystal: 24}, CrystalMineCost(1))
  36. assert.Equal(t, Resources{Metal: 76, Crystal: 38}, CrystalMineCost(2))
  37. assert.Equal(t, Resources{Metal: 34587, Crystal: 17293}, CrystalMineCost(15))
  38. // deuteriummine
  39. assert.Equal(t, Resources{Metal: 225, Crystal: 75}, DeuteriumMineCost(1))
  40. assert.Equal(t, Resources{Metal: 337, Crystal: 112}, DeuteriumMineCost(2))
  41. assert.Equal(t, Resources{Metal: 65684, Crystal: 21894}, DeuteriumMineCost(15))
  42. // energymine
  43. assert.Equal(t, Resources{Metal: 75, Crystal: 30}, EnergyMineCost(1))
  44. assert.Equal(t, Resources{Metal: 112, Crystal: 45}, EnergyMineCost(2))
  45. assert.Equal(t, Resources{Metal: 21894, Crystal: 8757}, EnergyMineCost(15))
  46. // FussionReactorCost
  47. assert.Equal(t, Resources{Metal: 900, Crystal: 360, Deuterium: 180}, FussionReactorCost(1))
  48. assert.Equal(t, Resources{Metal: 1620, Crystal: 648, Deuterium: 324}, FussionReactorCost(2))
  49. assert.Equal(t, Resources{Metal: 3373320, Crystal: 1349328, Deuterium: 674664}, FussionReactorCost(15))
  50. // roboticsfactory
  51. assert.Equal(t, Resources{Metal: 400, Crystal: 120, Deuterium: 200}, RoboticsFactoryCost(1))
  52. assert.Equal(t, Resources{Metal: 800, Crystal: 240, Deuterium: 400}, RoboticsFactoryCost(2))
  53. assert.Equal(t, Resources{Metal: 6553600, Crystal: 1966080, Deuterium: 3276800}, RoboticsFactoryCost(15))
  54. // shipyard
  55. assert.Equal(t, Resources{Metal: 400, Crystal: 200, Deuterium: 100}, ShipyardCost(1))
  56. assert.Equal(t, Resources{Metal: 800, Crystal: 400, Deuterium: 200}, ShipyardCost(2))
  57. assert.Equal(t, Resources{Metal: 6553600, Crystal: 3276800, Deuterium: 1638400}, ShipyardCost(15))
  58. // metalstorage
  59. assert.Equal(t, Resources{Metal: 1000}, MetalStorageCost(1))
  60. assert.Equal(t, Resources{Metal: 2000}, MetalStorageCost(2))
  61. assert.Equal(t, Resources{Metal: 16384000}, MetalStorageCost(15))
  62. // crystalstorage
  63. assert.Equal(t, Resources{Metal: 1000, Crystal: 500}, CrystalStorageCost(1))
  64. assert.Equal(t, Resources{Metal: 2000, Crystal: 1000}, CrystalStorageCost(2))
  65. assert.Equal(t, Resources{Metal: 16384000, Crystal: 8192000}, CrystalStorageCost(15))
  66. // deuteriumstorage
  67. assert.Equal(t, Resources{Metal: 1000, Crystal: 1000}, DeuteriumStorageCost(1))
  68. assert.Equal(t, Resources{Metal: 2000, Crystal: 2000}, DeuteriumStorageCost(2))
  69. assert.Equal(t, Resources{Metal: 16384000, Crystal: 16384000}, DeuteriumStorageCost(15))
  70. // researchlab
  71. assert.Equal(t, Resources{Metal: 200, Crystal: 400, Deuterium: 200}, RessearchLabCost(1))
  72. assert.Equal(t, Resources{Metal: 400, Crystal: 800, Deuterium: 400}, RessearchLabCost(2))
  73. assert.Equal(t, Resources{Metal: 3276800, Crystal: 6553600, Deuterium: 3276800}, RessearchLabCost(15))
  74. // alliancedepot
  75. assert.Equal(t, Resources{Metal: 20000, Crystal: 40000}, AllianceDepotCost(1))
  76. assert.Equal(t, Resources{Metal: 40000, Crystal: 80000}, AllianceDepotCost(2))
  77. assert.Equal(t, Resources{Metal: 327680000, Crystal: 655360000}, AllianceDepotCost(15))
  78. // missilesilo
  79. assert.Equal(t, Resources{Metal: 20000, Crystal: 20000, Deuterium: 1000}, MissileSiloCost(1))
  80. assert.Equal(t, Resources{Metal: 40000, Crystal: 40000, Deuterium: 2000}, MissileSiloCost(2))
  81. assert.Equal(t, Resources{Metal: 327680000, Crystal: 327680000, Deuterium: 16384000}, MissileSiloCost(15))
  82. // spacedock
  83. assert.Equal(t, Resources{Metal: 20000, Crystal: 20000, Deuterium: 1000}, SpaceDockCost(1))
  84. assert.Equal(t, Resources{Metal: 40000, Crystal: 40000, Deuterium: 2000}, SpaceDockCost(2))
  85. assert.Equal(t, Resources{Metal: 327680000, Crystal: 327680000, Deuterium: 16384000}, SpaceDockCost(15))
  86. }