builtin

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package builtin 包含了通用游戏相关的接口的内置实现

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCannotAddNegativeOrZeroItem = errors.New("cannot add items with negative quantities or zero")
	ErrItemNotExist                = errors.New("item not exist")
	ErrItemInsufficientQuantity    = errors.New("item insufficient quantity")
	ErrItemContainerIsFull         = errors.New("item container is full")
	ErrItemContainerNotExist       = errors.New("item container not exist")
)

Functions

This section is empty.

Types

type Actor

type Actor struct {
	// contains filtered or unexported fields
}

func NewActor

func NewActor(guid int64) *Actor

func (*Actor) GetGuid

func (slf *Actor) GetGuid() int64

func (*Actor) SetGuid

func (slf *Actor) SetGuid(guid int64)

type Item

type Item[ItemID comparable] struct {
	// contains filtered or unexported fields
}

func NewItem

func NewItem[ItemID comparable](id ItemID) *Item[ItemID]

func (*Item[ItemID]) GetID

func (slf *Item[ItemID]) GetID() ItemID

func (*Item[ItemID]) IsSame

func (slf *Item[ItemID]) IsSame(item game.Item[ItemID]) bool

type ItemContainer

type ItemContainer[ItemID comparable, Item game.Item[ItemID]] struct {
	// contains filtered or unexported fields
}

func NewItemContainer

func NewItemContainer[ItemID comparable, Item game.Item[ItemID]](options ...ItemContainerOption[ItemID, Item]) *ItemContainer[ItemID, Item]

func (*ItemContainer[ItemID, Item]) AddItem

func (slf *ItemContainer[ItemID, Item]) AddItem(item Item, count *huge.Int) (guid int64, err error)

func (*ItemContainer[ItemID, Item]) CheckAllowAdd

func (slf *ItemContainer[ItemID, Item]) CheckAllowAdd(item Item, count *huge.Int) error

func (*ItemContainer[ItemID, Item]) CheckDeductItem

func (slf *ItemContainer[ItemID, Item]) CheckDeductItem(guid int64, count *huge.Int) error

func (*ItemContainer[ItemID, Item]) Clear

func (slf *ItemContainer[ItemID, Item]) Clear()

func (*ItemContainer[ItemID, Item]) DeductItem

func (slf *ItemContainer[ItemID, Item]) DeductItem(guid int64, count *huge.Int) error

func (*ItemContainer[ItemID, Item]) ExistItem

func (slf *ItemContainer[ItemID, Item]) ExistItem(guid int64) bool

func (*ItemContainer[ItemID, Item]) ExistItemWithID

func (slf *ItemContainer[ItemID, Item]) ExistItemWithID(id ItemID) bool

func (*ItemContainer[ItemID, Item]) GetItem

func (slf *ItemContainer[ItemID, Item]) GetItem(guid int64) (game.ItemContainerMember[ItemID, Item], error)

func (*ItemContainer[ItemID, Item]) GetItems

func (slf *ItemContainer[ItemID, Item]) GetItems() []game.ItemContainerMember[ItemID, Item]

func (*ItemContainer[ItemID, Item]) GetItemsFull

func (slf *ItemContainer[ItemID, Item]) GetItemsFull() []game.ItemContainerMember[ItemID, Item]

func (*ItemContainer[ItemID, Item]) GetItemsMap

func (slf *ItemContainer[ItemID, Item]) GetItemsMap() map[int64]game.ItemContainerMember[ItemID, Item]

func (*ItemContainer[ItemID, Item]) GetSize

func (slf *ItemContainer[ItemID, Item]) GetSize() int

func (*ItemContainer[ItemID, Item]) GetSizeLimit

func (slf *ItemContainer[ItemID, Item]) GetSizeLimit() int

func (*ItemContainer[ItemID, Item]) Remove

func (slf *ItemContainer[ItemID, Item]) Remove(guid int64)

func (*ItemContainer[ItemID, Item]) RemoveWithID

func (slf *ItemContainer[ItemID, Item]) RemoveWithID(id ItemID)

func (*ItemContainer[ItemID, Item]) SetExpandSize

func (slf *ItemContainer[ItemID, Item]) SetExpandSize(size int)

func (*ItemContainer[ItemID, Item]) TransferTo

func (slf *ItemContainer[ItemID, Item]) TransferTo(guid int64, count *huge.Int, target game.ItemContainer[ItemID, Item]) error

type ItemContainerMember

type ItemContainerMember[ItemID comparable, I game.Item[ItemID]] struct {
	// contains filtered or unexported fields
}

func NewItemContainerMember

func NewItemContainerMember[ItemID comparable, I game.Item[ItemID]](guid int64, item I) *ItemContainerMember[ItemID, I]

func (*ItemContainerMember[ItemID, I]) GetCount

func (slf *ItemContainerMember[ItemID, I]) GetCount() *huge.Int

func (*ItemContainerMember[ItemID, I]) GetGUID

func (slf *ItemContainerMember[ItemID, I]) GetGUID() int64

func (*ItemContainerMember[ItemID, I]) GetID

func (slf *ItemContainerMember[ItemID, I]) GetID() ItemID

func (*ItemContainerMember[ItemID, I]) GetItem

func (slf *ItemContainerMember[ItemID, I]) GetItem() I

type ItemContainerOption

type ItemContainerOption[ItemID comparable, Item game.Item[ItemID]] func(container *ItemContainer[ItemID, Item])

func WithItemContainerSizeLimit

func WithItemContainerSizeLimit[ItemID comparable, Item game.Item[ItemID]](sizeLimit int) ItemContainerOption[ItemID, Item]

WithItemContainerSizeLimit 通过特定的物品容器非堆叠数量上限创建物品容器

func WithItemContainerStackLimit

func WithItemContainerStackLimit[ItemID comparable, Item game.Item[ItemID]](id ItemID, stackLimit *huge.Int) ItemContainerOption[ItemID, Item]

WithItemContainerStackLimit 通过设置特定物品堆叠数量创建容器

type Player

type Player[ID comparable] struct {
	// contains filtered or unexported fields
}

Player 游戏玩家

func NewPlayer

func NewPlayer[ID comparable](id ID, conn *server.Conn) *Player[ID]

func (*Player[ID]) Close

func (slf *Player[ID]) Close(err ...error)

Close 关闭玩家

func (*Player[ID]) GetConn added in v0.0.18

func (slf *Player[ID]) GetConn() *server.Conn

func (*Player[ID]) GetID

func (slf *Player[ID]) GetID() ID

func (*Player[ID]) Send

func (slf *Player[ID]) Send(packet []byte, callback ...func(err error))

Send 向该玩家发送数据

func (*Player[ID]) UseConn

func (slf *Player[ID]) UseConn(conn *server.Conn)

Jump to

Keyboard shortcuts

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