action

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TypeStrings

func TypeStrings() []string

TypeStrings returns a slice of all String values of the enum

Types

type Action

type Action struct {
	Type Type   `json:"type"`
	Room string `json:"room"`

	CursorMove           *CursorMovePayload           `json:"cursor_move,omitempty"`
	SummonUnit           *SummonUnitPayload           `json:"summon_unit,omitempty"`
	RemoveUnit           *RemoveUnitPayload           `json:"remove_unit,omitempty"`
	ChangeUnitLine       *ChangeUnitLinePayload       `json:"change_unit_line,omitempty"`
	StealLive            *StealLivePayload            `json:"steal_live,omitempty"`
	CameraZoom           *CameraZoomPayload           `json:"camera_zoom,omitempty"`
	SelectTower          *SelectTowerPayload          `json:"select_tower,omitempty"`
	PlaceTower           *PlaceTowerPayload           `json:"place_tower,omitempty"`
	RemoveTower          *RemoveTowerPayload          `json:"remove_tower,omitempty"`
	SelectedTowerInvalid *SelectedTowerInvalidPayload `json:"selected_tower_invalid,omitempty"`
	TowerAttack          *TowerAttackPayload          `json:"tower_attack,omitempty"`
	UnitKilled           *UnitKilledPayload           `json:"unit_killed,omitempty"`
	WindowResizing       *WindowResizingPayload       `json:"window_resizing,omitempty"`
	NavigateTo           *NavigateToPayload           `json:"navigate_to,omitempty"`
	StartGame            *StartGamePayload            `json:"start_game,omitempty"`
	GoHome               *GoHomePayload               `json:"go_home,omitempty"`
	ToggleStats          *ToggleStatsPayload          `json:"toggle_stats,omitempty"`
	TPS                  *TPSPayload                  `json:"tps,omitempty"`

	OpenTowerMenu  *OpenTowerMenuPayload  `json:"open_tower_menu,omitempty"`
	CloseTowerMenu *CloseTowerMenuPayload `json:"close_tower_menu,omitempty"`

	UserSignUp  *UserSignUpPayload  `json:"user_sign_up,omitempty"`
	SignUpError *SignUpErrorPayload `json:"sign_in_error,omitempty"`
	UserSignIn  *UserSignInPayload  `json:"user_sign_in,omitempty"`
	UserSignOut *UserSignOutPayload `json:"user_sign_out,omitempty"`

	AddPlayer       *AddPlayerPayload       `json:"add_player,omitempty"`
	RemovePlayer    *RemovePlayerPayload    `json:"remove_player,omitempty"`
	JoinWaitingRoom *JoinWaitingRoomPayload `json:"join_waiting_room,omitempty"`
	ExitWaitingRoom *ExitWaitingRoomPayload `json:"exit_waiting_room,omitempty"`
	SyncState       *SyncStatePayload       `json:"sync_state,omitempty"`
	SyncUsers       *SyncUsersPayload       `json:"sync_users,omitempty"`
	SyncWaitingRoom *SyncWaitingRoomPayload `json:"sync_waiting_room,omitempty"`
}

func NewAddPlayer

func NewAddPlayer(id, name string, lid int) *Action

func NewCameraZoom

func NewCameraZoom(d int) *Action

func NewChangeUnitLine

func NewChangeUnitLine(uid string) *Action

func NewCloseTowerMenu

func NewCloseTowerMenu() *Action

func NewCursorMove

func NewCursorMove(x, y int) *Action

func NewDeselectTower

func NewDeselectTower(_ string) *Action

func NewExitWaitingRoom

func NewExitWaitingRoom(un string) *Action

func NewGoHome

func NewGoHome() *Action

func NewIncomeTick

func NewIncomeTick() *Action

func NewJoinWaitingRoom

func NewJoinWaitingRoom(un string) *Action

func NewNavigateTo

func NewNavigateTo(route string) *Action

func NewOpenTowerMenu

func NewOpenTowerMenu(tid string) *Action

func NewPlaceTower

func NewPlaceTower(t, pid string, x, y int) *Action

func NewRemovePlayer

func NewRemovePlayer(id string) *Action

func NewRemoveTower

func NewRemoveTower(pid, tid, tt string) *Action

func NewRemoveUnit

func NewRemoveUnit(uid string) *Action

func NewSelectTower

func NewSelectTower(t string, x, y int) *Action

func NewSelectedTowerInvalid

func NewSelectedTowerInvalid(i bool) *Action

func NewSignUpError

func NewSignUpError(e string) *Action

func NewStartGame

func NewStartGame() *Action

func NewStealLive

func NewStealLive(fpid, tpid string) *Action

func NewSummonUnit

func NewSummonUnit(t, pid string, plid, clid int) *Action

func NewSyncState

func NewSyncState(players *SyncStatePlayersPayload, lines *SyncStateLinesPayload) *Action

TODO: or make the action.Action separated or make the store.Player separated

func NewSyncUsers

func NewSyncUsers(totalUsers int) *Action

func NewSyncWaitingRoom

func NewSyncWaitingRoom(tp, s, cd int) *Action

func NewTPS

func NewTPS(t time.Time) *Action

func NewToggleStats

func NewToggleStats() *Action

func NewTowerAttack

func NewTowerAttack(uid, tt string) *Action

func NewUnitKilled

func NewUnitKilled(pid, ut string) *Action

func NewUserSignIn

func NewUserSignIn(un string) *Action

NewUserSignIn initializes the UserSignIn with just the username the rest of the data needs to be manually set by someone else

func NewUserSignOut

func NewUserSignOut(un string) *Action

func NewUserSignUp

func NewUserSignUp(un string) *Action

func NewWaitRoomCountdownTick

func NewWaitRoomCountdownTick() *Action

