mirror of
https://github.com/arnaucube/gogame.git
synced 2026-02-07 03:26:39 +01:00
add get planet data
This commit is contained in:
@@ -92,6 +92,15 @@ func (srv Service) PutPlanetInSolarSystem(position int64, planet *models.Planet)
|
||||
return &solarSystem, err
|
||||
}
|
||||
|
||||
func (srv Service) GetBuildings(user *models.User, planetid bson.ObjectId) (*models.Planet, error) {
|
||||
var planet models.Planet
|
||||
err := srv.db.Planets.Find(bson.M{"_id": planetid, "ownerid": user.Id}).One(&planet)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &planet, nil
|
||||
}
|
||||
|
||||
func (srv Service) UpgradeBuilding(user *models.User, planetid bson.ObjectId, building string) (*models.Planet, error) {
|
||||
// get planet
|
||||
var planet models.Planet
|
||||
|
||||
@@ -49,7 +49,10 @@ func (srv Service) Register(name, password, email string) (*models.User, error)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, _, err = srv.gamesrv.CreatePlanet(user.Id)
|
||||
_, planet, err := srv.gamesrv.CreatePlanet(user.Id)
|
||||
|
||||
user.Planets = append(user.Planets, planet.Id)
|
||||
user.StoreInDb()
|
||||
|
||||
return user, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user