mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-01-23 10:35:44 +00:00
Use implicit cast of app/game structs
That will make the code a bit tidier.
This commit is contained in:
parent
7fe3a893f6
commit
49cb752b5c
5 changed files with 9 additions and 14 deletions
|
|
@ -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"`
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue