models

package
v0.0.0-...-fc44d3c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2019 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPoints

func AddPoints(db *database.Db, userId bson.ObjectId, points int64) error

func ConstructionTime

func ConstructionTime(r Resources, roboticsLvl int64) int64

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 CrystalGrowth

func CrystalGrowth(ilvl int64, idelta int64) int64

func CrystalMineEnergyConsumption

func CrystalMineEnergyConsumption(ilvl int64) int64

func DeuteriumGrowth

func DeuteriumGrowth(ilvl int64, idelta int64) int64

func DeuteriumMineEnergyConsumption

func DeuteriumMineEnergyConsumption(ilvl int64) int64

func FusionGrowth

func FusionGrowth(ilvl int64, ilvlTech int64, idelta int64) int64

func MetalGrowth

func MetalGrowth(ilvl int64, idelta int64) int64

idelta is time in seconds units

func MetalMineEnergyConsumption

func MetalMineEnergyConsumption(ilvl int64) int64

func ResourcesToPoints

func ResourcesToPoints(r Resources) int64

func RessearchTime

func RessearchTime(r Resources, researchLvl int64) int64

func SolarGrowth

func SolarGrowth(ilvl int64) int64

Types

type Planet

type Planet struct {
	Db           *database.Db
	Id           bson.ObjectId `json:"id" bson:"_id,omitempty"`
	LastUpdated  time.Time
	Size         int64 // fields/slots
	Name         string
	OwnerId      bson.ObjectId
	Resources    Resources
	Buildings    map[string]int64
	CurrentBuild Process
	Research     Process
}

func NewPlanet

func NewPlanet(db *database.Db, size int64, name string, ownerId bson.ObjectId) (*Planet, error)

func (*Planet) CheckCurrentBuild

func (p *Planet) CheckCurrentBuild() (bool, error)

CheckCurrentBuild checks if the planet has a ongoing building in process, and if has finished in case that has finished, updates it in db

func (*Planet) GetBuildingCost

func (p *Planet) GetBuildingCost(building string) (Resources, error)

func (*Planet) GetFromDb

func (p *Planet) GetFromDb() error

func (*Planet) GetResources

func (p *Planet) GetResources() (*Resources, error)

GetResources updates the values of resources and returns the value, also updates the user.Resources Resource types: metal, crystal, deuterium, energy

func (*Planet) SpendResources

func (p *Planet) SpendResources(r Resources) error

SpendResources checks if user has enough resources, then substracts the resources, and updates the amounts in the database

func (*Planet) StoreInDb

func (p *Planet) StoreInDb() error

func (*Planet) UpgradeBuilding

func (p *Planet) UpgradeBuilding(building string) error

type Process

type Process struct {
	// if Title == "", is not active, and can build other buildings/research
	Title     string // building name / research name + level
	Building  string
	Ends      time.Time
	CountDown int64
}

type Resources

type Resources struct {
	Metal     int64
	Crystal   int64
	Deuterium int64
	Energy    int64
}

func AllianceDepotCost

func AllianceDepotCost(ilvl int64) Resources

func CrystalStorageCost

func CrystalStorageCost(ilvl int64) Resources

func DeuteriumStorageCost

func DeuteriumStorageCost(ilvl int64) Resources

func EnergyMineCost

func EnergyMineCost(ilvl int64) Resources

func FussionReactorCost

func FussionReactorCost(ilvl int64) Resources

func MetalStorageCost

func MetalStorageCost(ilvl int64) Resources

func MissileSiloCost

func MissileSiloCost(ilvl int64) Resources

func RessearchLabCost

func RessearchLabCost(ilvl int64) Resources

func RoboticsFactoryCost

func RoboticsFactoryCost(ilvl int64) Resources

func ShipyardCost

func ShipyardCost(ilvl int64) Resources

func SpaceDockCost

func SpaceDockCost(ilvl int64) Resources

type SolarSystem

type SolarSystem struct {
	Id       bson.ObjectId `json:"id" bson:"_id,omitempty"`
	Position int64         // position of the solar system in the galaxy, the maximum position is GALAXYSIZE-1
	Planets  []string      // array with ids of the planets, if empty is equal to ""
}

type User

type User struct {
	Id          bson.ObjectId `json:"id" bson:"_id,omitempty"`
	Name        string
	LastUpdated time.Time
	Planets     []bson.ObjectId
	Points      int64
	// contains filtered or unexported fields
}

User is the data in memory, after getting it from DB

func NewUser

func NewUser(db *database.Db, name, password, email string) (*User, error)

func UserDbToUser

func UserDbToUser(db *database.Db, u UserDb) *User

func (*User) GetFromDb

func (u *User) GetFromDb() error

func (*User) GetPlanets

func (u *User) GetPlanets() ([]Planet, error)

func (*User) StoreInDb

func (u *User) StoreInDb() error

type UserDb

type UserDb struct {
	Id          bson.ObjectId `json:"id" bson:"_id,omitempty"`
	Name        string
	Password    string
	Email       string
	LastUpdated time.Time
	Planets     []bson.ObjectId
	Points      int64 // real points are this value / 1000
}

UserDb is the data in DB

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL