mud

package
v0.0.0-...-bd7a5bd Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Color_None ANSIColor = ""

	Color_Black   ANSIColor = "black"
	Color_Red     ANSIColor = "red"
	Color_Green   ANSIColor = "green"
	Color_Yellow  ANSIColor = "yellow"
	Color_Blue    ANSIColor = "blue"
	Color_Magenta ANSIColor = "magenta"
	Color_Cyan    ANSIColor = "cyan"
	Color_White   ANSIColor = "white"

	Color_DimBlack   ANSIColor = "dim black"
	Color_DimRed     ANSIColor = "dim red"
	Color_DimGreen   ANSIColor = "dim green"
	Color_DimYellow  ANSIColor = "dim yellow"
	Color_DimBlue    ANSIColor = "dim blue"
	Color_DimMagenta ANSIColor = "dim magenta"
	Color_DimCyan    ANSIColor = "dim cyan"
	Color_DimWhite   ANSIColor = "dim white"

	Color_BrightBlack   ANSIColor = "bright black"
	Color_BrightRed     ANSIColor = "bright red"
	Color_BrightGreen   ANSIColor = "bright green"
	Color_BrightYellow  ANSIColor = "bright yellow"
	Color_BrightBlue    ANSIColor = "bright blue"
	Color_BrightMagenta ANSIColor = "bright magenta"
	Color_BrightCyan    ANSIColor = "bright cyan"
	Color_BrightWhite   ANSIColor = "bright white"

	Color_Prompt        = Color_BrightGreen
	Color_Positive      = Color_Green
	Color_Negative      = Color_Red
	Color_NegativeBld   = Color_Red
	Color_Neutral       = Color_Yellow
	Color_NeutralBld    = Color_BrightYellow
	Color_PositiveBld   = Color_BrightGreen
	Color_Header        = Color_BrightCyan
	Color_SubHeader     = Color_Cyan
	Color_Entities      = Color_BrightWhite
	Color_Items         = Color_BrightWhite
	Color_Enum          = Color_BrightWhite
	Color_Stat          = Color_Cyan
	Color_PlayerDam     = Color_Green
	Color_EnemyDam      = Color_Red
	Color_StatusEffects = Color_Yellow
	Color_Cnd_Hurt      = Color_Red
	Color_Cnd_LightHurt = Color_Yellow
	Color_Cnd_Healthy   = Color_Green
)
View Source
const (
	MaxLevel     = 100
	MaxStatValue = 99
	SightRange   = 12
)
View Source
const (
	InvalidId = 0
)
View Source
const PlayerEntityKey = "_player"
View Source
const PlayerFileExtension = ".ply"
View Source
const PlayersDirectory = "players"
View Source
const (
	ScriptFileExtension = ".lua"
)
View Source
const (
	StatusEffectDuration_Permanent = 0
)

Variables

View Source
var CellsPerSecondSpeedLookup = []float64{
	0,
	2.5,
	3.33,
	6.66,
	10,
}

Converts Speed enum to number of cells that entity can traverse per second

View Source
var D10 = &Dice{1, 10, 0}
View Source
var D100 = &Dice{1, 100, 0}
View Source
var D12 = &Dice{1, 12, 0}
View Source
var D20 = &Dice{1, 20, 0}
View Source
var D4 = &Dice{1, 4, 0}
View Source
var D6 = &Dice{1, 6, 0}
View Source
var D8 = &Dice{1, 8, 0}
View Source
var DefenderElementModifierLookup = [][][]float64{

	{
		{1, 1, 1, 1, 1, 1, 1, 1, 0.25, 1},
		{1, 0.25, 1, 0.5, 1.75, 1, 1, 1, 1, 1},
		{1, 1, 1, 1.5, 0.5, 1.25, 1, 1, 1, 1},
		{1, 1.5, 0.5, 0.25, 1, 1.25, 1, 1, 1, 1},
		{1, 0.5, 1.5, 1, 0.25, 1.25, 1, 1, 1, 1},
		{1, 1, 1, 1, 1, 0, 1, 0.5, 1, 0.5},
		{1, 0.75, 0.75, 0.75, 0.75, 0.75, 0, 1.25, 0.75, 1},
		{1, 1, 1, 1, 1, 0.5, 1.25, 0, 0.75, 0},
		{0.25, 1, 1, 1, 1, 1, 1, 1, 1.25, 1},
		{1, 1, 1, 1.25, 1, -0.25, 1.5, -0.25, 1, 0},
	},

	{
		{1, 1, 1, 1, 1, 1, 1, 1, 0, 1},
		{1, 0, 1, 0.25, 1.75, 0.75, 1, 1, 0.75, 0.75},
		{1, 1, 0.5, 1.75, 0.25, 1.25, 1, 1, 0.75, 0.75},
		{1, 1.75, 0.25, 0, 1, 1.25, 1, 1, 0.75, 0.75},
		{1, 0.25, 1.75, 1, 0, 1.25, 1, 1, 0.75, 0.75},
		{1, 1, 1, 1, 1, 0, 1, 0.25, 0.75, 0.25},
		{1, 0.5, 0.5, 0.5, 0.5, 0.5, -0.25, 1.5, 0.5, 1.25},
		{1, 0.75, 0.75, 0.75, 0.75, 0.25, 1.5, -0.25, 0.5, 0},
		{0.25, 1, 1, 1, 1, 0.75, 1, 1, 1.5, 1},
		{1, 1, 1, 1.5, 1, -0.5, 1.75, -0.5, 1.25, 0},
	},

	{
		{1, 1, 1, 1, 1, 1, 1, 1, 0, 1},
		{1, -0.25, 1, 0, 2, 0.5, 1, 1, 0.5, 0.5},
		{1, 1, 0, 2, 0, 1, 1, 1, 0.5, 0.5},
		{1, 2, 0, -0.25, 1, 1, 1, 1, 0.5, 0.5},
		{1, 0, 2, 1, -0.25, 1, 1, 1, 0.5, 0.5},
		{1, 1, 1, 1, 1, 0, 1.25, 0, 0.5, 0},
		{1, 0.25, 0.25, 0.25, 0.25, 0.25, -0.5, 1.75, 0.25, 1.5},
		{1, 0.5, 0.5, 0.5, 0.5, 0, 1.75, -0.5, 0.25, 0},
		{0, 1, 1, 1, 1, 0.5, 1, 1, 1.75, 1},
		{1, 1.25, 1, 1.75, 1, -0.75, 2, -0.75, 1.5, 0},
	},

	{
		{1, 1, 1, 1, 1, 1, 1, 1, 0, 1},
		{1, -0.5, 1, 0, 2, 0.25, 0.75, 0.75, 0.25, 0.25},
		{1, 1, -0.25, 2, 0, 0.75, 0.75, 0.75, 0.25, 0.25},
		{1, 2, 0, -0.5, 1, 0.75, 0.75, 0.75, 0.25, 0.25},
		{1, 0, 2, 1, -0.5, 0.75, 0.75, 0.75, 0.25, 0.25},
		{1, 0.75, 0.75, 0.75, 0.75, 0, 1.25, -0.25, 0.25, -0.25},
		{1, 0, 0, 0, 0, 0, -1, 2, 0, 1.75},
		{1, 0.25, 0.25, 0.25, 0.25, -0.25, 2, -1, 0, 0},
		{0, 1, 1, 1, 1, 0.25, 1, 1, 2, 1},
		{1, 1.5, 0.5, 2, 1, -1, 2, -1, 1.75, 0},
	},
}

Map of defending element to attacking element multiplier (by defending element level) = [DefElemLevel][DefElem][AtkElem]Mult

