LastMUD/internal/game/player.go

40 lines
630 B
Go
Raw Normal View History

2025-06-20 16:26:39 +03:00
package game
2025-06-22 17:54:07 +03:00
import "github.com/google/uuid"
2025-06-20 16:26:39 +03:00
type Player struct {
2025-06-22 17:54:07 +03:00
id uuid.UUID
2025-06-24 16:37:26 +03:00
state PlayerState
2025-06-22 17:54:07 +03:00
currentRoom *Room
2025-06-20 16:26:39 +03:00
}
2025-06-24 16:37:26 +03:00
func CreateJoiningPlayer(identity uuid.UUID) *Player {
return &Player{
id: identity,
state: PlayerStateJoining,
currentRoom: nil,
}
}
func CreatePlayer(identity uuid.UUID, state PlayerState, room *Room) *Player {
2025-06-20 16:26:39 +03:00
return &Player{
2025-06-22 17:54:07 +03:00
id: identity,
2025-06-24 16:37:26 +03:00
state: state,
2025-06-22 17:54:07 +03:00
currentRoom: room,
2025-06-20 16:26:39 +03:00
}
}
2025-06-22 17:54:07 +03:00
2025-06-22 22:27:56 +03:00
func (p *Player) Identity() uuid.UUID {
return p.id
2025-06-22 17:54:07 +03:00
}
func (p *Player) SetRoom(r *Room) {
p.currentRoom = r
}
2025-06-22 22:27:56 +03:00
func (p *Player) CurrentRoom() *Room {
return p.currentRoom
}