game

package
v0.0.0-...-2b0e672 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: GPL-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package with game wrapper struct.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Character

type Character struct {
	*character.Character
	// contains filtered or unexported fields
}

Struct for game character.

func NewCharacter

func NewCharacter(char *character.Character, game *Game) *Character

NewCharacter creates game wrapper for module character.

func (*Character) AddChatMessage

func (c *Character) AddChatMessage(message objects.Message)

AddChatMessage adds new message to the character chat log.

func (*Character) CombatLog

func (c *Character) CombatLog() *objects.Log

CombatLog returns character combat log.

func (*Character) Equip

func (c *Character) Equip(it item.Equiper) error

Equip inserts specified equipable item to all compatible slots in active PC equipment.

func (*Character) InSight

func (c *Character) InSight(x, y float64) bool

InSight checks if specified XY position is in sight range of the character.

func (*Character) Name

func (c *Character) Name() string

Name returns character name.

func (*Character) PrivateLog

func (c *Character) PrivateLog() *objects.Log

PrivateLog returns character private log.

func (*Character) SetDestPoint

func (c *Character) SetDestPoint(x, y float64)

SetDestPoint sets destination point for player character.

func (*Character) SetOnUseFunc

func (c *Character) SetOnUseFunc(f func(o useaction.Usable))

SetOnUseFunc sets function to trigger after using an object.

func (*Character) SetPosition

func (c *Character) SetPosition(x, y float64)

SetPosition sets character position and destination point.

func (*Character) SetTarget

func (c *Character) SetTarget(tar effect.Target)

SetTarget sets specified targetable object as the current target.

func (*Character) Train

func (c *Character) Train(training *training.TrainerTraining, trainer training.Trainer)

Train uses specified training from specified trainer.

func (*Character) Unequip

func (c *Character) Unequip(it item.Equiper)

Unequip removes specified item from player equipment.

func (*Character) Usable

func (c *Character) Usable(id, serial string) useaction.Usable

Usable returns usable object with specified ID and serial.

func (*Character) Use

func (c *Character) Use(ob useaction.Usable)

Use uses specified usable object.

type Game

type Game struct {
	*flame.Module
	// contains filtered or unexported fields
}

Wrapper struct for game.

func New

func New(module *flame.Module) *Game

New creates new wrapper for specified module.

func (*Game) ActivePlayerChar

func (g *Game) ActivePlayerChar() *Character

ActivePlayerChar returns active player character.

func (*Game) AddPlayerChar

func (g *Game) AddPlayerChar(char *Character) error

AddPlayerChar adds specified character to player characters list.

func (*Game) AnswerDialog

func (g *Game) AnswerDialog(dialog *dialog.Dialog, answer *dialog.Answer)

AnswerDialog answers dialog with specified answer.

func (*Game) Char

func (g *Game) Char(id, serial string) *Character

Char returns game character with specified ID and serial.

func (*Game) Closing

func (g *Game) Closing() bool

Closing checks if game should be closed.

func (*Game) Pause

func (g *Game) Pause() bool

Pause checks if the game pause is active.

func (*Game) PlayerChars

func (g *Game) PlayerChars() []*Character

PlayerChars returns all player characters.

func (*Game) Server

func (g *Game) Server() *Server

Server returns game server connection.

func (*Game) SetActivePlayerChar

func (g *Game) SetActivePlayerChar(char *Character)

SetActivePlayer sets specified avatar as active player avatar.

func (*Game) SetOnPlayerCharChangeFunc

func (g *Game) SetOnPlayerCharChangeFunc(f func(c *Character))

SetOnPlayerChangeFunc sets function triggered on active player change.

func (*Game) SetPause

func (g *Game) SetPause(pause bool)

SetPause pauses/unpauses the game. If game uses the remote server this function will only send the pause request to the server and return, changing the game pause variable value should happend while handling the server response in such a case.

func (*Game) SetServer

func (g *Game) SetServer(server *Server)

SetServer sets game server.

func (*Game) SpawnChar

func (g *Game) SpawnChar(char *Character) error

SpawnChar sets start area and position of current chapter for specified character.

func (*Game) StartDialog

func (g *Game) StartDialog(dialog *dialog.Dialog, target dialog.Talker)

StartDialog starts dialog with specified object as dialog target.

func (*Game) Trade

func (g *Game) Trade(seller, buyer item.Container, sellItems, buyItems []item.Item)

Trade exchanges items between specified containers.

func (*Game) TransferItems

func (g *Game) TransferItems(from, to item.Container, items ...item.Item) error

TransferItems transfer items between specified objects. Items are in the form of a map with IDs as keys and serial values as values.

func (*Game) Update

func (g *Game) Update()

Update updates game. It executes game update loop until game is closed.

func (*Game) VisibleForPlayer

func (g *Game) VisibleForPlayer(x, y float64) bool

VisibleForPlayer checks whether specified position is in visibility range of any PC.

type Server

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

Struct for server connection.

func NewServer

func NewServer(host, port string) (*Server, error)

NewServer creates new server struct with connection to server with specified host and port number.

func (*Server) Address

func (s *Server) Address() string

Address returns server address.

func (*Server) Authorized

func (s *Server) Authorized() bool

Authorized checks if server connection is authorized.

func (*Server) Send

func (s *Server) Send(req request.Request) error

Send sends specified request to the server.

func (*Server) SetOnResponseFunc

func (s *Server) SetOnResponseFunc(f func(r response.Response))

SetOnResponseFunc sets function triggered on each server response.

Jump to

Keyboard shortcuts

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