View Source
var DefenderSizeModifierLookup = [][]float64{
	{1, 1, 0.75, 0.75, 0.75, 0.75, 0.5, 0.75, 1, 1, 0.75, 1, 1, 0.75, 0.75},
	{1, 0.75, 1, 0.75, 0.75, 1, 0.75, 1, 1, 1, 1, 1, 0.75, 1, 1},
	{1, 0.5, 0.75, 1, 1, 1, 1, 1, 1, 0.75, 0.75, 0.5, 0.5, 0.75, 0.5},
}

Determines damage modification multiplier when attacking entity of specified size with weapon type = Size[WeaponType]Mult

View Source
var JobXPLookup = [][]int{

	{
		0,
		0,
		10,
		28,
		56,
		96,
		187,
		338,
		543,
		811,
		1151,
	},

	{
		0,
		0,
		30,
		73,
		131,
		207,
		323,
		503,
		723,
		995,
		1331,
		1851,
		2455,
		3154,
		3956,
		4904,
		6029,
		7697,
		9634,
		11860,
		14900,
		18888,
		24452,
		30724,
		37745,
		46859,
		58332,
		73622,
		90513,
		109083,
		132312,
		160671,
		197149,
		236865,
		279953,
		332370,
		394865,
		473025,
		557200,
		647604,
		755215,
		881130,
		1035071,
		1226852,
		1431203,
		1679555,
		1965767,
		2352138,
		2761933,
		3244025,
		3753621,
	},

	{
		0,
		0,
		144,
		328,
		612,
		960,
		1563,
		2450,
		3546,
		5144,
		7684,
		11360,
		15650,
		20596,
		27275,
		36767,
		49537,
		63881,
		79886,
		100528,
		127962,
		163070,
		201647,
		243853,
		296561,
		363532,
		446220,
		535764,
		632433,
		750254,
		895175,
		1069376,
		1256053,
		1455637,
		1694254,
		1980620,
		2317767,
		2676202,
		3056578,
		3504263,
		4031252,
		4641498,
		5286234,
		6079769,
		7001579,
		8108337,
		9369292,
		10856596,
		12414253,
		14404885,
		16488271,
	},
}

Amount of Job XP needed for each job level = [JobType][JobLevel]

View Source
var Preamble = strings.ReplaceAll(`
 ________  ________  _____ ______   ___  ___  ________     
|\   __  \|\   __  \|\   _ \  _   \|\  \|\  \|\   ___ \    
\ \  \|\  \ \  \|\  \ \  \\\__\ \  \ \  \\\  \ \  \_|\ \   
 \ \   _  _\ \  \\\  \ \  \\|__| \  \ \  \\\  \ \  \ \\ \  
  \ \  \\  \\ \  \\\  \ \  \    \ \  \ \  \\\  \ \  \_\\ \ 
   \ \__\\ _\\ \_______\ \__\    \ \__\ \_______\ \_______\
    \|__|\|__|\|_______|\|__|     \|__|\|_______|\|_______|
`, "\n", utils.NewLine)
View Source
var XPLookup = []int{
	0,
	0,
	9,
	25,
	50,
	86,
	163,
	275,
	428,
	628,
	881,
	1201,
	1586,
	2076,
	2661,
	3361,
	4191,
	5161,
	6281,
	7541,
	8961,
	10581,
	12441,
	14431,
	16671,
	19175,
	22125,
	25551,
	29485,
	33959,
	40848,
	48843,
	58017,
	68442,
	80190,
	94157,
	109932,
	127610,
	147287,
	169060,
	199603,
	233815,
	271880,
	313982,
	360305,
	413331,
	471750,
	535791,
	605683,
	681656,
	784124,
	899378,
	1028070,
	1170854,
	1328382,
	1506566,
	1702866,
	1918064,
	2152943,
	2408284,
	2738472,
	3104386,
	3507610,
	3949726,
	4432316,
	4969264,
	5554455,
	6189733,
	6876944,
	7617932,
	8543332,
	10017078,
	11611136,
	13330064,
	15178419,
	17160759,
	19390872,
	21777034,
	24324451,
	27038329,
	30244489,
	33925513,
	37947985,
	42325009,
	47069689,
	52195129,
	57962401,
	64166401,
	70821865,
	77943529,
	85546129,
	95284849,
	106934809,
	120578329,
	138917629,
	162754429,
	198412429,
	247099429,
	305234429,
	405234427,
}

Amount of XP needed for each level

Functions

func Colorize

func Colorize(color ANSIColor, a any) string

func ColorizeRainbow

func ColorizeRainbow(str string) string

func DoAdmin

func DoAdmin(e *Entity, w *World, tokens []string)

func DoAlias

func DoAlias(e *Entity, _ *World, tokens []string)

func DoAttack

func DoAttack(e *Entity, w *World, tokens []string)

func DoBuy

func DoBuy(e *Entity, w *World, tokens []string)

func DoChangeJob

func DoChangeJob(e *Entity, w *World, tokens []string)

func DoConsider

func DoConsider(e *Entity, w *World, tokens []string)

func DoDrop

func DoDrop(e *Entity, w *World, tokens []string)

func DoEquip

func DoEquip(e *Entity, w *World, tokens []string)

func DoEquipment

func DoEquipment(e *Entity, _ *World, _ []string)

func DoGet

func DoGet(e *Entity, w *World, tokens []string)

func DoGive

func DoGive(e *Entity, w *World, tokens []string)

func DoInventory

func DoInventory(e *Entity, _ *World, _ []string)

func DoLearnSkill

func DoLearnSkill(e *Entity, w *World, tokens []string)

func DoList

func DoList(e *Entity, w *World, tokens []string)

func DoListCommands

func DoListCommands(e *Entity, _ *World, _ []string)

func DoListJobs

func DoListJobs(e *Entity, w *World, tokens []string)

func DoListSkills

func DoListSkills(e *Entity, w *World, tokens []string)

func DoLook

func DoLook(e *Entity, w *World, tokens []string)

func DoMove

func DoMove(e *Entity, w *World, tokens []string)

func DoPracticeSkill

func DoPracticeSkill(e *Entity, w *World, tokens []string)

func DoPut

func DoPut(e *Entity, w *World, tokens []string)

func DoQuit

func DoQuit(e *Entity, w *World, _ []string)

func DoRaiseStat

func DoRaiseStat(e *Entity, w *World, tokens []string)

func DoSave

func DoSave(e *Entity, w *World, _ []string)

func DoSay

func DoSay(e *Entity, w *World, tokens []string)

func DoSell

func DoSell(e *Entity, w *World, tokens []string)

func DoSit

func DoSit(e *Entity, w *World, _ []string)

func DoSkill

func DoSkill(e *Entity, w *World, tokens []string)

func DoSleep

func DoSleep(e *Entity, w *World, _ []string)

func DoStand

func DoStand(e *Entity, w *World, _ []string)

func DoStatus

func DoStatus(e *Entity, w *World, tokens []string)

func DoTell

func DoTell(e *Entity, w *World, tokens []string)

func DoUnalias

func DoUnalias(e *Entity, _ *World, tokens []string)

func DoUnequip

func DoUnequip(e *Entity, w *World, tokens []string)

func DoUse

func DoUse(e *Entity, w *World, tokens []string)

func DoWake

func DoWake(e *Entity, w *World, _ []string)

func DoWho

func DoWho(e *Entity, w *World, _ []string)

func DoYell

func DoYell(e *Entity, w *World, tokens []string)

func GameLoop

func GameLoop(w *World, handler *SessionHandler)

