1.4.0 • Published 10 months ago
@slk333/lib-ogame v1.4.0
Various functions and types related to the original Ogame browser game.
costs
mines and facilities
getStructureUpgradeCost("crystalMine", 9)
/* { metalAmount: 2061, crystalAmount: 1030, deuteriumAmount: 0 } */ships and defenses
getShipCost("lightFighter")
/* { metalAmount: 3000, crystalAmount: 1000, deuteriumAmount: 0 } */
getDefenseCost("rocketLauncher")
/* { metalAmount: 2000, crystalAmount: 0, deuteriumAmount: 0 } */construction time
mines and facilities
getStructureConstructionTime({
structureName: "researchLab",
level: 5,
roboticsFactory: 3,
naniteFactory: 0,
})
/* 2304 seconds*/ships and defenses
getShipConstructionTime({
shipName: "lightFighter",
shipyard: 5,
naniteFactory: 1,
})
/* 480 seconds*/
getDefenseConstructionTime({
defenseName: "rocketLauncher",
shipyard: 5,
naniteFactory: 1,
})
/* 240 seconds*/
// DEPRECATED: Use getShipConstructionTime or getDefenseConstructionTime instead
getShipyardUnitConstructionTime(
{ name: "lightFighter", type: "ship" },
5, // shipyardLevel
1 // naniteLevel
)
/* 480 seconds*/production
getMetalMineProduction_s(25)
/* 2.25694444 metal per second */
getCrystalMineProduction_s(25)
/* 1.50472222 crystal per second */
getDeuteriumProduction_s(25)
/* 1.08333333 deuterium per second */
/* fixed temperature: 0°C */derive data from planet
resources at date
computeResourcesForPlanetAtDate(planet, date)
/* { metalAmount: 51908, crystalAmount: 25767, deuteriumAmount: 10372 }
/* expects a Date */production
computeProductionForPlanet(planet)
/* { metalProduction_s: 0.5302, crystalProduction_s: 0.2133, deuteriumProduction_s: 0.1036 } */costs and durations
computeStructureUpgradeCostForPlanet(planet, "metalMine")
/* { metalAmount: 26273, crystalAmount: 6568, deuteriumAmount: 0 } */
computeStructureUpgradeTimeForPlanet(planet, "metalMine")
/* 1970 seconds */planet shape
export interface Planet {
id: string
name: string
owner: {
id: string
name: string
}
coordinates: Coordinates
structures: Record<StructureName, PlanetStructure>
ships: Record<ShipName, { name: ShipName; count: number }>
resources: ResourcesRecord
snapshotDate: string
pendingStructure: {
name: StructureName
completionDate: string
} | null
pendingShipyardUnit: {
shipyardUnit: ShipyardUnit
completionDate: string
} | null
structureQueue: StructureName[]
shipyardQueue: ScheduledShipyardOrder[]
}const samplePlanet: Planet = {
id: "planetAlpha",
name: "Alpha Centauri Bb",
owner: {
id: "player123",
name: "GalacticOverlord",
},
coordinates: { galaxy: 1, system: 100, position: 7, type: "planet" },
structures: {
metalMine: { name: "metalMine", level: 15 },
crystalMine: { name: "crystalMine", level: 12 },
deuteriumSynthesizer: { name: "deuteriumSynthesizer", level: 10 },
roboticsFactory: { name: "roboticsFactory", level: 5 },
shipyard: { name: "shipyard", level: 6 },
researchLab: { name: "researchLab", level: 7 },
naniteFactory: { name: "naniteFactory", level: 2 },
},
ships: {
lightFighter: { name: "lightFighter", count: 50 },
heavyFighter: { name: "heavyFighter", count: 0 },
cruiser: { name: "cruiser", count: 0 },
/* ... */
},
resources: { metalAmount: 50000, crystalAmount: 25000, deuteriumAmount: 10000 },
snapshotDate: new Date("2025-05-29T10:00:00.000Z").toISOString(),
pendingStructure: null,
pendingShipyardUnit: null,
structureQueue: [],
shipyardQueue: [],
}misc
Format resources
formatResourceAmount(1234567)
/* "1.2M" */1.2.0
10 months ago
1.0.1
10 months ago
1.0.0
10 months ago
1.4.0
10 months ago
0.5.0
1 year ago
0.7.0
12 months ago
0.4.20
1 year ago
1.1.0
10 months ago
0.4.21
1 year ago
1.3.0
10 months ago
0.4.19
1 year ago
0.4.17
1 year ago
0.4.18
1 year ago
0.4.15
1 year ago
0.4.16
1 year ago
0.6.3
1 year ago
0.8.0
10 months ago
0.6.2
1 year ago
0.6.5
1 year ago
0.6.4
1 year ago
0.6.1
1 year ago
0.6.0
1 year ago
0.4.9
2 years ago
0.4.8
2 years ago
0.4.10
2 years ago
0.4.13
2 years ago
0.4.14
2 years ago
0.4.11
2 years ago
0.4.12
2 years ago
0.3.0
2 years ago
0.2.1
2 years ago
0.2.0
2 years ago
0.4.5
2 years ago
0.4.4
2 years ago
0.4.7
2 years ago
0.4.6
2 years ago
0.4.1
2 years ago
0.2.3
2 years ago
0.4.0
2 years ago
0.3.1
2 years ago
0.2.2
2 years ago
0.4.3
2 years ago
0.4.2
2 years ago
0.1.4
3 years ago
0.1.3
3 years ago
0.1.6
3 years ago
0.1.5
3 years ago
0.1.2
3 years ago
0.1.1
3 years ago
0.1.0
3 years ago