2024-04-24 17:11:33 +03:00
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
|
|
|
"mvvasilev/last_light/util"
|
|
|
|
|
|
|
|
"github.com/gdamore/tcell/v2"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Player struct {
|
|
|
|
id uuid.UUID
|
|
|
|
position util.Position
|
2024-05-03 13:46:32 +03:00
|
|
|
|
|
|
|
inventory *Inventory
|
2024-04-24 17:11:33 +03:00
|
|
|
}
|
|
|
|
|
2024-04-27 22:32:05 +03:00
|
|
|
func CreatePlayer(x, y int) *Player {
|
2024-04-24 17:11:33 +03:00
|
|
|
p := new(Player)
|
|
|
|
|
|
|
|
p.id = uuid.New()
|
|
|
|
p.position = util.PositionAt(x, y)
|
2024-05-03 13:46:32 +03:00
|
|
|
p.inventory = CreateInventory(util.SizeOf(8, 4))
|
2024-04-24 17:11:33 +03:00
|
|
|
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Player) UniqueId() uuid.UUID {
|
|
|
|
return p.id
|
|
|
|
}
|
|
|
|
|
2024-04-27 22:32:05 +03:00
|
|
|
func (p *Player) Position() util.Position {
|
|
|
|
return p.position
|
|
|
|
}
|
|
|
|
|
2024-04-24 17:11:33 +03:00
|
|
|
func (p *Player) Move(dir Direction) {
|
2024-04-27 22:32:05 +03:00
|
|
|
p.position = p.Position().WithOffset(MovementDirectionOffset(dir))
|
|
|
|
}
|
2024-04-24 17:11:33 +03:00
|
|
|
|
2024-05-03 13:46:32 +03:00
|
|
|
func (p *Player) Presentation() (rune, tcell.Style) {
|
|
|
|
return '@', tcell.StyleDefault
|
2024-04-24 17:11:33 +03:00
|
|
|
}
|
|
|
|
|
2024-04-27 22:32:05 +03:00
|
|
|
func (p *Player) Passable() bool {
|
|
|
|
return false
|
2024-04-24 17:11:33 +03:00
|
|
|
}
|
|
|
|
|
2024-05-03 13:46:32 +03:00
|
|
|
func (p *Player) Transparent() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Player) Inventory() *Inventory {
|
|
|
|
return p.inventory
|
|
|
|
}
|
|
|
|
|
2024-04-24 17:11:33 +03:00
|
|
|
func (p *Player) Input(e *tcell.EventKey) {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Player) Tick(dt int64) {
|
|
|
|
|
|
|
|
}
|