func GetEquipmentSlotDescription

func GetEquipmentSlotDescription(slot EquipSlot) string

func GetJobXPForNextJobLevel

func GetJobXPForNextJobLevel(e *Entity) int

func GetPercentProgressToNextJobLevel

func GetPercentProgressToNextJobLevel(e *Entity) int

func GetPercentProgressToNextLevel

func GetPercentProgressToNextLevel(e *Entity) int

func GetXPForNextLevel

func GetXPForNextLevel(e *Entity) int

func GroupDescriptionsFromMap

func GroupDescriptionsFromMap[TKey comparable, TValue any](m map[TKey]TValue, filterFn func(TKey, TValue) bool, descFn func(TKey, TValue) string) []string

func GroupDescriptionsFromSlice

func GroupDescriptionsFromSlice[TValue any](s []TValue, filterFn func(TValue) bool, descFn func(TValue) string) []string

func IsMaxJobLevel

func IsMaxJobLevel(e *Entity) bool

func IsMaxLevel

func IsMaxLevel(e *Entity) bool

func IsReadyForJobLevelUp

func IsReadyForJobLevelUp(e *Entity) bool

func IsReadyForLevelUp

func IsReadyForLevelUp(e *Entity) bool

func LoadAssets

func LoadAssets(w *World, projectRoot string)

func ProcessCommand

func ProcessCommand(e *Entity, w *World, tokens []string) bool

func RegisterGlobalLuaBindings

func RegisterGlobalLuaBindings(L *lua.LState, w *World)

func RunScript

func RunScript(w *World, filePath string) error

func SearchList

func SearchList[TItem Matchable](query SearchQuery, items []TItem, filter func(TItem) bool) []TItem

func SearchMap

func SearchMap[TKey comparable, TItem Matchable](query SearchQuery, items map[TKey]TItem, filter func(TItem) bool) []TItem

Types

type ANSIColor

type ANSIColor string

type ActionFunc

type ActionFunc func(e *Entity, world *World, tokens []string)

type AdvantageType

type AdvantageType int

type ApplyStatusEffectConfig

type ApplyStatusEffectConfig struct {
	Type     StatusEffectMask
	Duration utils.Seconds
	Save     *SavingThrowConfig
}

type ArmorConfig

type ArmorConfig struct {
	Def  int
	MDef int
}

type AsyncCallback

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

type AttackConfig

type AttackConfig struct {
	Power Range
	Noun  string
	Range int
}

type CastingData

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

func (*CastingData) Valid

func (c *CastingData) Valid(e *Entity) bool

type CastingList

type CastingList struct {
	utils.List[*Entity]
}

func (*CastingList) EndCasting

func (c *CastingList) EndCasting(e *Entity)

func (*CastingList) StartCasting

func (c *CastingList) StartCasting(e *Entity, time utils.Seconds, target *Entity, skill *SkillConfig, level int) bool

type ChangeStateEvent

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

type CombatData

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

func (*CombatData) Valid

func (c *CombatData) Valid(e *Entity) bool

type CombatList

type CombatList struct {
	utils.List[*Entity]
}

func (*CombatList) EndCombat

func (c *CombatList) EndCombat(e *Entity)

func (*CombatList) StartCombat

func (c *CombatList) StartCombat(e *Entity, tgt *Entity, distance float64) bool

type CommandDesc

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

type CommandList

type CommandList []*CommandDesc
var Commands CommandList

type CommandMap

type CommandMap map[string]*CommandDesc
var CommandsLookup CommandMap

type Condition

type Condition int
const (
	Cnd_Dead Condition = iota
	Cnd_MortallyWounded
	Cnd_Incapacitated
	Cnd_Stunned
	Cnd_Healthy
)

func (Condition) InactionString

func (c Condition) InactionString() string

type DamageContext

type DamageContext int
const (
	DamCtx_Melee DamageContext = iota
	DamCtx_Bleeding
	DamCtx_Poison
	DamCtx_Skill
	DamCtx_Admin DamageContext = 999
)

type Database

type Database interface {
	DoesPlayerExist(id string) bool
	SavePlayer(id string, data *PlayerCharacterData) error
	LoadPlayer(id string) (*PlayerCharacterData, error)
}

type DeathMode

type DeathMode int
const (
	Death_Instant DeathMode = iota
	Death_Prolonged
)

func ParseDeathMode

func ParseDeathMode(str string) (DeathMode, error)

func (*DeathMode) UnmarshalJSON

func (d *DeathMode) UnmarshalJSON(data []byte) (err error)

type DeathMudConfig

type DeathMudConfig struct {
	Mode     DeathMode
	Players  *EntityTypeDeathConfig
	Monsters *EntityTypeDeathConfig
}

type Descriptive

type Descriptive interface {
	Describe() string
}

type Dice

type Dice struct {
	Num   uint
	Sides uint
	Plus  int
}

func NewDice

func NewDice(num uint, sides uint, plus int) Dice

func ParseDice

func ParseDice(s string) (Dice, error)

func (*Dice) Add

func (d *Dice) Add(num int) Dice

func (*Dice) Average

func (d *Dice) Average() int

func (*Dice) CriticalRoll

func (d *Dice) CriticalRoll() int

func (*Dice) IsZero

func (d *Dice) IsZero() bool

func (*Dice) MarshalJSON

func (d *Dice) MarshalJSON() ([]byte, error)

func (*Dice) Roll

func (d *Dice) Roll() int

func (*Dice) String

func (d *Dice) String() string

func (*Dice) StringColorized

func (d *Dice) StringColorized(color ANSIColor) string

func (*Dice) UnmarshalJSON

func (d *Dice) UnmarshalJSON(data []byte) (err error)

type Direction

type Direction int
const (
	DirNorth Direction = iota
	DirEast
	DirSouth
	DirWest
	DirUp
	DirDown
)

func ParseDirection

func ParseDirection(s string) (Direction, error)

func (*Direction) Reverse

func (d *Direction) Reverse() (Direction, error)

func (*Direction) String

func (d *Direction) String() string

type Element

type Element int
const (
	Neutral Element = iota
	Water
	Earth
	Fire
	Wind
	Poison
	Holy
	Shadow
	Ghost
	Undead
)

func ParseElement

func ParseElement(str string) (Element, error)

func (*Element) String

func (e *Element) String() string

type Entity

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

func NewEntity

func NewEntity(cfg *EntityConfig) *Entity

func SearchEntities

func SearchEntities(query SearchQuery, self *Entity, containers ...EntityContainer) []*Entity

func TryGetEntityByName

func TryGetEntityByName(name string, ents map[EntityId]*Entity) (*Entity, bool)

func (*Entity) AddItem

func (e *Entity) AddItem(item *Item)

func (*Entity) AddStatusEffect

func (e *Entity) AddStatusEffect(statusType StatusEffectMask, duration utils.Seconds) bool

func (*Entity) AllItems

func (e *Entity) AllItems() []*Item

func (*Entity) CanBeSeenBy

func (e *Entity) CanBeSeenBy(viewer *Entity) bool

func (*Entity) CanSee

func (e *Entity) CanSee() bool

func (*Entity) Describe

func (e *Entity) Describe() string

func (*Entity) DescribeEquipment

func (e *Entity) DescribeEquipment() string

func (*Entity) DescribeInventory

func (e *Entity) DescribeInventory() string

func (*Entity) DescribeStatus

func (e *Entity) DescribeStatus() string

func (*Entity) DescribeStatusEffects

func (e *Entity) DescribeStatusEffects() string

func (*Entity) Equip

func (e *Entity) Equip(item *Item) (EquipSlot, []*Item, bool)