func NewWindowResizing

func NewWindowResizing(w, h int) *Action

type AddPlayerPayload

type AddPlayerPayload struct {
	ID     string
	Name   string
	LineID int
}

type CameraZoomPayload

type CameraZoomPayload struct {
	Direction int
}

type ChangeUnitLinePayload

type ChangeUnitLinePayload struct {
	UnitID string
}

type CloseTowerMenuPayload

type CloseTowerMenuPayload struct{}

type CursorMovePayload

type CursorMovePayload struct {
	X int `json:"x"`
	Y int `json:"y"`
}

type ExitWaitingRoomPayload

type ExitWaitingRoomPayload struct {
	Username string
}

type GoHomePayload

type GoHomePayload struct{}

type JoinWaitingRoomPayload

type JoinWaitingRoomPayload struct {
	Username string
}
type NavigateToPayload struct {
	Route string
}

type OpenTowerMenuPayload

type OpenTowerMenuPayload struct {
	TowerID string
}

type PlaceTowerPayload

type PlaceTowerPayload struct {
	Type     string
	PlayerID string
	X        int
	Y        int
}

type RemovePlayerPayload

type RemovePlayerPayload struct {
	ID string
}

type RemoveTowerPayload

type RemoveTowerPayload struct {
	PlayerID  string
	TowerID   string
	TowerType string
}

type RemoveUnitPayload

type RemoveUnitPayload struct{ UnitID string }

type SelectTowerPayload

type SelectTowerPayload struct {
	Type string
	X    int
	Y    int
}

type SelectedTowerInvalidPayload

type SelectedTowerInvalidPayload struct {
	Invalid bool
}

type SignUpErrorPayload

type SignUpErrorPayload struct {
	Error string
}

type StartGamePayload

type StartGamePayload struct {
}

type StealLivePayload

type StealLivePayload struct {
	FromPlayerID string
	ToPlayerID   string
}

type SummonUnitPayload

type SummonUnitPayload struct {
	Type          string
	PlayerID      string
	PlayerLineID  int
	CurrentLineID int
}

type SyncStateLinePayload added in v1.0.3

type SyncStateLinePayload struct {
	Towers map[string]*SyncStateTowerPayload
	Units  map[string]*SyncStateUnitPayload
}

type SyncStateLinesPayload added in v1.0.3

type SyncStateLinesPayload struct {
	Lines map[int]*SyncStateLinePayload
}

type SyncStatePayload

type SyncStatePayload struct {
	Players *SyncStatePlayersPayload
	Lines   *SyncStateLinesPayload
}

type SyncStatePlayerPayload

type SyncStatePlayerPayload struct {
	ID      string
	Name    string
	Lives   int
	LineID  int
	Income  int
	Gold    int
	Current bool
	Winner  bool
}

type SyncStatePlayersPayload

type SyncStatePlayersPayload struct {
	Players     map[string]*SyncStatePlayerPayload
	IncomeTimer int
}

type SyncStateTowerPayload

type SyncStateTowerPayload struct {
	utils.Object

	ID       string
	Type     string
	LineID   int
	PlayerID string
}

type SyncStateUnitPayload

type SyncStateUnitPayload struct {
	utils.MovingObject

	ID            string
	Type          string
	PlayerID      string
	PlayerLineID  int
	CurrentLineID int

	Health float64

	Path      []graph.Step
	HashPath  string
	CreatedAt time.Time
}

type SyncUsersPayload

type SyncUsersPayload struct {
	TotalUsers int
}

type SyncWaitingRoomPayload

type SyncWaitingRoomPayload struct {
	TotalPlayers int
	Size         int
	Countdown    int
}

type TPSPayload added in v1.0.3

type TPSPayload struct {
	Time time.Time
}

type ToggleStatsPayload

type ToggleStatsPayload struct {
}

type TowerAttackPayload

type TowerAttackPayload struct {
	TowerType string
	UnitID    string
}

type Type

type Type int
const (
	CursorMove Type = iota
	CameraZoom
	SummonUnit
	TPS
	RemoveUnit
	StealLive
	PlaceTower
	RemoveTower
	SelectTower
	SelectedTower
	SelectedTowerInvalid
	DeselectTower
	IncomeTick
	TowerAttack
	UnitKilled
	WindowResizing
	NavigateTo
	StartGame
	OpenTowerMenu
	CloseTowerMenu
	GoHome
	ChangeUnitLine
	SignUpError
	UserSignUp
	UserSignIn
	UserSignOut
	JoinWaitingRoom
	ExitWaitingRoom
	ToggleStats

	// Specific to WS
	AddPlayer
	RemovePlayer
	SyncState
	SyncUsers
	WaitRoomCountdownTick
	SyncWaitingRoom
)

func TypeString

func TypeString(s string) (Type, error)

TypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func TypeValues

func TypeValues() []Type

TypeValues returns all values of the enum

func (Type) IsAType

func (i Type) IsAType() bool

IsAType returns "true" if the value is listed in the enum definition. "false" otherwise

func (Type) MarshalJSON

func (i Type) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Type

func (Type) String

func (i Type) String() string

func (*Type) UnmarshalJSON

func (i *Type) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Type

type UnitKilledPayload

type UnitKilledPayload struct {
	PlayerID string
	UnitType string
}

type UserSignInPayload

type UserSignInPayload struct {
	Username   string
	Websocket  *websocket.Conn
	RemoteAddr string
}

type UserSignOutPayload

type UserSignOutPayload struct {
	Username string
}

type UserSignUpPayload

type UserSignUpPayload struct {
	Username string
}

type WindowResizingPayload

type WindowResizingPayload struct {
	Width  int
	Height int
}

Jump to

Keyboard shortcuts

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