remote

package
v0.0.0-...-b7d9b72 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package remote contains tcp server and clients to control the game over the network.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunServer

func RunServer(host, port string, world *core.World, maxPlayer int)

RunServer runs a server (BLOCKING!). The server receives commands from the clients and implements them in "World". The first connecting client controls player 1. The second connecting client controls player 2, and so on.

Types

type Client

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

Client represents a remote connection to the game server, allowing communication and interaction with the game world.

func NewClient

func NewClient(host, port string) (*Client, error)

NewClient creates a new Client instance and establishes a connection to the game server at the provided host and port. It initializes the TCP connection and polls the world status every 100ms.

func (*Client) Fire

func (c *Client) Fire(fromX, fromY, toX, toY int) error

Fire sends a 'Fire' command to the game server to initiate an attack from one tile to another. (see Fire methode from core.World)

func (*Client) Move

func (c *Client) Move(fromX, fromY, toX, toY int) error

Move sends a 'Move' command to the game server to move a unit from one tile to another. (see Move methode from core.World)

func (*Client) Player

func (c *Client) Player() uint8

Player returns the player's ID associated with this client session (see core.PLAYERS).

func (*Client) Status

func (c *Client) Status() *core.World

Status returns the current game world status as new World object. This status is the censored version with the information visible to this player (see core.Censorship).

Jump to

Keyboard shortcuts

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