engine

package
v0.0.0-...-67043c1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AmmoCount

type AmmoCount struct {
	WeaponName string
	AmmoCount  int
}

AmmoCount contains ammo count for a weapon, displayed with inventory.

type BattleResult

type BattleResult struct {
	EngineStateInfo EngineStateInfo
	Result          battleResultInternal
}

type CombineResult

type CombineResult struct {
	EngineStateInfo EngineStateInfo
	Result          combineResultInternal
}

type DebugDoorInfo

type DebugDoorInfo struct {
	Name        string
	Location    string
	RoomA       string
	RoomB       string
	HasKeyLock  bool
	HasCodeLock bool
	IsLocked    bool
	KeyName     string
	Code        string
}

DebugDoorInfo contains complete debug information about a door.

type DebugEnemyInfo

type DebugEnemyInfo struct {
	Name        string
	Description string
	Room        string
	HP          int
	IsAlive     bool
}

DebugEnemyInfo contains complete debug information about an enemy.

type DebugEngineState

type DebugEngineState struct {
	LevelCompletionState string
	Mode                 string
	FightingEnemy        *DebugEnemyInfo
	CurrentRoom          string
}

DebugEngineState contains complete debug information about the engine state.

type DebugEventInfo

type DebugEventInfo struct {
	EventType string
	RoomName  string
	ItemName  string
}

DebugEventInfo contains debug information about an event.

type DebugItemInfo

type DebugItemInfo struct {
	Name         string
	Description  string
	Location     string
	Detail       string
	IsPortable   bool
	IsContainer  bool
	IsConcealer  bool
	IsKey        bool
	IsAmmoBox    bool
	IsWeapon     bool
	IsHealthItem bool

	// Container-specific fields
	HasKeyLock  bool
	HasCodeLock bool
	IsLocked    bool
	IsSearched  bool
	Contains    *DebugItemInfo // Nested item info if container has contents

	// Weapon-specific fields
	WeaponDamage float64
	UsesAmmo     bool
	AmmoQuantity int

	// AmmoBox-specific fields
	WeaponName string
	AmmoCount  int

	// HealthItem-specific fields
	HealthEffect string

	// Concealer-specific fields
	IsUncovered bool
	HiddenItem  *DebugItemInfo // Nested item info if concealer has hidden item
}

DebugItemInfo contains complete debug information about an item.

type DebugPlayerInfo

type DebugPlayerInfo struct {
	Health    string
	IsAlive   bool
	Inventory []DebugItemInfo
	Ammo      map[string]int
}

DebugPlayerInfo contains complete debug information about the player.

type DebugResult

type DebugResult struct {
	EngineStateInfo EngineStateInfo
	EngineState     DebugEngineState
	Player          DebugPlayerInfo
	Rooms           []DebugRoomInfo
	Enemies         []DebugEnemyInfo
	Triggers        []DebugTriggerInfo
	WinCondition    *DebugEventInfo
}

DebugResult contains the complete debug information for the engine.

func (*DebugResult) PrettyPrint

func (d *DebugResult) PrettyPrint() string

PrettyPrint formats the debug result in a readable way.

type DebugRoomInfo

type DebugRoomInfo struct {
	Name        string
	Description string
	Items       []DebugItemInfo
	Doors       []DebugDoorInfo
	IsCurrent   bool
}

DebugRoomInfo contains complete debug information about a room.

type DebugTriggerInfo

type DebugTriggerInfo struct {
	EventType  string
	EventName  string
	EffectType string
	EnemyName  string
}

DebugTriggerInfo contains debug information about a trigger.

type DefaultRng

type DefaultRng struct{}

func (*DefaultRng) Float64

func (g *DefaultRng) Float64() float64

type DoorInfo

type DoorInfo struct {
	Name        string
	Description string
	Location    string
	HasKeyLock  bool
	HasCodeLock bool
	IsLocked    bool
	IsStairwell bool
	IsLatched   bool
	LeadsTo     string
}