func (*Entity) Gender

func (e *Entity) Gender() Gender

func (*Entity) GetName

func (e *Entity) GetName() string

func (*Entity) GetNameCapitalized

func (e *Entity) GetNameCapitalized() string

func (*Entity) GetNamePluralized

func (e *Entity) GetNamePluralized(count int, includeCount bool) string

func (*Entity) GetWeapon

func (e *Entity) GetWeapon() (*WeaponConfig, *EquipmentConfig, bool)

func (*Entity) HasStatusEffect

func (e *Entity) HasStatusEffect(status StatusEffectMask) bool

func (*Entity) IsEnemyOf

func (e *Entity) IsEnemyOf(e2 *Entity) bool

func (*Entity) ItemWeight

func (e *Entity) ItemWeight() int

func (*Entity) MatchesKeyword

func (e *Entity) MatchesKeyword(keyword string) bool

func (*Entity) RemoveItem

func (e *Entity) RemoveItem(item *Item)

func (*Entity) RemoveStatusEffect

func (e *Entity) RemoveStatusEffect(statusType StatusEffectMask, permanent bool) bool

func (*Entity) RoomId

func (e *Entity) RoomId() RoomId

func (*Entity) SearchItems

func (e *Entity) SearchItems(query SearchQuery) []*Item

func (*Entity) SetData

func (e *Entity) SetData(data *EntityData, w *World)

func (*Entity) SkillTriggers

func (e *Entity) SkillTriggers(state EntityState) []*SkillTriggerConfig

func (*Entity) State

func (e *Entity) State() EntityState

func (*Entity) Unequip

func (e *Entity) Unequip(item *Item) bool

type EntityConfig

type EntityConfig struct {
	Key           string
	Name          string
	Gender        Gender
	Keywords      []string
	RoomDesc      string
	FullDesc      string
	DropTable     *utils.ChanceTable[string]
	Stats         *StatsConfig
	Attack        *AttackConfig
	SkillTriggers map[EntityState][]*SkillTriggerConfig
	Flags         EntityFlagMask
	// contains filtered or unexported fields
}

func (*EntityConfig) Init

func (cfg *EntityConfig) Init()

type EntityConfigList

type EntityConfigList []*EntityConfig

type EntityContainer

type EntityContainer interface {
	AddEntity(entity *Entity)
	SearchEntities(query SearchQuery) []*Entity
	AllEntities() []*Entity
	RemoveEntity(entity *Entity)
}

type EntityData

type EntityData struct {
	Key       string
	RoomId    RoomId           `json:",omitempty"`
	Job       *JobData         `json:",omitempty"`
	Skills    *SkillsData      `json:",omitempty"`
	Stats     StatMap          `json:",omitempty"`
	Inventory []*ItemData      `json:",omitempty"`
	Equipped  EquipmentDataMap `json:",omitempty"`
	Statuses  StatusDataMap    `json:",omitempty"`
}

type EntityFlagMask

type EntityFlagMask bits.Bits
const (
	EFlag_Stationary      EntityFlagMask = 1 << iota // Cannot move
	EFlag_Scavenger                                  // Pick up items on the ground
	EFlag_UsesEquipment                              // Can use equipment
	EFlag_Blind                                      // Cannot see
	EFlag_Invisible                                  // Cannot be seen
	EFlag_Aggro                                      // Attacks enemies on sight
	EFlag_AssistAll                                  // Assist all mobs who are being fought by players
	EFlag_AssistSame                                 // Assist mobs of the same type who are being fought by players
	EFlag_CanLeaveZone                               // Will wander out of initial zone
	EFlag_Pacifist                                   // Won't attack
	EFlag_Uninterruptable                            // Skills can't be interrupted
	EFlag_Detector                                   // Can detect hidden entities	// TODO: EFlags: Implement
	EFlag_Talks                                      // Can talk
)

func ParseEntityFlag

func ParseEntityFlag(str string) (EntityFlagMask, error)

func (*EntityFlagMask) Has

func (m *EntityFlagMask) Has(flag EntityFlagMask) bool

func (*EntityFlagMask) MarshalJSON

func (m *EntityFlagMask) MarshalJSON() ([]byte, error)

func (*EntityFlagMask) String

func (m *EntityFlagMask) String() string

func (*EntityFlagMask) Strings

func (m *EntityFlagMask) Strings() []string

func (*EntityFlagMask) UnmarshalJSON

func (m *EntityFlagMask) UnmarshalJSON(data []byte) (err error)

type EntityId

type EntityId int

type EntityList

type EntityList []*Entity

type EntityScripts

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

func NewEntityScripts

func NewEntityScripts(L *lua.LState, tbl *lua.LTable) *EntityScripts

type EntityState

type EntityState int
const (
	EState_Idle EntityState = iota
	EState_Combat
)

func ParseEntityState

func ParseEntityState(str string) (EntityState, error)

type EntityTypeDeathConfig

type EntityTypeDeathConfig struct {
	Corpses bool
	Items   ItemsOnDeath
}

type EquipSlot

type EquipSlot bits.Bits
const (
	EqSlot_None EquipSlot = 1 << iota

	// Slot flags
	EqSlot_Head_High
	EqSlot_Head_Mid
	EqSlot_Head_Low
	EqSlot_Garment
	EqSlot_Armor
	EqSlot_Feet
	EqSlot_Accessory_1
	EqSlot_Accessory_2
	EqSlot_Held_L
	EqSlot_Held_R

	// Special flags
	EqSlot_Accessory
	EqSlot_Held_1H
	EqSlot_Held_2H = EqSlot_Held_L | EqSlot_Held_R
)

func ParseEquipSlot

func ParseEquipSlot(str string) (EquipSlot, error)

func (*EquipSlot) Has

func (s *EquipSlot) Has(flag EquipSlot) bool

func (*EquipSlot) MarshalJSON

func (s *EquipSlot) MarshalJSON() ([]byte, error)

func (*EquipSlot) String

func (s *EquipSlot) String() string

type EquipmentConfig

type EquipmentConfig struct {
	Slot          EquipSlot
	Stats         StatMap
	StatusEffect  StatusEffectMask
	Armor         *ArmorConfig
	Weapon        *WeaponConfig
	RequiredLevel int
	Upgradable    bool
}

type EquipmentDataMap

type EquipmentDataMap map[EquipSlot]*ItemData

func (*EquipmentDataMap) MarshalJSON

func (m *EquipmentDataMap) MarshalJSON() ([]byte, error)

func (*EquipmentDataMap) UnmarshalJSON

func (m *EquipmentDataMap) UnmarshalJSON(data []byte) (err error)

type FileSystemDatabase

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

func NewFileSystemDatabase

func NewFileSystemDatabase(path string) *FileSystemDatabase

func (*FileSystemDatabase) DoesPlayerExist

func (db *FileSystemDatabase) DoesPlayerExist(id string) bool

func (*FileSystemDatabase) LoadPlayer

func (db *FileSystemDatabase) LoadPlayer(id string) (*PlayerCharacterData, error)

func (*FileSystemDatabase) SavePlayer

func (db *FileSystemDatabase) SavePlayer(id string, data *PlayerCharacterData) error

type GameState

type GameState interface {
	StateId() StateId

	OnEnter()
	ProcessInput(input string) StateId
	OnExit()
}

type Gender

type Gender uint8
const (
	NonGendered Gender = iota
	Male
	Female
	Other
)

func (Gender) GetObjectPronoun

func (g Gender) GetObjectPronoun() string

func (Gender) GetPossessivePronoun

func (g Gender) GetPossessivePronoun() string

