gameworld

package
Version: v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: GPL-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package gameworld provides a gameworld protocol server.

Index

Constants

View Source
const (
	CreatureTypePlayer  = CreatureType(0x10000000)
	CreatureTypeNPC     = CreatureType(0x2000000)
	CreatureTypeMonster = CreatureType(0x40000000)
)

Variables

View Source
var (
	ItemNotFound     error
	CreatureNotFound error
)

Functions

func LoadOTBForTest

func LoadOTBForTest(t *testing.T) *itemsotb.Items

func LoadThingsForTest

func LoadThingsForTest(t *testing.T) *things.Things

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 ChaseMode

type ChaseMode uint8
const (
	ChaseModeStand ChaseMode = iota
	ChaseModeChase
)

func (ChaseMode) String

func (m ChaseMode) String() string

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 FightMode

type FightMode uint8
const (
	FightModeUnknown FightMode = iota
	FightModeOffensive
	FightModeBalanced
	FightModeDefensive
)

func (FightMode) String

func (m FightMode) String() string

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

func (c *GameworldServer) Serve(conn net.Conn, initialMessage *tnet.Message) error

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 MapItem

type MapItem interface {
	GetServerType() uint16
	GetCount() uint16
}

type MapTile

type MapTile interface {
	GetItem(idx int) (MapItem, error)
	AddCreature(creature Creature) error
	GetCreature(idx int) (Creature, error)
	RemoveCreature(Creature) error
}

type MapTileEventSubscriber

type MapTileEventSubscriber interface {
}

type Skill

type Skill byte
const (
	SkillFist Skill = iota // 0
	SkillClub
	SkillSword
	SkillAxe
	SkillDistance
	SkillShield
	SkillFishing

	SkillFirst = SkillFist
	SkillLast  = SkillFishing
)

Jump to

Keyboard shortcuts

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