Browse Source

all buildings working

master
arnaucube 5 years ago
parent
commit
c32ae80b68
2 changed files with 21 additions and 13 deletions
  1. +18
    -0
      models/user.go
  2. +3
    -13
      services/usersrv/usersrv.go

+ 18
- 0
models/user.go

@ -181,8 +181,26 @@ func (u *User) GetBuildingCost(planet Planet, building string) (Resources, error
return DeuteriumMineCost(planet.Buildings["deuteriummine"] + 1), nil return DeuteriumMineCost(planet.Buildings["deuteriummine"] + 1), nil
case "energymine": case "energymine":
return EnergyMineCost(planet.Buildings["energymine"] + 1), nil return EnergyMineCost(planet.Buildings["energymine"] + 1), nil
case "fusionreactor":
return FussionReactorCost(planet.Buildings["fusionreactor"] + 1), nil
case "roboticsfactory":
return RoboticsFactoryCost(planet.Buildings["roboticsfactory"] + 1), nil
case "shipyard":
return ShipyardCost(planet.Buildings["shipyard"] + 1), nil
case "metalstorage":
return MetalStorageCost(planet.Buildings["metalstorage"] + 1), nil
case "crystalstorage":
return CrystalStorageCost(planet.Buildings["crystalstorage"] + 1), nil
case "deuteriumstorage":
return DeuteriumStorageCost(planet.Buildings["deuteriumstorage"] + 1), nil
case "ressearchlab": case "ressearchlab":
return RessearchLabCost(planet.Buildings["ressearchlab"] + 1), nil return RessearchLabCost(planet.Buildings["ressearchlab"] + 1), nil
case "alliancedepot":
return AllianceDepotCost(planet.Buildings["alliancedepot"] + 1), nil
case "missilesilo":
return MissileSiloCost(planet.Buildings["missilesilo"] + 1), nil
case "spacedock":
return SpaceDockCost(planet.Buildings["spacedock"] + 1), nil
default: default:
return Resources{}, errors.New("building not found") return Resources{}, errors.New("building not found")
} }

+ 3
- 13
services/usersrv/usersrv.go

@ -91,7 +91,9 @@ func (srv Service) GetUserById(userid bson.ObjectId) (*models.User, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
return models.UserDbToUser(srv.db, userDb), nil
user := models.UserDbToUser(srv.db, userDb)
_, err = user.GetResources()
return user, err
} }
func (srv Service) GetUserPlanetsById(userid bson.ObjectId) ([]*models.Planet, error) { func (srv Service) GetUserPlanetsById(userid bson.ObjectId) ([]*models.Planet, error) {
@ -102,15 +104,3 @@ func (srv Service) GetUserPlanetsById(userid bson.ObjectId) ([]*models.Planet, e
} }
return planets, err return planets, err
} }
// func (srv Service) GetUser(id bson.ObjectId) (*models.User, error) {
// // update user stats
// user := getUserFromDB
// user.GetStats()
//
// }
//
// func (srv Service) GetUser(id bson.ObjectId) (*models.User, error) {
// // update user stats
//
// }

Loading…
Cancel
Save