type Item

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

func NewItem

func NewItem(cfg *ItemConfig) *Item

func SearchItems

func SearchItems(query SearchQuery, containers ...ItemContainer) []*Item

func (*Item) AddItem

func (i *Item) AddItem(i2 *Item)

func (*Item) AllItems

func (i *Item) AllItems() []*Item

func (*Item) CanBeSeenBy

func (i *Item) CanBeSeenBy(viewer *Entity) bool

func (*Item) Describe

func (i *Item) Describe() string

func (*Item) DescribeContents

func (i *Item) DescribeContents() string

func (*Item) GetName

func (i *Item) GetName() string

func (*Item) GetNameCapitalized

func (i *Item) GetNameCapitalized() string

func (*Item) GetNamePluralized

func (i *Item) GetNamePluralized(count int, includeCount bool) string

func (*Item) ItemWeight

func (i *Item) ItemWeight() int

func (*Item) MatchesKeyword

func (i *Item) MatchesKeyword(keyword string) bool

func (*Item) RemoveAllFromContainer

func (i *Item) RemoveAllFromContainer() ItemList

func (*Item) RemoveItem

func (i *Item) RemoveItem(item *Item)

func (*Item) RoomId

func (i *Item) RoomId() RoomId

func (*Item) SearchItems

func (i *Item) SearchItems(query SearchQuery) []*Item

func (*Item) SetData

func (i *Item) SetData(data *ItemData, w *World)

func (*Item) Value

func (i *Item) Value() int

type ItemConfig

type ItemConfig struct {
	Key        string
	Name       string
	NamePlural string
	Keywords   []string
	RoomDesc   string
	FullDesc   string
	Flags      ItemFlagMask
	Equipment  *EquipmentConfig
	BuyPrice   int
	SellPrice  int
	Weight     int
	// contains filtered or unexported fields
}

func (*ItemConfig) GetName

func (cfg *ItemConfig) GetName() string

func (*ItemConfig) GetNameCapitalized

func (cfg *ItemConfig) GetNameCapitalized() string

func (*ItemConfig) GetNamePluralized

func (cfg *ItemConfig) GetNamePluralized(count int, includeCount bool) string

func (*ItemConfig) Init

func (cfg *ItemConfig) Init()

func (*ItemConfig) MatchesKeyword

func (cfg *ItemConfig) MatchesKeyword(keyword string) bool

func (*ItemConfig) Stackable

func (cfg *ItemConfig) Stackable() bool

type ItemConfigList

type ItemConfigList []*ItemConfig

type ItemContainer

type ItemContainer interface {
	AddItem(item *Item)
	SearchItems(query SearchQuery) []*Item
	AllItems() []*Item
	ItemWeight() int
	RemoveItem(item *Item)
}

type ItemData

type ItemData struct {
	Key      string
	RoomId   RoomId      `json:",omitempty"`
	Contents []*ItemData `json:",omitempty"`
}

type ItemFlagMask

type ItemFlagMask bits.Bits
const (
	IFlag_Container     ItemFlagMask = 1 << iota // Can contain other items
	IFlag_NoStorage                              // Cannot be used for storage (i.e. can't add contents to them)
	IFlag_Light                                  // Light the room that they're in
	IFlag_Environmental                          // Can't be picked up
	IFlag_Crumbles                               // Crumble when picked up
	IFlag_Usable                                 // Item can be used ('use' command)
	IFlag_Consumable                             // Item is consumed when used
)

func ParseItemFlag

func ParseItemFlag(str string) (ItemFlagMask, error)

func (*ItemFlagMask) Has

func (m *ItemFlagMask) Has(flag ItemFlagMask) bool

func (*ItemFlagMask) MarshalJSON

func (m *ItemFlagMask) MarshalJSON() ([]byte, error)

func (*ItemFlagMask) String

func (m *ItemFlagMask) String() string

func (*ItemFlagMask) UnmarshalJSON

func (m *ItemFlagMask) UnmarshalJSON(data []byte) (err error)

type ItemId

type ItemId int32

type ItemList

type ItemList []*Item

type ItemScripts

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

func NewItemScripts

func NewItemScripts(L *lua.LState, tbl *lua.LTable) *ItemScripts

type ItemsOnDeath

type ItemsOnDeath int
const (
	ItemsOnDeath_Drop ItemsOnDeath = iota
	ItemsOnDeath_Destroy
	ItemsOnDeath_Retain
)

func ParseItemsOnDeath

func ParseItemsOnDeath(str string) (ItemsOnDeath, error)

func (*ItemsOnDeath) UnmarshalJSON

func (d *ItemsOnDeath) UnmarshalJSON(data []byte) (err error)

type Job

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

func (*Job) CanLearnSkill

func (j *Job) CanLearnSkill(skey string) bool

type JobBonusStat

type JobBonusStat struct {
	Level int
	Stat  StatType
}

type JobConfig

type JobConfig struct {
	Name                string
	JobType             JobTypeMask
	JobTier             JobTier
	Base                JobTypeMask
	AspdBase            map[WeaponType]int
	MaxHPMod            float64
	MaxSPMod            float64
	CarryingCapacityMod int
	BonusStats          []JobBonusStat
	// contains filtered or unexported fields
}

func (*JobConfig) Init

func (cfg *JobConfig) Init()

func (*JobConfig) IsJobTypeOrAncestor

func (cfg *JobConfig) IsJobTypeOrAncestor(jobType JobTypeMask) bool

type JobData

type JobData struct {
	JobType JobTypeMask
}

type JobTier

type JobTier int
const (
	JobTier_Novice JobTier = iota
	JobTier_First
	JobTier_Second
)

func ParseJobTier

func ParseJobTier(str string) (JobTier, error)

type JobTypeMask

type JobTypeMask bits.Bits
const (
	JobType_Novice JobTypeMask = 1 << iota
	JobType_Swordman
	JobType_Mage
	JobType_Archer
	JobType_Merchant
	JobType_Thief
	JobType_Acolyte
	JobType_Knight
	JobType_Crusader
	JobType_Wizard
	JobType_Sage
	JobType_Hunter
	JobType_Bard
	JobType_Dancer
	JobType_Blacksmith
	JobType_Alchemist
	JobType_Assassin
	JobType_Rogue
	JobType_Priest
	JobType_Monk
	JobType_Num
	JobType_All
)

func ParseJobTypeMask

func ParseJobTypeMask(str string) (JobTypeMask, error)

func (*JobTypeMask) MarshalJSON

func (jt *JobTypeMask) MarshalJSON() ([]byte, error)

func (*JobTypeMask) String

func (jt *JobTypeMask) String() string

func (*JobTypeMask) UnmarshalJSON

func (jt *JobTypeMask) UnmarshalJSON(data []byte) (err error)

type JobsMudConfig

type JobsMudConfig struct {
	IgnoreJobRequirements bool
}

type LearnedSkill

type LearnedSkill struct {
	Key   string
	Level int
	// contains filtered or unexported fields
}

type LoggedOutState

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

func (*LoggedOutState) OnEnter

func (s *LoggedOutState) OnEnter()

func (*LoggedOutState) OnExit

func (s *LoggedOutState) OnExit()

func (*LoggedOutState) ProcessInput

func (s *LoggedOutState) ProcessInput(_ string) StateId

func (*LoggedOutState) StateId

func (s *LoggedOutState) StateId() StateId

type LoginState

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

func (*LoginState) OnEnter

func (s *LoginState) OnEnter()

func (*LoginState) OnExit

func (s *LoginState) OnExit()

func (*LoginState) ProcessInput

