arnaucube
arnaucube/gogame-oldPublic Self-hosted repository
add construction & research time calculations
arnaucube arnaucube@gmail.com
Sun, 16 Jun 2019 11:11:51 +0200
commit

bf1c564a45483e480f611a0b4c7d46e45941ffba

parent

c32ae80b68d6456ecc67a4df3a607a821d3a82c2

4 files changed, 61 insertions(+), 13 deletions(-)

jump to
M README.md → README.md

@@ -5,3 +5,28 @@

WIP The frontend is in https://github.com/arnaucube/gogame-frontend + + + +- [x] queue system +- [x] server api +- [ ] log system (console print and file save) +- [x] register/login +- [ ] data models + - [x] user + - [x] planet + - [x] galaxy + - [ ] ships +- [x] mongodb connectors +- [x] buildings engine +- [x] resources engine +- [ ] costs calculators + - [x] mining growth from mines/buildings + - [x] building costs + - [x] building time + - [x] research time + - [ ] energy costs + - [ ] ships costs + - [ ] ships building time + - [ ] ships travel time +- [ ] battle engine
M models/calc.go → models/calc.go

@@ -293,3 +293,17 @@ cost.Deuterium = int64(float64(base.Deuterium) * math.Pow(2, lvl-1))

cost.Energy = int64(float64(base.Energy) * math.Pow(2, lvl-1)) return cost } + +// TODO ConstructionTime and ResearchTime are following the formulas from https://ogame.fandom.com/wiki/Formulas +// but are not giving exact same numbers than in online calculators +func ConstructionTime(r Resources, roboticsLvl int64) int64 { + naniteLvl := float64(1) + // T(h) = (metal + crystal) / (2500 * (1+roboticsLvl) * 2^naniteLvl * universespeed) + tHours := float64(r.Metal+r.Crystal) / (float64(2500) * float64(1+roboticsLvl) * math.Pow(2, naniteLvl) * constants.UniverseAcceleration) + return int64(tHours * 3600) +} +func RessearchTime(r Resources, researchLvl int64) int64 { + // T(h) = (metal + crystal) / (1000 * (1+researchLvl * universespeed) + tHours := float64(r.Metal+r.Crystal) / (float64(1000) * float64(1+researchLvl*constants.UniverseAcceleration)) + return int64(tHours * 3600) +}
M models/calc_test.go → models/calc_test.go

@@ -105,3 +105,25 @@ 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)) } + +func TestConstructionTime(t *testing.T) { + // Numbers of the online calculators + // assert.Equal(t, int64(30), ConstructionTime(Resources{Metal: 60, Crystal: 15}, 1)) + // assert.Equal(t, int64(53), ConstructionTime(Resources{Metal: 90, Crystal: 22}, 1)) + // assert.Equal(t, int64(96), ConstructionTime(Resources{Metal: 135, Crystal: 33}, 1)) + // assert.Equal(t, int64(383340), ConstructionTime(Resources{Metal: 204800, Crystal: 61440}, 10)) + + // Numbers following the formulas + assert.Equal(t, int64(27), ConstructionTime(Resources{Metal: 60, Crystal: 15}, 1)) + assert.Equal(t, int64(40), ConstructionTime(Resources{Metal: 90, Crystal: 22}, 1)) + assert.Equal(t, int64(60), ConstructionTime(Resources{Metal: 135, Crystal: 33}, 1)) + assert.Equal(t, int64(17426), ConstructionTime(Resources{Metal: 204800, Crystal: 61440}, 10)) +} +func TestRessearchTime(t *testing.T) { + assert.Equal(t, int64(1440), RessearchTime(Resources{Metal: 0, Crystal: 800}, 1)) + assert.Equal(t, int64(5236), RessearchTime(Resources{Metal: 12800, Crystal: 3200}, 10)) + + // Numbers of the online calculators + // assert.Equal(t, int64(2880), RessearchTime(Resources{Metal: 12800, Crystal: 6400}, 15)) + // assert.Equal(t, int64(360), RessearchTime(Resources{Metal: 1600, Crystal: 800}, 15)) +}
D parts.md

@@ -1,13 +0,0 @@

-- queue system -- server api -- register/login -- data models - - user - - planet - - ships - - galaxy -- mongodb connectors -- planet engine -- building engine -- battle engine -- log system (console print and file save)