client

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SignUpRoute      = "sign_up"
	LobbyRoute       = "lobby"
	GameRoute        = "game"
	WaitingRoomRoute = "waiting_room"
)

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, ad *ActionDispatcher, rs *RouterStore, opt Options) error

Types

type ActionDispatcher

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

ActionDispatcher is in charge of dispatching actions to the application dispatcher

func NewActionDispatcher

func NewActionDispatcher(d *flux.Dispatcher, s *store.Store, opt Options) *ActionDispatcher

NewActionDispatcher initializes the action dispatcher with the give dispatcher

func (*ActionDispatcher) CameraZoom

func (ac *ActionDispatcher) CameraZoom(d int)

CameraZoom zooms the camera the direction 'd'

func (*ActionDispatcher) ChangeUnitLine

func (ac *ActionDispatcher) ChangeUnitLine(uid string)

ChangeUnitLine will move the unit to the next line

func (*ActionDispatcher) CheckedPath

func (ac *ActionDispatcher) CheckedPath(cp bool)

CheckedPath will set the value of the path checked

func (*ActionDispatcher) CloseTowerMenu

func (ac *ActionDispatcher) CloseTowerMenu()

CloseTowerMenu when a tower menu needs to be closed

func (*ActionDispatcher) CursorMove

func (ac *ActionDispatcher) CursorMove(x, y int)

CursorMove dispatches an action of moving the Cursor to the new x,y coordinates

func (*ActionDispatcher) DeselectTower

func (ac *ActionDispatcher) DeselectTower(t string)

DeelectTower cleans the current selected tower

func (*ActionDispatcher) Dispatch

func (ac *ActionDispatcher) Dispatch(a *action.Action)

Dispatch is a helper to access to the internal dispatch directly with an action. This should only be used from the WS Handler to forward server actions directly

func (*ActionDispatcher) ExitWaitingRoom

func (ac *ActionDispatcher) ExitWaitingRoom(un string)

func (*ActionDispatcher) GoHome

func (ac *ActionDispatcher) GoHome()

GoHome will move the camera to the current player home line

func (*ActionDispatcher) IncomeTick

func (ac *ActionDispatcher) IncomeTick()

IncomeTick a new tick for the income

func (*ActionDispatcher) JoinWaitingRoom

func (ac *ActionDispatcher) JoinWaitingRoom(un string)

func (*ActionDispatcher) NavigateTo

func (ac *ActionDispatcher) NavigateTo(route string)

NavigateTo navigates to the given route

func (*ActionDispatcher) OpenTowerMenu

func (ac *ActionDispatcher) OpenTowerMenu(tid string)

OpenTowerMenu when a tower is clicked and the menu of the tower is displayed

func (*ActionDispatcher) PlaceTower

func (ac *ActionDispatcher) PlaceTower(t, pid string, x, y int)

PlaceTower places the tower 't' on the position X and Y of the player pid

func (*ActionDispatcher) RemovePlayer

func (ac *ActionDispatcher) RemovePlayer(pid string)

func (*ActionDispatcher) RemoveTower

func (ac *ActionDispatcher) RemoveTower(pid, tid, tt string)

RemoveTower removes the tower tid

func (*ActionDispatcher) RemoveUnit

func (ac *ActionDispatcher) RemoveUnit(uid string)

RemoveUnit removes the unit with the id 'uid'

func (*ActionDispatcher) SelectTower

func (ac *ActionDispatcher) SelectTower(t string, x, y int)

SelectTower selects the tower 't' on the position x, y

func (*ActionDispatcher) SelectedTowerInvalid

func (ac *ActionDispatcher) SelectedTowerInvalid(i bool)

SelectTower selects the tower 't' on the position x, y

func (*ActionDispatcher) SignUpSubmit

func (ac *ActionDispatcher) SignUpSubmit(un string)

func (*ActionDispatcher) StealLive

func (ac *ActionDispatcher) StealLive(fpid, tpid string)

StealLive removes one live from the player with id 'fpid' and adds it to the player with id 'tpid'