func (s *LoginState) ProcessInput(input string) StateId

func (*LoginState) StateId

func (s *LoginState) StateId() StateId

type LoginSubState

type LoginSubState int
const (
	LSS_EnterName LoginSubState = iota
	LSS_NewUserConfName
	LSS_NewUserEnterPass
	LSS_NewUserConfPass
	LSS_RetUserEnterPass
	LSS_SelectInitialStats
	LSS_ConfirmInitialStats
)

type Matchable

type Matchable interface {
	MatchesKeyword(keyword string) bool
}

type MudConfig

type MudConfig struct {
	ConfigRoot                   string
	Death                        *DeathMudConfig
	Jobs                         *JobsMudConfig
	Skills                       *SkillsMudConfig
	ItemDropRateMultiplier       float64
	XPRateMultiplier             float64
	JobXPRateMultiplier          float64
	GameSpeedMultiplier          float64
	LootOwnershipDurationSeconds float64
	LuaAPIFile                   string // (Optional) dot delimeted file path to Lua API script
}

type Named

type Named interface {
	GetName() string
	GetNameCapitalized() string
	GetNamePluralized(count int, includeCount bool) string
}

type NamedObservable

type NamedObservable interface {
	Observable
	Named
}

type NounConfig

type NounConfig struct {
	Singular string
	Plural   string
}

type Observable

type Observable interface {
	CanBeSeenBy(observer *Entity) bool
}

type ObservableDescriptor

type ObservableDescriptor interface {
	Desc(observer *Entity) string
}

func ObservableNameCap

func ObservableNameCap(o NamedObservable) ObservableDescriptor

type ObservableNameDescriptor

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

func (ObservableNameDescriptor) Desc

func (d ObservableNameDescriptor) Desc(observer *Entity) string

type Ownership

type Ownership struct {
	OwnerId EntityId
	Until   time.Time
}

func (Ownership) Valid

func (o Ownership) Valid() bool

type Player

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

func NewPlayer

func NewPlayer(session *server.Session) *Player

func (*Player) Send

func (p *Player) Send(format string, a ...any)

func (*Player) SendRaw

func (p *Player) SendRaw(bytes []byte)

func (*Player) SetData

func (p *Player) SetData(data *PlayerData)

type PlayerCharacterData

type PlayerCharacterData struct {
	Player    *PlayerData
	Character *EntityData
}

type PlayerData

type PlayerData struct {
	Name        string
	Pass        string
	Gender      Gender
	LastSavedAt time.Time
	Aliases     map[string]string
}

type PlayerId

type PlayerId int32

type PlayerPromptProvider

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

func (*PlayerPromptProvider) Prompt

func (pp *PlayerPromptProvider) Prompt() string

type PlayerSessionData

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

type PlayingState

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

func (*PlayingState) OnEnter

func (s *PlayingState) OnEnter()

func (*PlayingState) OnExit

func (s *PlayingState) OnExit()

func (*PlayingState) ProcessInput

func (s *PlayingState) ProcessInput(input string) StateId

func (*PlayingState) StateId

func (s *PlayingState) StateId() StateId

type Position

type Position int
const (
	Pos_Sleeping Position = iota
	Pos_Prone
	Pos_Sitting
	Pos_Standing
)

func (Position) InactionString

func (p Position) InactionString() string

type Race

type Race int
const (
	Race_DemiHuman Race = iota
	Race_Brute
	Race_Insect
	Race_Fish
	Race_Dragon
	Race_Plant
	Race_Formless
	Race_Angel
	Race_Demon
	Race_Undead
)

func ParseRace

func ParseRace(str string) (Race, error)

type Range

type Range struct {
	Min int
	Max int
}

func NewRange

func NewRange(min int, max int) Range

func ParseRange

func ParseRange(s string) (Range, error)

func (*Range) Average

func (r *Range) Average() int

func (*Range) Random

func (r *Range) Random() int

func (*Range) String

func (r *Range) String() string

func (*Range) StringColorized

func (r *Range) StringColorized(color ANSIColor) string

func (*Range) UnmarshalJSON

func (r *Range) UnmarshalJSON(data []byte) (err error)

type Room

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

func NewRoom

func NewRoom(cfg *RoomConfig, zoneId ZoneId) (*Room, error)

func (*Room) AddEntity

func (r *Room) AddEntity(e *Entity)

func (*Room) AddItem

func (r *Room) AddItem(i *Item)

func (*Room) AllEntities

func (r *Room) AllEntities() []*Entity

func (*Room) AllItems

func (r *Room) AllItems() []*Item

func (*Room) Describe

func (r *Room) Describe(subject *Entity) string

func (*Room) GetName

func (r *Room) GetName() string

func (*Room) GetNameCapitalized

func (r *Room) GetNameCapitalized() string

func (*Room) GetNamePluralized

func (r *Room) GetNamePluralized(count int, includeCount bool) string

func (*Room) IsExitOpen

func (r *Room) IsExitOpen(dir Direction) bool

func (*Room) ItemWeight

func (r *Room) ItemWeight() int

func (*Room) RemoveEntity

func (r *Room) RemoveEntity(e *Entity)

func (*Room) RemoveItem

func (r *Room) RemoveItem(i *Item)

func (*Room) SearchEntities

func (r *Room) SearchEntities(query SearchQuery) []*Entity

func (*Room) SearchItems

func (r *Room) SearchItems(query SearchQuery) []*Item

type RoomConfig

type RoomConfig struct {
	Id    RoomId
	Name  string
	Desc  string
	Exits RoomExitsConfig
}

type RoomConfigList

type RoomConfigList []*RoomConfig

type RoomExitConfig

type RoomExitConfig struct {
	RoomId RoomId
	Verb   Direction
}

type RoomExitsConfig

type RoomExitsConfig map[Direction]RoomId

type RoomId

type RoomId int32

type RoomPresence

type RoomPresence interface {
	RoomId() RoomId
}

type SavingThrowConfig

type SavingThrowConfig struct {
	Stat StatType
	DC   int
}

type SearchQuery

type SearchQuery struct {
	Keyword string
	Index   int
	Count   int
}

func NewSearchQuery

func NewSearchQuery(keyword string, count int) SearchQuery

func (SearchQuery) IsEmpty

func (s SearchQuery) IsEmpty() bool

type SendBuilder

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

func Write

func Write(format string, args ...any) *SendBuilder

func (*SendBuilder) Colorized

func (b *SendBuilder) Colorized(c ANSIColor) *SendBuilder

func (*SendBuilder) Ignore

func (b *SendBuilder) Ignore(e *Entity) *SendBuilder

func (*SendBuilder) Restricted

func (b *SendBuilder) Restricted(r SendRestrictionsMask) *SendBuilder

func (*SendBuilder) Send

func (b *SendBuilder) Send()

func (*SendBuilder) Subject

func (b *SendBuilder) Subject(s NamedObservable) *SendBuilder

func (*SendBuilder) ToEntityRoom

func (b *SendBuilder) ToEntityRoom(w *World, e *Entity) *SendBuilder

func (*SendBuilder) ToPlayer

func (b *SendBuilder) ToPlayer(e *Entity) *SendBuilder

func (*SendBuilder) ToRoom

func (b *SendBuilder) ToRoom(r *Room) *SendBuilder

func (*SendBuilder) ToWorld

func (b *SendBuilder) ToWorld(w *World) *SendBuilder

type SendDestination

type SendDestination interface {
	Send(b *SendBuilder)
}

type SendDestinationPlayer

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

func (SendDestinationPlayer) Send

type SendDestinationRoom

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

func (SendDestinationRoom) Send

