game

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CmdRepeater

func CmdRepeater(gs *GameState, count int, cmd func(*GameState))

func GetMapSize

func GetMapSize(gs GameState) (height, width int)

func IsWall

func IsWall(gs GameState, line, col int) bool

func ToLines

func ToLines(gs GameState) []string

func ToText

func ToText(lines []string) string

Types

type AttackType

type AttackType int
const (
	Melee AttackType = iota
	Ranged
)

type Camera

type Camera struct {
	X      int
	Y      int
	Width  int
	Height int
}

type CombatLog

type CombatLog struct {
	EnemyType
	Hit         bool
	EnemyKilled bool
	Critical    bool
	DamageDealt int
	Experience  int
	AttackStyle AttackType
}

func (CombatLog) ParseLog

func (l CombatLog) ParseLog() string

type EnemyInfo

type EnemyInfo struct {
	EnemyType
	Location  Position
	BaseDmg   int
	Health    int
	MoveCount int
}

func MakeChaser

func MakeChaser(line, col int) EnemyInfo

func MakeMeleer

func MakeMeleer(line, col int) EnemyInfo

func MakeTank

func MakeTank(line, col int) EnemyInfo

Zanth is a friend who loves playing tank, so this is a mob dedicated to him

func (EnemyInfo) GetExperience

func (e EnemyInfo) GetExperience(attack AttackType) int

type EnemyType

type EnemyType int
const (
	Normal EnemyType = iota
	Chaser
	Tank
)

func (EnemyType) String

func (e EnemyType) String() string

type GameState

type GameState struct {
	Player  Position
	Stats   PlayerInfo
	Enemies []EnemyInfo
	Items   []Item
	MapInfo MapInfo
	// contains filtered or unexported fields
}

func (*GameState) AttackMob

func (gs *GameState) AttackMob(e *EnemyInfo, style AttackType) CombatLog

func (GameState) BlockedTile

func (gs GameState) BlockedTile(line, col, idx int) bool

func (*GameState) ChasePlayer

func (gs *GameState) ChasePlayer() string

func (*GameState) CurrentSnapShot

func (gs *GameState) CurrentSnapShot() SnapShot

func (*GameState) DeleteAt

func (gs *GameState) DeleteAt()

func (*GameState) DeleteDirection

func (gs *GameState) DeleteDirection(input string)

H and L aren't wrong or bugged, for some reason this is how actual VIM accepts these deletes based on position J and K also aren't bugged.. VIM doesn't seem to like trying to delete current + next if there isnt a next

func (*GameState) DropGold

func (gs *GameState) DropGold(line, col int) int

func (*GameState) DropItem

func (gs *GameState) DropItem(line, col, amount int, itemType ItemType)

func (*GameState) DropPotion

func (gs *GameState) DropPotion(line, col int)

func (GameState) EnemyAt

func (gs GameState) EnemyAt(line, col int) (EnemyInfo, bool)

func (*GameState) GetLootFromKill

func (gs *GameState) GetLootFromKill(line, col int, style AttackType)

func (GameState) GetTile

func (gs GameState) GetTile(line, col int) rune

func (*GameState) GrabItem

func (gs *GameState) GrabItem() string

func (*GameState) HaveFeather added in v0.1.4

func (gs *GameState) HaveFeather() bool

func (GameState) ItemAt

func (gs GameState) ItemAt(line, col int) (Item, bool)

func (*GameState) JumpToEnd

func (gs *GameState) JumpToEnd()

Jumps to end of next word

func (*GameState) JumpToEndOrPunct

func (gs *GameState) JumpToEndOrPunct()

Jumps to end of word or next punct

func (*GameState) JumpToLast

func (gs *GameState) JumpToLast()

Jumps to last index of line

func (*GameState) JumpToNext

func (gs *GameState) JumpToNext()

Jumps to either next new word OR punctuation

func (*GameState) JumpToNextWord

func (gs *GameState) JumpToNextWord()

Only jumps to next word after a space

func (*GameState) JumpToPrev

func (gs *GameState) JumpToPrev()

Jumps to last beginning of word or punctuation

func (*GameState) JumpToPrevWord

func (gs *GameState) JumpToPrevWord()

Jump to last word

func (*GameState) JumpToStart

func (gs *GameState) JumpToStart()

Jumps to first index of line (shuffled to 1 because hardcoded maps start at index 1, normally is index 0)

func (*GameState) LevelStats

func (gs *GameState) LevelStats(input string)

func (*GameState) MapComplete

func (gs *GameState) MapComplete() bool

func (*GameState) MeleeAttack

func (gs *GameState) MeleeAttack() CombatLog

func (*GameState) OpenChest

func (gs *GameState) OpenChest(line, col int) string

func (*GameState) RangedAttack

func (gs *GameState) RangedAttack(direction string) CombatLog

func (*GameState) Redo

func (gs *GameState) Redo()

func (*GameState) ReplaceAt

func (gs *GameState) ReplaceAt(input string)

func (*GameState) SpawnEnemy

func (gs *GameState) SpawnEnemy(maxEnemies int)

func (*GameState) SpawnPlayer

func (gs *GameState) SpawnPlayer() Position

func (*GameState) TakeSnapShot

func (gs *GameState) TakeSnapShot(pos Position, mapLines []string)

func (*GameState) TryDamagePlayer

func (gs *GameState) TryDamagePlayer() string

func (*GameState) Undo

func (gs *GameState) Undo()

func (*GameState) UseFeather added in v0.1.4

func (gs *GameState) UseFeather()

func (*GameState) UseMerchant

func (gs *GameState) UseMerchant(option int) (string, bool)

Add more options in the future, items instead of potion + xp

func (*GameState) UsePotion

func (gs *GameState) UsePotion()

type Item

type Item struct {
	Type   ItemType
	Amount int
	Line   int
	Col    int
}

type ItemType

type ItemType int
const (
	HealthPotion ItemType = iota
	Gold         ItemType = iota
	LuckyFeather ItemType = iota
)

func PickRandomItem

func PickRandomItem() ItemType

type MapInfo

type MapInfo struct {
	Level     int
	LevelMap  levels.LevelMap
	AnswerMap levels.LevelMap
	MapType   MapType
}

func GetMapInfo

func GetMapInfo(level int) MapInfo

type MapType

type MapType string
const (
	RoomMap   MapType = "room"
	EditorMap MapType = "editor"
)

func GetType

func GetType(sMap levels.LevelMap) MapType

type PlayerInfo

type PlayerInfo struct {
	MaxHealth     int
	CurrentHealth int
	BaseDmg       int
	CritChance    int
	BaseCritMulti int
	XPGained      int
	TotalXP       int
	Kills         int
	DamageTaken   int
	Inventory     []Item
	Gold          int
	PlayerLevel   int
	HardCore      bool
}

type Position

type Position struct {
	Line   int
	Column int
}

func (*Position) AdjustPlayer

func (p *Position) AdjustPlayer(lines []string)

func (*Position) Move

func (p *Position) Move(direction string, gs GameState)

type SnapShot

type SnapShot struct {
	PlayerSnapShot Position
	MapSnapShot    []string
}

Jump to

Keyboard shortcuts

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