func (*ActionDispatcher) SummonUnit

func (ac *ActionDispatcher) SummonUnit(unit, pid string, plid, clid int)

SummonUnit summons the 'unit' from the player id 'pid' to the line 'plid' and with the current line id 'clid'

func (*ActionDispatcher) TPS

func (ac *ActionDispatcher) TPS()

TPS is the call for every TPS event

func (*ActionDispatcher) ToggleStats

func (ac *ActionDispatcher) ToggleStats()

func (*ActionDispatcher) TowerAttack

func (ac *ActionDispatcher) TowerAttack(uid, tt string)

TowerAttack issues a attack to the Unit with uid

func (*ActionDispatcher) UnitKilled

func (ac *ActionDispatcher) UnitKilled(pid, ut string)

UnitKilled adds gold to the user

func (*ActionDispatcher) WindowResizing

func (ac *ActionDispatcher) WindowResizing(w, h int)

WindowResizing new sizes of the window

type CameraState

type CameraState struct {
	utils.Object
	Zoom               float64
	LastCursorPosition utils.Object
}

CameraState is the store data on the Camera

type CameraStore

type CameraStore struct {
	*flux.ReduceStore

	Store *store.Store
	// contains filtered or unexported fields
}

CameraStore is in charge of what it's seen on the screen, it also tracks the position of the cursor and the wheel scroll

func NewCameraStore

func NewCameraStore(d *flux.Dispatcher, s *store.Store, w, h int) *CameraStore

NewCameraStore creates a new CameraState linked to the Dispatcher d with the Game g and with width w and height h which is the size of the viewport

func (*CameraStore) Draw

func (cs *CameraStore) Draw(screen *ebiten.Image)

func (*CameraStore) Reduce

func (cs *CameraStore) Reduce(state, a interface{}) interface{}

func (*CameraStore) Update

func (cs *CameraStore) Update() error

type Game

type Game struct {
	Store *store.Store

	Camera *CameraStore
	HUD    *HUDStore

	Units  *Units
	Towers *Towers

	Map *Map
}

Game is the main struct that is the initializer of the main loop. It holds all the other Stores and the Map

func (*Game) Draw

func (g *Game) Draw(screen *ebiten.Image)

func (*Game) Update

func (g *Game) Update() error

type HUDState

type HUDState struct {
	SelectedTower   *SelectedTower
	TowerOpenMenuID string

	LastCursorPosition utils.Object
	CheckedPath        bool

	ShowStats bool
}

HUDState stores the HUD state

type HUDStore

type HUDStore struct {
	*flux.ReduceStore
	// contains filtered or unexported fields
}

HUDStore is in charge of keeping track of all the elements on the player HUD that are static and always seen

func NewHUDStore

func NewHUDStore(d *flux.Dispatcher, i inputer.Inputer, g *Game) (*HUDStore, error)

NewHUDStore creates a new HUDStore with the Dispatcher d and the Game g

func (*HUDStore) Draw

func (hs *HUDStore) Draw(screen *ebiten.Image)

func (*HUDStore) Reduce

func (hs *HUDStore) Reduce(state, a interface{}) interface{}

func (*HUDStore) Update

func (hs *HUDStore) Update() error

type LobbyState

type LobbyState struct {
	TotalUsers int
}

type LobbyStore

type LobbyStore struct {
	*flux.ReduceStore

	Store *Store
	// contains filtered or unexported fields
}

func NewLobbyStore

func NewLobbyStore(d *flux.Dispatcher, i inputer.Inputer, s *Store) (*LobbyStore, error)

func (*LobbyStore) Draw

func (ls *LobbyStore) Draw(screen *ebiten.Image)

func (*LobbyStore) Reduce

func (ls *LobbyStore) Reduce(state, a interface{}) interface{}

func (*LobbyStore) Update

func (ls *LobbyStore) Update() error

type LoggerStore

type LoggerStore struct {
	*flux.ReduceStore
}

LoggerStore is a logger store in charge of logging all the actions

func NewLoggerStore

