Documentation ¶
Overview ¶
Package gameworld provides a gameworld protocol server.
Index ¶
- Constants
- Variables
- func LoadOTBForTest(t *testing.T) *itemsotb.Items
- func LoadThingsForTest(t *testing.T) *things.Things
- func MapDescriptionEncoding_Test(t *testing.T, ds1, ds2 MapDataSource)
- type ChaseMode
- type Creature
- type CreatureID
- type CreatureType
- type FightMode
- type GameworldConnection
- type GameworldConnectionID
- type GameworldServer
- type InventorySlot
- type MapDataSource
- type MapItem
- type MapTile
- type MapTileEventSubscriber
- type Skill
Constants ¶
const ( CreatureTypePlayer = CreatureType(0x10000000) CreatureTypeNPC = CreatureType(0x2000000) CreatureTypeMonster = CreatureType(0x40000000) )
Variables ¶
var ( ItemNotFound error CreatureNotFound error )
Functions ¶
func LoadOTBForTest ¶
func MapDescriptionEncoding_Test ¶
func MapDescriptionEncoding_Test(t *testing.T, ds1, ds2 MapDataSource)
This test code is here because to load the map, we need to import OTBM loader.
But OTBM loader imports gameworld, due to some map types being here.
So the actual test is invoked from OTBM loader.
Types ¶
type Creature ¶
type Creature interface { GetPos() tnet.Position SetPos(tnet.Position) error GetID() CreatureID GetName() string GetDir() things.CreatureDirection // TODO: move to tnet? or move tnet.Position to things? SetDir(things.CreatureDirection) error GetServerType() uint16 GetOutfitColors() [4]things.OutfitColor }
type CreatureID ¶
type CreatureID uint32
func NewCreatureID ¶
func NewCreatureID(kind CreatureType) CreatureID
TODO(ivucica): Move this to map data source
type CreatureType ¶ added in v0.0.3
type CreatureType uint32
type GameworldConnection ¶
type GameworldConnection struct {
// contains filtered or unexported fields
}
func (*GameworldConnection) PlayerID ¶
func (c *GameworldConnection) PlayerID() (CreatureID, error)
type GameworldConnectionID ¶
type GameworldConnectionID CreatureID
type GameworldServer ¶
type GameworldServer struct { LameDuckText string // error to serve during lame duck mode // contains filtered or unexported fields }
func NewServer ¶
func NewServer(pk *rsa.PrivateKey) (*GameworldServer, error)
NewServer creates a new GameworldServer which decodes the initial login message using the passed private key.
func (*GameworldServer) Serve ¶
Serve begins serving the gameworld protocol on the accepted network connection.
User of this method needs to bring their own listening schema and accept the connection, then pass on the control to this method.
User also needs to transmit the initial gameworld message which the server sends.
func (*GameworldServer) SetMapDataSource ¶
func (c *GameworldServer) SetMapDataSource(ds MapDataSource) error
SetMapDataSource sets the data source for map information such as tiles, items on tiles, creatures present, etc.
func (*GameworldServer) SetThings ¶
func (c *GameworldServer) SetThings(t *things.Things) error
SetThings sets the thing registry to the passed value. It's used to refer to a combination of items.otb, Tibia.dat and Tibia.spr from the gameworld.
It's not constructed by GameworldServer as the same registry may be used for other servers (such as a web server).
type InventorySlot ¶
type InventorySlot byte
const ( InventorySlotUnknown InventorySlot = iota // 0 InventorySlotHead // 1 InventorySlotNecklace // 2 InventorySlotBackpack // 3 InventorySlotArmor // 4 InventorySlotRight // 5 InventorySlotLeft // 6 InventorySlotLegs // 7 InventorySlotFeet // 8 InventorySlotRing // 9 InventorySlotAmmo // A InventorySlotFirst = InventorySlotHead InventorySlotLast = InventorySlotAmmo )
type MapDataSource ¶
type MapDataSource interface { GetMapTile(x, y uint16, floor uint8) (MapTile, error) GetCreatureByIDBytes(id [4]byte) (Creature, error) GetCreatureByID(CreatureID) (Creature, error) AddCreature(creature Creature) error RemoveCreatureByID(CreatureID) error Private_And_Temp__DefaultPlayerSpawnPoint(CreatureID) tnet.Position }
func NewMapDataSource ¶
func NewMapDataSource() MapDataSource
NewMapDataSource returns a new procedural map data source, good for testing.
type MapTileEventSubscriber ¶
type MapTileEventSubscriber interface { }