app

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WALL              = "wall"
	PLAYER            = "player"
	FIREBALL          = "fireball"
	CASTLE            = "castle"
	NORTH             = "north"
	SOUTH             = "south"
	EAST              = "east"
	WEST              = "west"
	PLAYER_MAX_HEALTH = 5
)
View Source
const (
	WIDTH  = 30
	HEIGHT = 20
)
View Source
const (
	PURPLE = lipgloss.Color("13")
	GREEN  = lipgloss.Color("10")
)
View Source
const (
	TICK_DURATION_MS = 100
)

Variables

This section is empty.

Functions

func Move

func Move(oldGrid *Grid, nextGrid *Grid, y int, x int)

Types

type App

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

func NewApp

func NewApp() App

func (*App) CastSpells

func (a *App) CastSpells()

func (*App) FindPlayer

func (a *App) FindPlayer(id string) (error, *Entity)

func (*App) MoveAll

func (a *App) MoveAll()

func (*App) ProgramHandler

func (a *App) ProgramHandler(s ssh.Session) *tea.Program

func (*App) Send

func (a *App) Send(msg tea.Msg)

func (*App) Start

func (a *App) Start()

type CastSpellMsg

type CastSpellMsg struct {
	ID        string
	Type      string
	Direction string
}

type Entity

type Entity struct {
	Skin            string
	Type            string
	ID              string
	NextMove        string
	Indestructible  bool
	RemoveOnContact bool
	Health          int
	Damage          int
	IsDead          bool
}

func CreateCastle

func CreateCastle() *Entity

func CreateFireball

func CreateFireball(direction string) *Entity

func CreateNextPlayer

func CreateNextPlayer() *Entity

func (*Entity) Render

func (e *Entity) Render(sb *strings.Builder)

type Grid

type Grid [][]*Entity

func NewGrid

func NewGrid() *Grid

func (*Grid) DealDamage

func (g *Grid) DealDamage(entity *Entity, amount int)

func (*Grid) FindEntity

func (g *Grid) FindEntity(id string) (*Entity, int, int, error)

func (*Grid) PlaceCastles

func (g *Grid) PlaceCastles()

func (*Grid) PlacePlayer

func (g *Grid) PlacePlayer(p *Entity)

func (*Grid) SpawnEntity

func (g *Grid) SpawnEntity(e *Entity, y int, x int)

type GridUpdateMsg

type GridUpdateMsg struct {
	Grid Grid
}

type Model

type Model struct {
	Grid Grid
	App  *App
	ID   string
	PC   *Entity
}

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Model) View

func (m Model) View() string

type PlanMoveMsg

type PlanMoveMsg struct {
	ID        string
	Direction string
}

type TryRespawnMsg

type TryRespawnMsg struct {
	ID string
}

Jump to

Keyboard shortcuts

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