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.

62 lines
2.5 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. // researchlab
  47. assert.Equal(t, Resources{Metal: 200, Crystal: 400, Deuterium: 200}, RessearchLabCost(1))
  48. assert.Equal(t, Resources{Metal: 400, Crystal: 800, Deuterium: 400}, RessearchLabCost(2))
  49. assert.Equal(t, Resources{Metal: 3276800, Crystal: 6553600, Deuterium: 3276800}, RessearchLabCost(15))
  50. }