Skip to content

Commit

Permalink
Merge branch 'main' of github.com:CAS735-F23/macrun-archless-team int…
Browse files Browse the repository at this point in the history
…o main
  • Loading branch information
leonliu288 committed Dec 5, 2023
2 parents 4d4f032 + 1353778 commit d26ded4
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ python3 ./simulator.py 127.0.0.1:8080

We automate the testing of our services using GitHub Actions (CI/CD). You can view the test results at:

- <https://github.com/CAS735-F23/macrun-archless-team/actions/workflows/test.yml>.
- <https://github.com/CAS735-F23/macrun-archless-team/actions/workflows/test.yml>

### Manual Test

Expand Down
11 changes: 6 additions & 5 deletions api-gateway/Caddyfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
http://:8080 {
reverse_proxy /hrm/* http://hrm:9500
reverse_proxy /player/* http://player:9000
reverse_proxy /game/* http://game:9090
reverse_proxy /challenge/* http://challenge:9001
reverse_proxy /geo/* http://geo:9002
reverse_proxy /hrm* http://hrm:9500
reverse_proxy /player* http://player:9000
reverse_proxy /game* http://game:9090
reverse_proxy /challenge* http://challenge:9001
reverse_proxy /badge* http://challenge:9001
reverse_proxy /geo* http://geo:9002
}
7 changes: 5 additions & 2 deletions game-service/api/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"log"
"time"

"github.com/gin-gonic/gin"
Expand All @@ -21,13 +22,15 @@ func getPlayerDTOBySessionID(sessionID, username string) (*dto.PlayerDTO, error)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

log.Printf("GET Session from `%s` for `%s`", sessionID, username)

cmd := _cache.HGet(ctx,
fmt.Sprintf("spring:session:sessions:%s", sessionID),
fmt.Sprintf("sessionAttr:PLAYER_SESSION%s", username))
fmt.Sprintf("sessionAttr:PLAYER_SESSION_%s", username))

data, err := cmd.Bytes()
if err != nil {
return nil, err
return nil, fmt.Errorf("redis cmd returned error: %s", err)
}

res, err := jserial.ParseSerializedObjectMinimal(data)
Expand Down
2 changes: 1 addition & 1 deletion game-service/game/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (app *App) ProcessGameAction(player *dto.PlayerDTO, action, cType string, l
}
}{}
if err := app.GetService("challenge-service",
fmt.Sprintf("/challenge/management?userHeartRate=%d&type=%s", ctx.GetHeartRate(), cType), &data); err != nil {
fmt.Sprintf("/challenge?userHeartRate=%d&type=%s", ctx.GetHeartRate(), cType), &data); err != nil {
//return nil, fmt.Errorf("get init challenge failed: %v", err)

data.Data.UserHeartRate = ((100-player.Age)/2 + player.Weight) + rand.Intn(40) - 20
Expand Down
4 changes: 0 additions & 4 deletions game-service/game/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,3 @@ func (app *App) GetService(service, path string, v any) error {

return json.NewDecoder(res.Body).Decode(v)
}

func (app *App) PostService(service, path string, body any) {

}
10 changes: 8 additions & 2 deletions simulator-script/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ def simulate(base: str):
}) as r:
print(f'>>> Starting game in Zone: MAC ({x}, {y})')
pprint(data := r.json())
shelters = data['data']['shelters']
try:
shelters = data['data']['shelters']
except KeyError:
shelters = []
time.sleep(1)

for i in range(10):
Expand Down Expand Up @@ -104,4 +107,7 @@ def main():


if __name__ == '__main__':
main()
try:
main()
except KeyboardInterrupt:
exit(0)

0 comments on commit d26ded4

Please sign in to comment.