diff --git a/game/builtin/doc.go b/game/builtin/doc.go deleted file mode 100644 index 84e833b..0000000 --- a/game/builtin/doc.go +++ /dev/null @@ -1,2 +0,0 @@ -// Package builtin 包含了通用游戏相关的接口的内置实现 -package builtin diff --git a/game/builtin/player.go b/game/builtin/player.go deleted file mode 100644 index 5013174..0000000 --- a/game/builtin/player.go +++ /dev/null @@ -1,44 +0,0 @@ -package builtin - -import "github.com/kercylan98/minotaur/server" - -func NewPlayer[ID comparable](id ID, conn *server.Conn) *Player[ID] { - return &Player[ID]{ - id: id, - conn: conn, - } -} - -// Player 游戏玩家 -type Player[ID comparable] struct { - id ID - conn *server.Conn -} - -func (slf *Player[ID]) GetID() ID { - return slf.id -} - -func (slf *Player[ID]) GetConn() *server.Conn { - return slf.conn -} - -func (slf *Player[ID]) UseConn(conn *server.Conn) { - if conn == nil { - return - } - if slf.conn != nil { - slf.conn.Close() - } - slf.conn = conn -} - -// Send 向该玩家发送数据 -func (slf *Player[ID]) Send(packet []byte, callback ...func(err error)) { - slf.conn.Write(packet, callback...) -} - -// Close 关闭玩家 -func (slf *Player[ID]) Close(err ...error) { - slf.conn.Close(err...) -} diff --git a/game/player.go b/game/player.go deleted file mode 100644 index b069374..0000000 --- a/game/player.go +++ /dev/null @@ -1,15 +0,0 @@ -package game - -import "github.com/kercylan98/minotaur/server" - -// Player 玩家 -type Player[ID comparable] interface { - // GetID 获取玩家ID - GetID() ID - // GetConn 获取玩家连接 - GetConn() *server.Conn - // UseConn 指定连接 - UseConn(conn *server.Conn) - // Close 关闭玩家并且释放其资源 - Close(err ...error) -}