func (d SendDestinationRoom) Send(b *SendBuilder)

type SendDestinationWorld

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

func (SendDestinationWorld) Send

func (d SendDestinationWorld) Send(b *SendBuilder)

type SendRestrictionsMask

type SendRestrictionsMask bits.Bits
const (
	SendRst_None   SendRestrictionsMask = 0
	SendRst_CanSee SendRestrictionsMask = 1 << iota
)

func (*SendRestrictionsMask) Has

type SessionHandler

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

func NewSessionHandler

func NewSessionHandler(world *World, events <-chan server.SessionEvent) *SessionHandler

func (*SessionHandler) ChangeGameState

func (s *SessionHandler) ChangeGameState(sid server.SessionId, id StateId)

func (*SessionHandler) HandleEvent

func (s *SessionHandler) HandleEvent(sessionEvt server.SessionEvent)

type SessionHandlerSystem

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

func (*SessionHandlerSystem) Update

func (s *SessionHandlerSystem) Update(w *World, dt utils.Seconds)

type Shop

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

func NewShop

func NewShop(cfg *ShopConfig) *Shop

func (*Shop) Init

func (s *Shop) Init(w *World)

type ShopConfig

type ShopConfig struct {
	RoomId RoomId
	Stock  []string
}

type Size

type Size int
const (
	Size_Small Size = iota
	Size_Medium
	Size_Large
)

func ParseSize

func ParseSize(str string) (Size, error)

type SkillAttack

type SkillAttack struct {
	AtkType   SkillAttackType // Type of attack (weapon, mag)
	AtkBonus  float64         // Attack multiplier
	MAtkBonus float64         // Magic Attack multiplier
	HitBonus  float64         // Hit multiplier
	Element   Element         // Element of attack
	Delay     utils.Seconds   // Delay until attack triggers
	// contains filtered or unexported fields
}

type SkillAttackType

type SkillAttackType int
const (
	SkillAttackType_Physical SkillAttackType = iota
	SkillAttackType_Magic
)

func ParseSkillAttackType

func ParseSkillAttackType(str string) (SkillAttackType, error)

func (*SkillAttackType) String

func (dt *SkillAttackType) String() string

type SkillConfig

type SkillConfig struct {
	Key        string
	Name       string
	Type       SkillType
	TargetType SkillTargetType
	Range      int
	CastTimes  []utils.Seconds
	CastDelays []utils.Seconds
	SPCosts    []int
	MaxLevel   int
	Job        JobTypeMask
	PreReqs    *SkillPreReqs
	Desc       string
	// contains filtered or unexported fields
}

func (*SkillConfig) CastDelay

func (cfg *SkillConfig) CastDelay(level int) utils.Seconds

func (*SkillConfig) CastTime

func (cfg *SkillConfig) CastTime(level int) utils.Seconds

func (*SkillConfig) SPCost

func (cfg *SkillConfig) SPCost(level int) int

func (*SkillConfig) SelectableLevel

func (cfg *SkillConfig) SelectableLevel() bool

type SkillPreReqs

type SkillPreReqs struct {
	Key   string
	Level int
}

type SkillScripts

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

func NewSkillScripts

func NewSkillScripts(L *lua.LState, tbl *lua.LTable) *SkillScripts

type SkillTargetType

type SkillTargetType int
const (
	SkillTargetType_None SkillTargetType = iota
	SkillTargetType_Self
	SkillTargetType_Single_Ally
	SkillTargetType_Single_Enemy
	SkillTargetType_Single_Entity
	SkillTargetType_All_Enemies
)

func ParseSkillTargetType

func ParseSkillTargetType(str string) (SkillTargetType, error)

func (*SkillTargetType) String

func (s *SkillTargetType) String() string

type SkillTriggerConfig

type SkillTriggerConfig struct {
	Key          string
	Level        int
	Chance       float64
	MaxHpPercent float64
}

type SkillType

type SkillType int
const (
	SkillType_Passive SkillType = iota
	SkillType_Active
	SkillType_Offensive
)

func ParseSkillType

func ParseSkillType(str string) (SkillType, error)

func (*SkillType) String

func (s *SkillType) String() string

type Skills

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

func (*Skills) KnowsSkill

func (s *Skills) KnowsSkill(key string) bool

func (*Skills) Learn

func (s *Skills) Learn(key string)

func (*Skills) LevelUp

func (s *Skills) LevelUp(key string)

func (*Skills) SetData

func (s *Skills) SetData(data *SkillsData)

func (*Skills) SkillLevel

func (s *Skills) SkillLevel(key string) int

func (*Skills) SkillMastered

func (s *Skills) SkillMastered(key string) bool

type SkillsData

type SkillsData struct {
	Learned []*LearnedSkill
}

type SkillsMudConfig

type SkillsMudConfig struct {
	IgnorePreRequirements bool
	IgnoreJobRequirements bool
	IgnorePoints          bool
	AllowCastUnlearned    bool
	AllowCastAnyLevel     bool
}

type SpawnerType

type SpawnerType int
const (
	Spawner_Entity SpawnerType = iota
	Spawner_Item
)

func ParseSpawnerType

func ParseSpawnerType(str string) (SpawnerType, error)

type Speed

type Speed int
const (
	Speed_Immovable Speed = iota
	Speed_Very_Slow
	Speed_Slow
	Speed_Fast
	Speed_Very_Fast
)

func ParseSpeed

func ParseSpeed(str string) (Speed, error)

type StatMap

type StatMap map[StatType]int

func (*StatMap) MarshalJSON

func (m *StatMap) MarshalJSON() ([]byte, error)

func (*StatMap) UnmarshalJSON

func (m *StatMap) UnmarshalJSON(data []byte) (err error)

type StatType

type StatType int
const (
	Stat_HP StatType = iota
	Stat_MaxHP
	Stat_SP
	Stat_MaxSP
	Stat_Mov
	Stat_MaxMov
	Stat_Str
	Stat_Agi
	Stat_Vit
	Stat_Int
	Stat_Dex
	Stat_Luk
	Stat_Level
	Stat_XP
	Stat_JobLevel
	Stat_JobXP
	Stat_StatPoints
	Stat_SkillPoints
	Stat_Gold

	Stat_Num
)

func ParseStatType

func ParseStatType(str string) (StatType, error)

func (*StatType) MarshalJSON

func (s *StatType) MarshalJSON() ([]byte, error)

func (*StatType) String

func (s *StatType) String() string

func (*StatType) UnmarshalJSON

func (s *StatType) UnmarshalJSON(data []byte) (err error)

type StateId

type StateId int
const (
	GameState_None StateId = iota
	GameState_LoggedOut
	GameState_LoggingIn
	GameState_Playing
)

type Stats

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

func (*Stats) Add

func (s *Stats) Add(stat StatType, delta int)

func (*Stats) AddMod

func (s *Stats) AddMod(stat StatType, mod int)

func (*Stats) Condition

func (s *Stats) Condition() Condition

func (*Stats) ConditionLongString

func (s *Stats) ConditionLongString(e *Entity) string

func (*Stats) ConditionShortString

func (s *Stats) ConditionShortString() string

func (*Stats) Diff

func (s *Stats) Diff(other map[StatType]int) map[StatType]int

func (*Stats) Get

func (s *Stats) Get(stat StatType) int

func (*Stats) GetFloat

func (s *Stats) GetFloat(stat StatType) float64

func (*Stats) MaxStatType

func (s *Stats) MaxStatType(stats ...StatType) StatType

func (*Stats) RemoveMod

func (s *Stats) RemoveMod(stat StatType, mod int)