func NewLoggerStore(d *flux.Dispatcher) *LoggerStore

NewLoggerStore creates a new LoggerStore with the Dispatcher d

func (*LoggerStore) Reduce

func (ss *LoggerStore) Reduce(cstate, a interface{}) interface{}

type Map

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

func NewMap

func NewMap(g *Game) *Map

func (*Map) Draw

func (m *Map) Draw(screen *ebiten.Image)

func (*Map) Update

func (m *Map) Update() error

type Options

type Options struct {
	HostURL string
	ScreenW int
	ScreenH int
}

type RouterState

type RouterState struct {
	Route string
}

type RouterStore

type RouterStore struct {
	*flux.ReduceStore
	// contains filtered or unexported fields
}

func NewRouterStore

func NewRouterStore(d *flux.Dispatcher, su *SignUpStore, l *LobbyStore, wr *WaitingRoomStore, g *Game) *RouterStore

func (*RouterStore) Draw

func (rs *RouterStore) Draw(screen *ebiten.Image)

func (*RouterStore) Layout

func (rs *RouterStore) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int)

func (*RouterStore) Reduce

func (rs *RouterStore) Reduce(state, a interface{}) interface{}

func (*RouterStore) Update

func (rs *RouterStore) Update() error

type SelectedTower

type SelectedTower struct {
	store.Tower

	Invalid bool
}

type SignUpState

type SignUpState struct {
	Error string
}

type SignUpStore

type SignUpStore struct {
	*flux.ReduceStore

	Store *store.Store

	Camera *CameraStore
	// contains filtered or unexported fields
}

func NewSignUpStore

func NewSignUpStore(d *flux.Dispatcher, i inputer.Inputer, s *store.Store) (*SignUpStore, error)

func (*SignUpStore) Draw

func (su *SignUpStore) Draw(screen *ebiten.Image)

func (*SignUpStore) Reduce

func (su *SignUpStore) Reduce(state, a interface{}) interface{}

func (*SignUpStore) Update

func (su *SignUpStore) Update() error

type Store

type Store struct {
	*store.Store

	Users *UserStore
}

func NewStore

func NewStore(ss *store.Store, us *UserStore) *Store

type Towers

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

func NewTowers

func NewTowers(g *Game) (*Towers, error)

func (*Towers) Draw

func (ts *Towers) Draw(screen *ebiten.Image)

func (*Towers) DrawTower

func (ts *Towers) DrawTower(screen *ebiten.Image, c *CameraStore, t *store.Tower)

func (*Towers) Update

func (ts *Towers) Update() error

type Units

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

func NewUnits

func NewUnits(g *Game) (*Units, error)

func (*Units) Draw

func (us *Units) Draw(screen *ebiten.Image)

func (*Units) DrawUnit

func (us *Units) DrawUnit(screen *ebiten.Image, c *CameraStore, u *store.Unit)

func (*Units) Update

func (us *Units) Update() error

type UserState

type UserState struct {
	Username string
}

type UserStore

type UserStore struct {
	*flux.ReduceStore
}

func NewUserStore

func NewUserStore(d *flux.Dispatcher) *UserStore

func (*UserStore) Reduce

func (u *UserStore) Reduce(state, a interface{}) interface{}

func (*UserStore) Username

func (us *UserStore) Username() string

type WaitingRoomState

type WaitingRoomState struct {
	TotalPlayers int
	Size         int
	Countdown    int
}

type WaitingRoomStore

type WaitingRoomStore struct {
	*flux.ReduceStore

	Store *Store
	// contains filtered or unexported fields
}

func NewWaitingRoomStore

func NewWaitingRoomStore(d *flux.Dispatcher, s *Store) *WaitingRoomStore

func (*WaitingRoomStore) Draw

func (wr *WaitingRoomStore) Draw(screen *ebiten.Image)

func (*WaitingRoomStore) Reduce

func (wr *WaitingRoomStore) Reduce(state, a interface{}) interface{}

func (*WaitingRoomStore) Update

func (wr *WaitingRoomStore) Update() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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