type DoorInspection

type DoorInspection struct {
	DoorInfo
}

DoorInspection contains the details of an inspected door.

type Engine

type Engine struct {
	Level                *world.Level
	Player               *world.Player
	CurrentFloor         *world.Floor
	CurrentRoom          *world.Room
	FightingEnemy        *world.Enemy
	Rng                  Rng
	LevelCompletionState LevelCompletionState
	Mode                 Mode
	ValidationDisabled   bool
	MinimapData          map[string]*MinimapDoorInfo // door name -> minimap info
}

Engine contains all live game state and logic for a single level.

func NewEngine

func NewEngine(
	level *world.Level,
) *Engine

NewEngine creates a new engine for a level.

func (*Engine) Battle

func (e *Engine) Battle(weaponName string) (*BattleResult, error)

Battle battles an enemy. Handles the event, possibly triggering a state change. Returns a BattleResult and engine state info with state change notification, if applicable.

func (*Engine) Combine

func (e *Engine) Combine(inputItemAName string, inputItemBName string) (*CombineResult, error)

Combine crafts a new item by combining two input items. Returns a CombineResult and engine state info.

func (*Engine) Debug

func (e *Engine) Debug() (*DebugResult, error)

Debug returns complete debug information about the engine state.

func (*Engine) DisableValidation

func (e *Engine) DisableValidation()

func (*Engine) EnableValidation

func (e *Engine) EnableValidation()

func (*Engine) Heal

func (e *Engine) Heal(name string) (*HealResult, error)

Heal heals the player by name. Returns a HealResult and engine state info.

func (*Engine) Inspect

func (e *Engine) Inspect(name string) (*InspectResult, error)

Inspect inspects an item or door by name. Returns an InspectResult and engine state info.

func (*Engine) Inventory

func (e *Engine) Inventory() (*InventoryResult, error)

Inventory returns the player's inventory. Returns an InventoryResult and engine state info.

func (*Engine) Minimap

func (e *Engine) Minimap() (*MinimapResult, error)

Minimap returns minimap data for the current floor. Returns a MinimapResult with engine state info.

func (*Engine) Observe

func (e *Engine) Observe() (*ObserveResult, error)

Observe observes the current room. Returns an ObserveResult and engine state info.

func (*Engine) Search

func (e *Engine) Search(name string) (*SearchResult, error)

Search searches a container by name. Returns a SearchResult and engine state info.

func (*Engine) Take

func (e *Engine) Take(name string) (*TakeResult, error)

Take takes an item by name. Handles the event, possibly triggering a state change. Returns a TakeResult and engine state info with state change notification, if applicable.

func (*Engine) Traverse

func (e *Engine) Traverse(destination string) (*TraverseResult, error)

Traverse traverses to a destination room. Handles the event, possibly triggering a state change. Returns a TraverseResult and engine state info with state change notification, if applicable.

func (*Engine) Uncover

func (e *Engine) Uncover(name string) (*UncoverResult, error)

Uncover uncovers an item by name. Returns an UncoverResult and engine state info.

func (*Engine) Unlock

func (e *Engine) Unlock(keyNameOrCode string, targetName string) (*UnlockResult, error)

Unlock unlocks a door by name. Returns an UnlockResult and engine state info.

func (*Engine) Use

func (e *Engine) Use(itemName string, targetName string) (*UseResult, error)

type EngineStateChangeNotification

type EngineStateChangeNotification string

EngineStateChangeNotification indicates a state change in the engine.

const (
	EngineStateChangeLevelComplete EngineStateChangeNotification = "level_complete"
	EngineStateChangeLevelFailed   EngineStateChangeNotification = "level_failed"
	EngineStateChangeEnterCombat   EngineStateChangeNotification = "enter_combat"
	EngineStateChangeExitCombat    EngineStateChangeNotification = "exit_combat"
)

type EngineStateInfo

