dungeonsandtrolls

package
v0.0.0-...-193d145 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const LoopTime = time.Second

Variables

This section is empty.

Functions

func Equip

func Equip(game *Game, player *gameobject.Player, item *api.Item) error

func EvaluateEffects

func EvaluateEffects(g *Game, effects []*api.Effect, a *api.Attributes, receiver gameobject.Alive) ([]*api.Effect, error)

func ExecuteAssignSkillPoints

func ExecuteAssignSkillPoints(player *gameobject.Player, a *api.Attributes) error

func ExecuteBuy

func ExecuteBuy(game *Game, p *gameobject.Player, identifiers *api.Identifiers) error

func ExecutePickUp

func ExecutePickUp(game *Game, p *gameobject.Player, i *api.Identifier) error

func ExecuteSkill

func ExecuteSkill(game *Game, player gameobject.Skiller, su *api.SkillUse) error

func ExecuteYell

func ExecuteYell(game *Game, p gameobject.Positioner, message *api.Message) error

func HideNonPublicMonsterFields

func HideNonPublicMonsterFields(g *Game, m *api.Monster)

func IsMapDeprecated

func IsMapDeprecated(mm *LevelCache, t int32, l int32) bool

func LevelAgeTimeout

func LevelAgeTimeout(l int32) int32

func LevelsPostProcessing

func LevelsPostProcessing(g *Game, m *api.Map, mapCache *MapCache) error

func ParseMap

func ParseMap(mapJson string) (*api.Map, error)

func RemoveMonsterFromTile

func RemoveMonsterFromTile(o *api.MapObjects, m *gameobject.Monster)

func RemovePlayerFromTile

func RemovePlayerFromTile(o *api.MapObjects, p *gameobject.Player)

func TilesInRange

func TilesInRange(game *Game, startingPosition *api.Coordinates, rng int32) []*api.MapObjects

func ValidateBuy

func ValidateBuy(game *Game, p *gameobject.Player, identifiers *api.Identifiers) error

ValidateBuy validates identifiers, funds, and requirements

Types

type Game

type Game struct {
	// Gained after kill (may be used in the next run)
	Score           float32                       `json:"score"`
	Players         map[string]*gameobject.Player `json:"-"`
	ApiKeyToPlayer  map[string]*gameobject.Player `json:"player_api_keys"`
	MaxLevelReached int32                         `json:"max_reached_level"`
	Game            api.GameState                 `json:"-"`
	GameLock        sync.RWMutex                  `json:"-"`
	CommandsLock    sync.RWMutex                  `json:"-"`
	TickCond        *sync.Cond                    `json:"-"`

	Commands map[string]*api.CommandsBatch `json:"-"`

	Respawns []*gameobject.Player `json:"-"`
	// contains filtered or unexported fields
}

func CreateGame

func CreateGame() (*Game, error)

func NewGame

func NewGame() *Game

func (*Game) AddItem

func (g *Game) AddItem(item *api.Item)

func (*Game) AddLevel

func (g *Game) AddLevel(level int32)

func (*Game) AddLevels

func (g *Game) AddLevels(start int32, end int32)

func (*Game) AddPlayer

func (g *Game) AddPlayer(player *gameobject.Player, registration *api.Registration)

func (*Game) AlwaysGetObjectsOnPosition

func (g *Game) AlwaysGetObjectsOnPosition(c *api.Coordinates) (*api.MapObjects, error)

func (*Game) ForceMoveCharacter

func (g *Game) ForceMoveCharacter(p gameobject.Positioner, c *api.Coordinates) error

func (*Game) GetCachedLevel

func (g *Game) GetCachedLevel(level int32) (*LevelCache, error)

func (*Game) GetCommands

func (g *Game) GetCommands(pId string) *api.CommandsBatch

func (*Game) GetCurrentPlayer

func (g *Game) GetCurrentPlayer(token string) (*gameobject.Player, error)

func (*Game) GetMapObjectsOrCreateDefault

func (g *Game) GetMapObjectsOrCreateDefault(c *api.Coordinates) *api.MapObjects

func (*Game) GetMoney

func (g *Game) GetMoney() int32

func (*Game) GetObjectById

func (g *Game) GetObjectById(id string) (gameobject.Ider, error)

func (*Game) GetObjectsOnPosition

func (g *Game) GetObjectsOnPosition(c *api.Coordinates) (*api.MapObjects, error)

func (*Game) GetPlayerByKey

func (g *Game) GetPlayerByKey(apiKey string) (*gameobject.Player, error)

func (*Game) LogEvent

func (g *Game) LogEvent(event *api.Event)

func (*Game) MarkVisitedLevel

func (g *Game) MarkVisitedLevel(level int32)

func (*Game) MoveCharacter

func (g *Game) MoveCharacter(p gameobject.Positioner, c *api.Coordinates) error

MoveCharacter The coordinates must include level.

func (*Game) Register

func (g *Game) Register(o gameobject.Ider)

func (*Game) Respawn

func (g *Game) Respawn(player *gameobject.Player, markDeath bool)

func (*Game) SortMaps

func (g *Game) SortMaps()

func (*Game) SpawnPlayer

func (g *Game) SpawnPlayer(p *gameobject.Player, level int32)

func (*Game) Unregister

func (g *Game) Unregister(o gameobject.Ider)

func (*Game) WaitForNextTick

func (g *Game) WaitForNextTick(tick int32)

type LevelCache

type LevelCache struct {
	SpawnPoint         *api.Coordinates
	Width              int32
	Height             int32
	Objects            map[int32]map[int32]*api.MapObjects
	Grid               *paths.Grid
	GeneratedTick      int32
	LastInteractedTick int32
	Fow                map[int32]map[int32]bool
}

func (*LevelCache) CacheObjectsOnPosition

func (lc *LevelCache) CacheObjectsOnPosition(p *api.Coordinates, mo *api.MapObjects) *api.MapObjects

type MapCache

type MapCache struct {
	Level map[int32]*LevelCache
}

func (*MapCache) CachedLevel

func (m *MapCache) CachedLevel(l int32) (*LevelCache, error)

func (*MapCache) ClearLevelCache

func (m *MapCache) ClearLevelCache(l int32)

Directories

Path Synopsis
Package api is a reverse proxy.
Package api is a reverse proxy.

Jump to

Keyboard shortcuts

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