Use implicit cast of app/game structs

That will make the code a bit tidier.
This commit is contained in:
Sergey Stepanov 2023-07-10 13:27:25 +03:00
parent 7fe3a893f6
commit 49cb752b5c
No known key found for this signature in database
GPG key ID: A56B4929BAA8556B
5 changed files with 9 additions and 14 deletions

View file

@ -25,8 +25,8 @@ type (
PlayerIndex int `json:"player_index"`
}
GameInfo struct {
Name string `json:"name"`
Base string `json:"base"`
Name string `json:"name"`
Path string `json:"path"`
System string `json:"system"`
Type string `json:"type"`

View file

@ -23,7 +23,7 @@ func (w *Worker) StartGame(id com.Uid, app games.AppMeta, req api.GameStartUserR
return api.UnwrapChecked[api.StartGameResponse](
w.Send(api.StartGame, api.StartGameRequest[com.Uid]{
StatefulRoom: StateRoom(id, req.RoomId),
Game: api.GameInfo{Name: app.Name, Base: app.Base, Path: app.Path, System: app.System, Type: app.Type},
Game: api.GameInfo(app),
PlayerIndex: req.PlayerIndex,
Record: req.Record,
RecordUser: req.RecordUser,

View file

@ -14,11 +14,11 @@ type Launcher interface {
}
type AppMeta struct {
Name string
Type string
Base string
Name string
Path string
System string
Type string
}
type GameLauncher struct {

View file

@ -56,14 +56,11 @@ type WithEmulatorInfo interface {
}
type GameMetadata struct {
// the display name of the game
Name string
// the game file extension (e.g. nes, n64)
Type string
Base string
// the game path relative to the library base path
Path string
Base string
Name string // the display name of the game
Path string // the game path relative to the library base path
System string
Type string // the game file extension (e.g. nes, n64)
}
func (g GameMetadata) FullPath(base string) string {

View file

@ -81,9 +81,7 @@ func (c *coordinator) HandleGameStart(rq api.StartGameRequest[com.Uid], w *Worke
if room == nil {
room = NewRoom(
rq.Room.Rid,
games.GameMetadata{
Name: rq.Game.Name, Base: rq.Game.Base, Type: rq.Game.Type, Path: rq.Game.Path, System: rq.Game.System,
},
games.GameMetadata(rq.Game),
func(room *Room) {
w.router.SetRoom(nil)
c.CloseRoom(room.id)