Skip to content

Commit

Permalink
fix: adjust api change
Browse files Browse the repository at this point in the history
  • Loading branch information
xjasonlyu committed Dec 6, 2023
1 parent 600477d commit efb3a4a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
3 changes: 1 addition & 2 deletions game-service/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

type startQuery struct {
Username string `form:"username" binding:"required"`
Zone string `form:"zone"`
Location dto.PointDTO `form:"location"`
}

Expand Down Expand Up @@ -39,7 +38,7 @@ func handleGameStart(app *game.App) gin.HandlerFunc {
return
}

if err := app.StartGame(player, query.Zone, query.Location); err != nil {
if err := app.StartGame(player, query.Location); err != nil {
abortWithStatusMessage(c, http.StatusInternalServerError, err)
return
}
Expand Down
5 changes: 0 additions & 5 deletions game-service/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ const (
HRMSendAction = "SEND_HEART_RATE"
)

var AllowedZones = map[string]any{
"MAC": nil,
"MCMASTER": nil,
}

const (
ReactSheltering = "SHELTERING"
ReactEscaping = "ESCAPING"
Expand Down
8 changes: 2 additions & 6 deletions game-service/game/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ import (
"game-service/message"
)

func (app *App) StartGame(player *dto.PlayerDTO, zone string, location dto.PointDTO) error {

if _, ok := consts.AllowedZones[strings.ToUpper(zone)]; !ok {
return fmt.Errorf("zone is not allowed: %s", zone)
}
func (app *App) StartGame(player *dto.PlayerDTO, location dto.PointDTO) error {

ctx := &context.Context{
Player: player,
Expand Down Expand Up @@ -49,7 +45,7 @@ func (app *App) StartGame(player *dto.PlayerDTO, zone string, location dto.Point
}
}
}{}
if err := app.GetService("geo-service", fmt.Sprintf("/geo/trail?zone=%s", strings.ToLower(zone)), &data); err != nil {
if err := app.GetService("geo-service", fmt.Sprintf("/geo/trail?username=%s", strings.ToLower(player.Username)), &data); err != nil {
return fmt.Errorf("get init trail failed: %v", err)
}

Expand Down

0 comments on commit efb3a4a

Please sign in to comment.