xwis

package module
v0.0.0-...-c5d2fc1 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2022 License: MIT Imports: 18 Imported by: 2

README

Nox XWIS tools

Tools for working with XWIS lobby servers. Tailored specifically for Nox.

Installation

go install ./cmd/xwis

Listing games

$ xwis list

Total rooms: 5
        1:NoXWorld.ru   0/31
        Daybreak        2/32
        Korean Ladder   5/32
        NoxCommunity EU 0/29
        Sephira Serve   0/13

Registering a game

$ cp xwis-game-example.json xwis-game.json
$ xwis register

Hosting game: "My Server" on "mymap" (arena)

Documentation

Index

Constants

View Source
const (
	AccessOpen    = Access(0)
	AccessClosed  = Access(1)
	AccessPrivate = Access(2)
)
View Source
const (
	ClassWarrior  = Class(1 << 0)
	ClassWizard   = Class(1 << 1)
	ClassConjurer = Class(1 << 2)
)
View Source
const (
	Res640x480   = Resolution(0)
	Res800x600   = Resolution(1)
	Res1024x768  = Resolution(2)
	Res1280x1024 = Resolution(3)
)
View Source
const (
	MapTypeKOTR        = MapType(0x0010)
	MapTypeCTF         = MapType(0x0020)
	MapTypeFlagBall    = MapType(0x0040)
	MapTypeChat        = MapType(0x0080)
	MapTypeArena       = MapType(0x0100)
	MapTypeElimination = MapType(0x0400)
	MapTypeCoop        = MapType(0x0A00)
	MapTypeQuest       = MapType(0x1000)
)
View Source
const (
	DefaultAddress = "xwis.net:4000"
)

Variables

View Source
var DebugLog *log.Logger
View Source
var (
	ErrClientClosed = errors.New("client closed")
)

Functions

This section is empty.

Types

type Access

type Access int

func (Access) MarshalJSON

func (a Access) MarshalJSON() ([]byte, error)

func (Access) String

func (a Access) String() string

func (Access) Unknown

func (a Access) Unknown() bool

func (*Access) UnmarshalJSON

func (a *Access) UnmarshalJSON(data []byte) error

type Class

type Class int

func (Class) String

func (c Class) String() string

type Client

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

func NewClient

func NewClient(ctx context.Context, login, pass string) (*Client, error)

func NewClientWithAddress

func NewClientWithAddress(ctx context.Context, addr, login, pass string) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) HostGame

func (c *Client) HostGame(ctx context.Context, info GameInfo) error

HostGame registers a game and keeps it online until the context is cancelled. This call blocks for the whole duration of the game.

func (*Client) ListRooms

func (c *Client) ListRooms(ctx context.Context) ([]Room, error)

ListRooms lists all available rooms on XWIS.

func (*Client) RegisterGame

func (c *Client) RegisterGame(ctx context.Context, info GameInfo) (*Game, error)

RegisterGame register the game online and allows to control it asynchronously.

type Game

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

func (*Game) Close

func (g *Game) Close() error

Close the game and remove it from XWIS.

func (*Game) Update

func (g *Game) Update(ctx context.Context, info GameInfo) error

Update info for this game.

type GameFlags

type GameFlags int

type GameInfo

type GameInfo struct {
	Addr       string        `json:"addr"`
	Name       string        `json:"name"`
	Map        string        `json:"map"`
	MapType    MapType       `json:"map_type"`
	Access     Access        `json:"access"`
	Disallow   Class         `json:"disallow,omitempty"`
	Flags      GameFlags     `json:"flags,omitempty"`
	Resolution Resolution    `json:"resolution"`
	LimitRes   bool          `json:"limit_res,omitempty"`
	Players    int           `json:"players,omitempty"`
	MaxPlayers int           `json:"max_players,omitempty"`
	MinPing    int           `json:"min_ping,omitempty"`
	MaxPing    int           `json:"max_ping,omitempty"`
	FragLimit  int           `json:"frag_limit,omitempty"`
	TimeLimit  time.Duration `json:"time_limit,omitempty"`
	Unk1       byte          `json:"-"`
	Unk2       uint16        `json:"-"`
	Unk3       [28]byte      `json:"-"`
	Unknown    []byte        `json:"-"`
}

func (*GameInfo) MarshalBinary

func (g *GameInfo) MarshalBinary() ([]byte, error)

func (*GameInfo) UnmarshalBinary

func (g *GameInfo) UnmarshalBinary(data []byte) error

type LobbyServer

type LobbyServer struct {
	Addr string
	Name string
}

func ListLobbyServers

func ListLobbyServers(ctx context.Context) ([]LobbyServer, error)

type MapType

type MapType int

func (MapType) MarshalJSON

func (m MapType) MarshalJSON() ([]byte, error)

func (MapType) String

func (m MapType) String() string

func (MapType) Unknown

func (m MapType) Unknown() bool

func (*MapType) UnmarshalJSON

func (m *MapType) UnmarshalJSON(data []byte) error

type Resolution

type Resolution int

func (Resolution) MarshalJSON

func (r Resolution) MarshalJSON() ([]byte, error)

func (Resolution) String

func (r Resolution) String() string

func (Resolution) Unknown

func (r Resolution) Unknown() bool

func (*Resolution) UnmarshalJSON

func (r *Resolution) UnmarshalJSON(data []byte) error

type Room

type Room struct {
	ID    string
	Name  string
	Users int
	Game  *GameInfo
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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