func (*Stats) Set

func (s *Stats) Set(stat StatType, val int)

func (*Stats) Snapshot

func (s *Stats) Snapshot() map[StatType]int

type StatsConfig

type StatsConfig struct {
	HP           int
	Size         Size
	Speed        Speed
	Element      Element
	ElementLevel int
	Race         Race
	Mov          int
	Str          int
	Agi          int
	Vit          int
	Int          int
	Dex          int
	Luk          int
	Level        int
	Hit100       int // Monster Only: HIT value required for making 100% chance hit on monster
	Flee95       int // Monster Only: FLEE value required for making 95% chance dodge on monster
	XPValue      int
	JobXPValue   int
}

type StatusDataMap

type StatusDataMap map[StatusEffectMask]*StatusEffectData

func (*StatusDataMap) MarshalJSON

func (m *StatusDataMap) MarshalJSON() ([]byte, error)

func (*StatusDataMap) UnmarshalJSON

func (m *StatusDataMap) UnmarshalJSON(data []byte) (err error)

type StatusEffect

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

type StatusEffectConfig

type StatusEffectConfig struct {
	EntityFlags EntityFlagMask
}

type StatusEffectConfigBuilder

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

func NewStatusEffectConfigBuilder

func NewStatusEffectConfigBuilder() *StatusEffectConfigBuilder

func (*StatusEffectConfigBuilder) Build

func (*StatusEffectConfigBuilder) WithEntityFlag

type StatusEffectData

type StatusEffectData struct {
	Duration utils.Seconds `json:",omitempty"`
}

type StatusEffectDuration

type StatusEffectDuration int

type StatusEffectMask

type StatusEffectMask bits.Bits
const (
	// TODO Implement
	StatusType_Poison StatusEffectMask = 1 << iota
	StatusType_Blind
	StatusType_Invisible
)

func ParseStatusEffectType

func ParseStatusEffectType(str string) (StatusEffectMask, error)

func (*StatusEffectMask) Has

func (m *StatusEffectMask) Has(status StatusEffectMask) bool

func (*StatusEffectMask) MarshalJSON

func (m *StatusEffectMask) MarshalJSON() ([]byte, error)

func (*StatusEffectMask) String

func (m *StatusEffectMask) String() string

func (*StatusEffectMask) UnmarshalJSON

func (m *StatusEffectMask) UnmarshalJSON(data []byte) (err error)

type StatusEffects

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

type System

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

func (*System) Update

func (s *System) Update(w *World, dt utils.Seconds)

type SystemUpdater

type SystemUpdater interface {
	Update(w *World, dt utils.Seconds)
}

type UpdateSystem

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

func (*UpdateSystem) Update

func (s *UpdateSystem) Update(w *World, _ utils.Seconds)

type Vocab

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

func NewVocab

func NewVocab() *Vocab

func (*Vocab) GetNoun

func (v *Vocab) GetNoun(key string) *NounConfig

type WeaponConfig

type WeaponConfig struct {
	Type      WeaponType
	Atk       int
	MAtkBonus float64
	Element   Element
	Level     int
	Noun      string
	Range     int
}

type WeaponType

type WeaponType int
const (
	WeaponType_Fist WeaponType = iota
	WeaponType_Dagger
	WeaponType_Sword_1H
	WeaponType_Sword_2H
	WeaponType_Spear_1H
	WeaponType_Spear_2H
	WeaponType_Axe_1H
	WeaponType_Axe_2H
	WeaponType_Mace_1H
	WeaponType_Mace_2H
	WeaponType_Staff_1H
	WeaponType_Staff_2H
	WeaponType_Bow
	WeaponType_Knuckle
	WeaponType_Musical
	WeaponType_Whip
	WeaponType_Book
	WeaponType_Katar
	WeaponType_Gun
	WeaponType_Huuma_Shuriken
)

func ParseWeaponType

func ParseWeaponType(str string) (WeaponType, error)

func (WeaponType) Ranged

func (w WeaponType) Ranged() bool

type World

type World struct {
	L *lua.LState
	// contains filtered or unexported fields
}

func NewWorld

func NewWorld(db Database, l *lua.LState, cfg *MudConfig, events chan<- server.SessionEvent) *World

func (*World) AddEntity

func (w *World) AddEntity(e *Entity, roomId RoomId)

func (*World) AddEntityConfig

func (w *World) AddEntityConfig(cfg *EntityConfig)

func (*World) AddItem

func (w *World) AddItem(i *Item, roomId RoomId)

func (*World) AddItemConfig

func (w *World) AddItemConfig(cfg *ItemConfig)

func (*World) AddJobConfig

func (w *World) AddJobConfig(cfg *JobConfig)

func (*World) AddRoom

func (w *World) AddRoom(r *Room) *Room

func (*World) AddSession

func (w *World) AddSession(s *server.Session)

func (*World) AddSkillConfig

func (w *World) AddSkillConfig(cfg *SkillConfig)

func (*World) CreatePlayerCharacter

func (w *World) CreatePlayerCharacter(name string, pass string, player *Player) *Entity

func (*World) EntryRoomId

func (w *World) EntryRoomId() RoomId

func (*World) LogoutPlayer

func (w *World) LogoutPlayer(p *Player)

func (*World) OnPlayerInput

func (w *World) OnPlayerInput(p *Player, input string) StateId

func (*World) RemoveEntity

func (w *World) RemoveEntity(eid EntityId)

func (*World) RemoveSession

func (w *World) RemoveSession(sid server.SessionId)

func (*World) SavePlayerCharacter

func (w *World) SavePlayerCharacter(pid PlayerId)

func (*World) SetEntryRoomId

func (w *World) SetEntryRoomId(id RoomId)

func (*World) TryGetEntityByPlayerId

func (w *World) TryGetEntityByPlayerId(id PlayerId) (*Entity, bool)

func (*World) TryGetEntityConfig

func (w *World) TryGetEntityConfig(key string) (*EntityConfig, bool)

func (*World) TryGetItemConfig

func (w *World) TryGetItemConfig(key string) (*ItemConfig, bool)

func (*World) TryGetJobConfig

func (w *World) TryGetJobConfig(jobType JobTypeMask) (*JobConfig, bool)

func (*World) TryGetSkillConfig

func (w *World) TryGetSkillConfig(key string) (*SkillConfig, bool)

func (*World) TryLoadPlayerCharacter

func (w *World) TryLoadPlayerCharacter(name string, player *Player) (*Entity, error)

type WorldConfig

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

type Zone

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

func NewZone

func NewZone(cfg *ZoneConfig) *Zone

type ZoneConfig

type ZoneConfig struct {
	Id        ZoneId
	Name      string
	MinRoomId RoomId
	MaxRoomId RoomId
	Spawners  []*ZoneSpawnerConfig
}

type ZoneId

type ZoneId int32

type ZoneSpawner

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

func NewZoneSpawner

func NewZoneSpawner(cfg *ZoneSpawnerConfig) *ZoneSpawner

func (*ZoneSpawner) CanSpawn

func (s *ZoneSpawner) CanSpawn(time utils.Seconds) bool

func (*ZoneSpawner) Spawn

func (s *ZoneSpawner) Spawn(z *Zone, w *World)

func (*ZoneSpawner) UpdateActive

func (s *ZoneSpawner) UpdateActive(time utils.Seconds)

type ZoneSpawnerConfig

type ZoneSpawnerConfig struct {
	Type      SpawnerType
	Spawns    *utils.WeightedTableConfig[string]
	MaxActive int
	RoomIds   []RoomId
	Cooldown  utils.Seconds
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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