player

package
v0.0.0-...-3befcbb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2023 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SETCOLOR = "setcolor"
)

Variables

This section is empty.

Functions

func RemoveItemEntity

func RemoveItemEntity(itemEntities *[]*item.ItemEntity, itemEntity *item.ItemEntity, broadcastChan chan messages.BroadcastMessage) bool

Types

type ChatCommandData

type ChatCommandData struct {
	Name string   `json:"name"`
	Args []string `json:"args"`
}

Chatcommand we receive from client

type ChatMessageClientData

type ChatMessageClientData struct {
	Message   string `json:"message"`
	Author    string `json:"author"`
	Timestamp int64  `json:"timestamp"`
	Color     string `json:"color"`
}

The parsed chat message that gets sent out

type ChatMessageData

type ChatMessageData struct {
	Message string `json:"message"`
	Color   string `json:"color"`
}

Chatmessage we receive from clients

type CitizenUpdateStateData

type CitizenUpdateStateData struct {
	// citizen id
	Citizen string `json:"citizen"`
	// conversation id
	Conversation string `json:"conversation"`
	// text
	Text uint `json:"text"`
}

type Player

type Player struct {
	Conn         *websocket.Conn
	Id           uuid.UUID
	HustlerId    string
	Name         string
	CurrentMap   string
	Direction    string
	Position     dopemap.Position
	LastPosition dopemap.Position

	GameItems []*item.ItemEntity

	Chatcolor string

	Items  []item.Item
	Quests []Quest

	// messages sent to player
	Send chan messages.BaseMessage

	// messages broadcasted to the game server
	Unregister chan *Player
	Broadcast  chan messages.BroadcastMessage
}

func NewPlayer

func NewPlayer(conn *websocket.Conn, broadcast chan messages.BroadcastMessage, unregister chan *Player, hustlerId string, name string, currentMap string, x float32, y float32, items []*item.ItemEntity) *Player

func (*Player) AddItem

func (p *Player) AddItem(ctx context.Context, client *ent.Client, gameItem item.Item, pickup bool) error

func (*Player) AddQuest

func (p *Player) AddQuest(ctx context.Context, client *ent.Client, quest Quest) error

func (*Player) Move

func (p *Player) Move(x float32, y float32, direction string)

func (*Player) ReadPump

func (p *Player) ReadPump(ctx context.Context, client *ent.Client)

func (*Player) Serialize

func (p *Player) Serialize() PlayerData

func (*Player) WritePump

func (p *Player) WritePump(ctx context.Context)

type PlayerAddItemClientData

type PlayerAddItemClientData struct {
	Item   string `json:"item"`
	Pickup bool   `json:"pickup"`
}

type PlayerAddQuestClientData

type PlayerAddQuestClientData struct {
	Quest string `json:"quest"`
}

type PlayerData

type PlayerData struct {
	Id         string  `json:"id"`
	HustlerId  string  `json:"hustlerId"`
	Name       string  `json:"name"`
	CurrentMap string  `json:"current_map"`
	X          float32 `json:"x"`
	Y          float32 `json:"y"`
}

type PlayerMoveData

type PlayerMoveData struct {
	Id        string  `json:"id"`
	X         float32 `json:"x"`
	Y         float32 `json:"y"`
	Direction string  `json:"direction"`
}

received from client, updates current pos

type PlayerUpdateMapClientData

type PlayerUpdateMapClientData struct {
	Id         string  `json:"id"`
	CurrentMap string  `json:"current_map"`
	X          float32 `json:"x"`
	Y          float32 `json:"y"`
}

gets sent out to every other player

type PlayerUpdateMapData

type PlayerUpdateMapData struct {
	CurrentMap string  `json:"current_map"`
	X          float32 `json:"x"`
	Y          float32 `json:"y"`
}

received from client

type Quest

type Quest struct {
	Quest     string `json:"quest"`
	Completed bool   `json:"completed"`
}

type Relation

type Relation struct {
	Citizen      string `json:"citizen"`
	Conversation string `json:"conversation"`
	Text         uint   `json:"text"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL