add get planet data

This commit is contained in:
arnaucube
2019-06-15 21:04:46 +02:00
parent 513836c4c7
commit 3bac070c04
5 changed files with 43 additions and 8 deletions

View File

@@ -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

View File

@@ -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
}