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.

295 lines
8.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 FussionReactorCost(ilvl int64) Resources {
  121. lvl := float64(ilvl)
  122. base := Resources{
  123. Metal: 900,
  124. Crystal: 360,
  125. Deuterium: 180,
  126. Energy: 0,
  127. }
  128. // cost = base * 1.8^(lvl-1)
  129. cost := Resources{}
  130. cost.Metal = int64(float64(base.Metal) * math.Pow(1.8, lvl-1))
  131. cost.Crystal = int64(float64(base.Crystal) * math.Pow(1.8, lvl-1))
  132. cost.Deuterium = int64(float64(base.Deuterium) * math.Pow(1.8, lvl-1))
  133. cost.Energy = int64(float64(base.Energy) * math.Pow(1.8, lvl-1))
  134. return cost
  135. }
  136. func RoboticsFactoryCost(ilvl int64) Resources {
  137. lvl := float64(ilvl)
  138. base := Resources{
  139. Metal: 400,
  140. Crystal: 120,
  141. Deuterium: 200,
  142. Energy: 0,
  143. }
  144. // cost = base * 2^(lvl-1)
  145. cost := Resources{}
  146. cost.Metal = int64(float64(base.Metal) * math.Pow(2, lvl-1))
  147. cost.Crystal = int64(float64(base.Crystal) * math.Pow(2, lvl-1))
  148. cost.Deuterium = int64(float64(base.Deuterium) * math.Pow(2, lvl-1))
  149. cost.Energy = int64(float64(base.Energy) * math.Pow(2, lvl-1))
  150. return cost
  151. }
  152. func ShipyardCost(ilvl int64) Resources {
  153. lvl := float64(ilvl)
  154. base := Resources{
  155. Metal: 400,
  156. Crystal: 200,
  157. Deuterium: 100,
  158. Energy: 0,
  159. }
  160. // cost = base * 2^(lvl-1)
  161. cost := Resources{}
  162. cost.Metal = int64(float64(base.Metal) * math.Pow(2, lvl-1))
  163. cost.Crystal = int64(float64(base.Crystal) * math.Pow(2, lvl-1))
  164. cost.Deuterium = int64(float64(base.Deuterium) * math.Pow(2, lvl-1))
  165. cost.Energy = int64(float64(base.Energy) * math.Pow(2, lvl-1))
  166. return cost
  167. }
  168. func MetalStorageCost(ilvl int64) Resources {
  169. lvl := float64(ilvl)
  170. base := Resources{
  171. Metal: 1000,
  172. Crystal: 0,
  173. Deuterium: 0,
  174. Energy: 0,
  175. }
  176. // cost = base * 2^(lvl-1)
  177. cost := Resources{}
  178. cost.Metal = int64(float64(base.Metal) * math.Pow(2, lvl-1))
  179. cost.Crystal = 0
  180. cost.Deuterium = 0
  181. cost.Energy = 0
  182. return cost
  183. }
  184. func CrystalStorageCost(ilvl int64) Resources {
  185. lvl := float64(ilvl)
  186. base := Resources{
  187. Metal: 1000,
  188. Crystal: 500,
  189. Deuterium: 0,
  190. Energy: 0,
  191. }
  192. // cost = base * 2^(lvl-1)
  193. cost := Resources{}
  194. cost.Metal = int64(float64(base.Metal) * math.Pow(2, lvl-1))
  195. cost.Crystal = int64(float64(base.Crystal) * math.Pow(2, lvl-1))
  196. cost.Deuterium = 0
  197. cost.Energy = 0
  198. return cost
  199. }
  200. func DeuteriumStorageCost(ilvl int64) Resources {
  201. lvl := float64(ilvl)
  202. base := Resources{
  203. Metal: 1000,
  204. Crystal: 1000,
  205. Deuterium: 0,
  206. Energy: 0,
  207. }
  208. // cost = base * 2^(lvl-1)
  209. cost := Resources{}
  210. cost.Metal = int64(float64(base.Metal) * math.Pow(2, lvl-1))
  211. cost.Crystal = int64(float64(base.Crystal) * math.Pow(2, lvl-1))
  212. cost.Deuterium = int64(float64(base.Deuterium) * math.Pow(2, lvl-1))
  213. cost.Energy = int64(float64(base.Energy) * math.Pow(2, lvl-1))
  214. return cost
  215. }
  216. func RessearchLabCost(ilvl int64) Resources {
  217. lvl := float64(ilvl)
  218. base := Resources{
  219. Metal: 200,
  220. Crystal: 400,
  221. Deuterium: 200,
  222. Energy: 0,
  223. }
  224. // cost = base * 2^(lvl-1)
  225. cost := Resources{}
  226. cost.Metal = int64(float64(base.Metal) * math.Pow(2, lvl-1))
  227. cost.Crystal = int64(float64(base.Crystal) * math.Pow(2, lvl-1))
  228. cost.Deuterium = int64(float64(base.Deuterium) * math.Pow(2, lvl-1))
  229. cost.Energy = int64(float64(base.Energy) * math.Pow(2, lvl-1))
  230. return cost
  231. }
  232. func AllianceDepotCost(ilvl int64) Resources {
  233. lvl := float64(ilvl)
  234. base := Resources{
  235. Metal: 20000,
  236. Crystal: 40000,
  237. Deuterium: 0,
  238. Energy: 0,
  239. }
  240. // cost = base * 2^(lvl-1)
  241. cost := Resources{}
  242. cost.Metal = int64(float64(base.Metal) * math.Pow(2, lvl-1))
  243. cost.Crystal = int64(float64(base.Crystal) * math.Pow(2, lvl-1))
  244. cost.Deuterium = int64(float64(base.Deuterium) * math.Pow(2, lvl-1))
  245. cost.Energy = int64(float64(base.Energy) * math.Pow(2, lvl-1))
  246. return cost
  247. }
  248. func MissileSiloCost(ilvl int64) Resources {
  249. lvl := float64(ilvl)
  250. base := Resources{
  251. Metal: 20000,
  252. Crystal: 20000,
  253. Deuterium: 1000,
  254. Energy: 0,
  255. }
  256. // cost = base * 2^(lvl-1)
  257. cost := Resources{}
  258. cost.Metal = int64(float64(base.Metal) * math.Pow(2, lvl-1))
  259. cost.Crystal = int64(float64(base.Crystal) * math.Pow(2, lvl-1))
  260. cost.Deuterium = int64(float64(base.Deuterium) * math.Pow(2, lvl-1))
  261. cost.Energy = int64(float64(base.Energy) * math.Pow(2, lvl-1))
  262. return cost
  263. }
  264. func SpaceDockCost(ilvl int64) Resources {
  265. lvl := float64(ilvl)
  266. base := Resources{
  267. Metal: 20000,
  268. Crystal: 20000,
  269. Deuterium: 1000,
  270. Energy: 0,
  271. }
  272. // cost = base * 2^(lvl-1)
  273. cost := Resources{}
  274. cost.Metal = int64(float64(base.Metal) * math.Pow(2, lvl-1))
  275. cost.Crystal = int64(float64(base.Crystal) * math.Pow(2, lvl-1))
  276. cost.Deuterium = int64(float64(base.Deuterium) * math.Pow(2, lvl-1))
  277. cost.Energy = int64(float64(base.Energy) * math.Pow(2, lvl-1))
  278. return cost
  279. }