type EngineStateInfo struct {
	LevelCompletionState          LevelCompletionState
	CurrentLevel                  *world.Level
	CurrentFloor                  *world.Floor
	CurrentRoom                   *world.Room
	Mode                          Mode
	PlayerHealth                  world.HealthState
	EngineStateChangeNotification *EngineStateChangeNotification
	FightingEnemy                 *world.Enemy
	OutroNarrative                string
}

EngineStateInfo contains general engine state info.

type FakeRng

type FakeRng struct{ Value float64 }

func (*FakeRng) Float64

func (g *FakeRng) Float64() float64

func (*FakeRng) SetValue

func (g *FakeRng) SetValue(value float64)

type FloorInfo

type FloorInfo struct {
	Name        string
	Description string
}

type HealResult

type HealResult struct {
	EngineStateInfo EngineStateInfo
	Result          healResultInternal
}

type InspectResult

type InspectResult struct {
	EngineStateInfo EngineStateInfo
	Result          inspectResultInternal
}

type InventoryResult

type InventoryResult struct {
	EngineStateInfo EngineStateInfo
	Result          inventoryResultInternal
}

type ItemInfo

type ItemInfo struct {
	Name         string
	Description  string
	Location     string
	IsPortable   bool
	IsContainer  bool
	IsConcealer  bool
	IsKey        bool
	IsAmmoBox    bool
	IsWeapon     bool
	IsHealthItem bool
	IsFixture    bool

	// Container-specific fields
	HasKeyLock  bool
	HasCodeLock bool
	IsLocked    bool
	IsSearched  bool
	Contains    string

	// Concealer-specific fields
	IsUncovered bool
}

ItemInfo contains the basic information about an item, excluding detail.

type ItemInspection

type ItemInspection struct {
	ItemInfo
	Detail string
}

ItemInspection contains the details of an inspected item.

type LevelCompletionState

type LevelCompletionState string

LevelCompletionState indicates the completion state of the current level.

const (
	LevelCompletionStateInProgress LevelCompletionState = "in_progress"
	LevelCompletionStateComplete   LevelCompletionState = "complete"
	LevelCompletionStateFailed     LevelCompletionState = "failed"
)

type MinimapDoorInfo

type MinimapDoorInfo struct {
	Name   string // door name
	Locked *bool  // nil if unknown, true/false if known
	Hidden bool   // true if the door should be hidden on minimap
}

MinimapDoorInfo contains minimap information about a door

type MinimapResult

type MinimapResult struct {
	EngineStateInfo EngineStateInfo
	Result          minimapResultInternal
}

type MinimapRoomInfo

type MinimapRoomInfo struct {
	Name   string
	Hidden bool
}

MinimapRoomInfo contains minimap information about a room

type Mode

type Mode string

Current "mode" of the game. Investigation is the default mode. Certain events (e.g. entering a room) may trigger a switch to Combat.

const (
	Investigation Mode = "investigation"
	Combat        Mode = "combat"
)

type ObserveResult

type ObserveResult struct {
	EngineStateInfo EngineStateInfo
	Result          observeResultInternal
}

type Rng

type Rng interface {
	Float64() float64
}

type SearchResult

type SearchResult struct {
	EngineStateInfo EngineStateInfo
	Result          searchResultInternal
}

type TakeResult

type TakeResult struct {
	EngineStateInfo EngineStateInfo
	Result          takeResultInternal
}

type TraverseResult

type TraverseResult struct {
	EngineStateInfo EngineStateInfo
	Result          traverseResultInternal
}

type UncoverResult

type UncoverResult struct {
	EngineStateInfo EngineStateInfo
	Result          uncoverResultInternal
}

type UnlockResult

type UnlockResult struct {
	EngineStateInfo EngineStateInfo
	Result          unlockResultInternal
}

type UseResult

type UseResult struct {
	EngineStateInfo EngineStateInfo
	Result          useResultInternal
}

Jump to

Keyboard shortcuts

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