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.

150 lines
4.3 KiB

  1. package models
  2. import (
  3. "math"
  4. "github.com/arnaucube/gogame/constants"
  5. )
  6. // formulas
  7. // https://ogame.fandom.com/wiki/Formulas
  8. // https://ogame.fandom.com/wiki/Research
  9. // idelta is time in seconds units
  10. func MetalGrowth(ilvl int64, idelta int64) int64 {
  11. lvl := float64(ilvl)
  12. delta := float64(idelta)
  13. // 30 * L * 1.1^L
  14. perHour := constants.UniverseAcceleration * 30 * lvl * math.Pow(1.1, lvl)
  15. r := (perHour / 60) * delta * constants.MineVelocity
  16. return int64(r)
  17. }
  18. func CrystalGrowth(ilvl int64, idelta int64) int64 {
  19. lvl := float64(ilvl)
  20. delta := float64(idelta)
  21. // 20 * L * 1.1^L
  22. perHour := constants.UniverseAcceleration * 20 * lvl * math.Pow(1.1, lvl)
  23. r := (perHour / 60) * delta * constants.MineVelocity
  24. return int64(r)
  25. }
  26. func DeuteriumGrowth(ilvl int64, idelta int64) int64 {
  27. lvl := float64(ilvl)
  28. delta := float64(idelta)
  29. t := float64(240) // t: max temperature
  30. // 10 * L * 1.1^L * (−0.002 * T + 1.28))
  31. perHour := constants.UniverseAcceleration * 10 * lvl * math.Pow(1.1, lvl) * ((-0.002)*t + 1.28)
  32. r := (perHour / 60) * delta * constants.MineVelocity
  33. return int64(r)
  34. }
  35. func SolarGrowth(ilvl int64, idelta int64) int64 {
  36. lvl := float64(ilvl)
  37. delta := float64(idelta)
  38. // 20 * L * 1.1^L
  39. perHour := constants.UniverseAcceleration * 20 * lvl * math.Pow(1.1, lvl)
  40. r := (perHour / 60) * delta * constants.MineVelocity
  41. return int64(r)
  42. }
  43. func FusionGrowth(ilvl int64, ilvlTech int64, idelta int64) int64 {
  44. lvl := float64(ilvl)
  45. lvlTech := float64(ilvlTech)
  46. delta := float64(idelta)
  47. // 30 * L * (1.05 + lvlTech * 0.01)^lvl
  48. perHour := constants.UniverseAcceleration * 30 * math.Pow((1.05+lvlTech*0.01), lvl)
  49. r := (perHour / 60) * delta * constants.MineVelocity
  50. return int64(r)
  51. }
  52. // https://ogame.fandom.com/wiki/Buildings
  53. // https://ogame.fandom.com/wiki/Metal_Mine
  54. func MetalMineCost(ilvl int64) Resources {
  55. lvl := float64(ilvl)
  56. base := Resources{
  57. Metal: 60,
  58. Crystal: 15,
  59. Deuterium: 0,
  60. Energy: 0,
  61. }
  62. // cost = base * 1.5^(lvl-1)
  63. cost := Resources{}
  64. cost.Metal = int64(float64(base.Metal) * math.Pow(1.5, lvl-1))
  65. cost.Crystal = int64(float64(base.Crystal) * math.Pow(1.5, lvl-1))
  66. cost.Deuterium = int64(float64(base.Deuterium) * math.Pow(1.5, lvl-1))
  67. cost.Energy = int64(float64(base.Energy) * math.Pow(1.5, lvl-1))
  68. return cost
  69. }
  70. // https://ogame.fandom.com/wiki/Crystal_Mine
  71. func CrystalMineCost(ilvl int64) Resources {
  72. lvl := float64(ilvl)
  73. base := Resources{
  74. Metal: 48,
  75. Crystal: 24,
  76. Deuterium: 0,
  77. Energy: 0,
  78. }
  79. // cost = base * 1.6^(lvl-1)
  80. cost := Resources{}
  81. cost.Metal = int64(float64(base.Metal) * math.Pow(1.6, lvl-1))
  82. cost.Crystal = int64(float64(base.Crystal) * math.Pow(1.6, lvl-1))
  83. cost.Deuterium = int64(float64(base.Deuterium) * math.Pow(1.6, lvl-1))
  84. cost.Energy = int64(float64(base.Energy) * math.Pow(1.6, lvl-1))
  85. return cost
  86. }
  87. // https://ogame.fandom.com/wiki/Deuterium_Synthesizer
  88. func DeuteriumMineCost(ilvl int64) Resources {
  89. lvl := float64(ilvl)
  90. base := Resources{
  91. Metal: 225,
  92. Crystal: 75,
  93. Deuterium: 0,
  94. Energy: 0,
  95. }
  96. // cost = base * 1.5^(lvl-1)
  97. cost := Resources{}
  98. cost.Metal = int64(float64(base.Metal) * math.Pow(1.5, lvl-1))
  99. cost.Crystal = int64(float64(base.Crystal) * math.Pow(1.5, lvl-1))
  100. cost.Deuterium = int64(float64(base.Deuterium) * math.Pow(1.5, lvl-1))
  101. cost.Energy = int64(float64(base.Energy) * math.Pow(1.5, lvl-1))
  102. return cost
  103. }
  104. func EnergyMineCost(ilvl int64) Resources {
  105. lvl := float64(ilvl)
  106. base := Resources{
  107. Metal: 75,
  108. Crystal: 30,
  109. Deuterium: 0,
  110. Energy: 0,
  111. }
  112. // cost = base * 1.5^(lvl-1)
  113. cost := Resources{}
  114. cost.Metal = int64(float64(base.Metal) * math.Pow(1.5, lvl-1))
  115. cost.Crystal = int64(float64(base.Crystal) * math.Pow(1.5, lvl-1))
  116. cost.Deuterium = int64(float64(base.Deuterium) * math.Pow(1.5, lvl-1))
  117. cost.Energy = int64(float64(base.Energy) * math.Pow(1.5, lvl-1))
  118. return cost
  119. }
  120. func RessearchLabCost(ilvl int64) Resources {
  121. lvl := float64(ilvl)
  122. base := Resources{
  123. Metal: 200,
  124. Crystal: 400,
  125. Deuterium: 200,
  126. Energy: 0,
  127. }
  128. // cost = base * 1.5^(lvl-1)
  129. cost := Resources{}
  130. cost.Metal = int64(float64(base.Metal) * math.Pow(2, lvl-1))
  131. cost.Crystal = int64(float64(base.Crystal) * math.Pow(2, lvl-1))
  132. cost.Deuterium = int64(float64(base.Deuterium) * math.Pow(2, lvl-1))
  133. cost.Energy = int64(float64(base.Energy) * math.Pow(2, lvl-1))
  134. return cost
  135. }