character

package
v0.0.0-...-ac9a988 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: GPL-2.0 Imports: 17 Imported by: 12

Documentation

Overview

character package provides game character struct and other types for game characters.

Index

Constants

View Source
const (
	LawfulGood     Alignment = Alignment("aliLawfulGood")
	NeutralGood              = Alignment("aliNeutralGood")
	ChaoticGood              = Alignment("aliChaoticGood")
	LawfulNeutral            = Alignment("aliLawfulNeutral")
	TrueNeutral              = Alignment("aliTrueNeutral")
	ChaoticNeutral           = Alignment("aliChaoticNeutral")
	LawfulEvil               = Alignment("aliLawfulEvil")
	NeutralEvil              = Alignment("aliNeutralEvil")
	ChaoticEvil              = Alignment("aliChaoticEvil")
)
View Source
const (
	Friendly Attitude = Attitude("attFriendly")
	Neutral           = Attitude("attNeutral")
	Hostile           = Attitude("attHostile")
)
View Source
const (
	BaseLift   = 10
	BaseSight  = 300.0
	BaseHealth = 50
	BaseMana   = 10
)

Variables

View Source
var (
	REQS_NOT_MEET = errors.New("requirements not meet")
	NOT_READY_YET = errors.New("not ready yet")
	IN_MOVE       = errors.New("impossible while moving")
	CANT_USE      = errors.New("object can't be used")
)

Functions

This section is empty.

Types

type Alignment

type Alignment string

Type for character alignment.

type Attitude

type Attitude string

Type for character attitude.

type Attributes

type Attributes struct {
	Str, Con, Dex, Wis, Int int
}

Attributes struct represents game character attributes: strenght, constitution, dexterity, wisdom, intelligence.

func (*Attributes) Apply

func (a *Attributes) Apply(data res.AttributesData)

Apply applies specified data on character attributes.

func (*Attributes) Damage

func (a *Attributes) Damage() (int, int)

Damage returns min and max damage values based on attributes.

func (*Attributes) Data

func (a *Attributes) Data() res.AttributesData

Data returns data resource for attributes.

func (*Attributes) Health

func (a *Attributes) Health() int

Health returns maximal health based on attributes.

func (*Attributes) Lift

func (a *Attributes) Lift() int

Lift returns maximal size of inventory based on attributes.

func (*Attributes) Mana

func (a *Attributes) Mana() int

Mana returns maximal mana based on attributes.

func (*Attributes) Sight

func (a *Attributes) Sight() float64

Sight returns maximal sight range based on attributes.

func (*Attributes) String

func (a *Attributes) String() string

String returns attributes struct as string in format: [strengt], [constitution], [dexterity], [wisdom], [intelligence]

type Character

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

Character struct represents game character.

func New

func New(data res.CharacterData) *Character

New creates new character from specified data.

func (*Character) AddDialog

func (c *Character) AddDialog(d *dialog.Dialog)

AddDialog adds specified dialog to character and sets character as dialog owner.

func (*Character) AddEffect

func (c *Character) AddEffect(e *effect.Effect)

AddEffect add specified effect to character effects.

func (*Character) AddFlag

func (c *Character) AddFlag(f flag.Flag)

AddFlag adds specified flag.

func (*Character) AddKill

func (c *Character) AddKill(kill res.KillData)

AddKill adds specified kill on character kill list.

func (*Character) AddOnModifierEvent

func (c *Character) AddOnModifierEvent(f func(m effect.Modifier))

AddOnModifierEvent adds specified function to be triggered after receiving a new modifier. The event function will be called for every recieved modifier after it was handled by the character.

func (*Character) AddSkill

func (c *Character) AddSkill(s *skill.Skill)

AddSkill adds specified skill to characters skills.

func (*Character) AddTraining

func (c *Character) AddTraining(t *training.TrainerTraining)

AddTrainings adds specified training to character trainings list.

func (*Character) Agony

func (c *Character) Agony() bool

Agony check wheter character is in agony state.

func (*Character) Alignment

func (c *Character) Alignment() Alignment

Alignment returns character alignment

func (*Character) Apply

func (c *Character) Apply(data res.CharacterData)

Apply applies specified data on the character.

func (*Character) AreaID

func (c *Character) AreaID() string

AreaID returns ID of character area.

func (*Character) Attitude

func (c *Character) Attitude() Attitude

Attitude returns character attitude.

func (*Character) AttitudeFor

func (c *Character) AttitudeFor(o serial.Serialer) Attitude

AttitudeFor returns attitude for specified object. For dead objects returns neutral attitude. For memorized targets returns memorized attitude. For not memorized objects from the same guild returns friendly attitude. For not memorized hostile objects returns hostile attitude. For other cases returns character attitude.

func (*Character) Attributes

func (c *Character) Attributes() *Attributes

Attributes returns character attributes.

func (*Character) BaseMoveCooldown

func (c *Character) BaseMoveCooldown() int64

BaseMoveCooldown returns character base movement cooldown in milliseconds.

func (*Character) Casted

func (c *Character) Casted() useaction.Usable

Casted returns usable object currently casted by the character.

func (*Character) ChapterID

func (c *Character) ChapterID() string

ChapterID returns ID of the chapter that this character should be in.

func (*Character) ChargeReqs

func (c *Character) ChargeReqs(reqs ...req.Requirement)

ChargeReqs takes from character all things that make the character meet specified requirements. All requirements that are not 'chargeable' will be ignored.

func (*Character) ChatLog

func (c *Character) ChatLog() *objects.Log

ChatLog returns character speech log channel.

func (*Character) Cooldown

func (c *Character) Cooldown() int64

Cooldown returns character cooldown in milliseconds.

func (*Character) Crafting

func (c *Character) Crafting() *craft.Crafting

Crafting returns character crafting object.

func (*Character) Damage

func (c *Character) Damage() (int, int)

Damage retruns min and max damage value, including weapons, active effects, etc.

func (*Character) DamageType

func (c *Character) DamageType() objects.Element

DamgaeType returns type of damage caused by character.

func (*Character) Data

func (c *Character) Data() res.CharacterData

Data creates data resource struct for character.

func (*Character) DefaultPosition

func (c *Character) DefaultPosition() (float64, float64)

DefaultPosition returns character default position.

func (*Character) DestPoint

func (c *Character) DestPoint() (float64, float64)

DestPoint returns current destination point position.

func (*Character) Dialog

func (c *Character) Dialog(char Character) (dial *dialog.Dialog)

Dialog returns dialog for specified character.

func (*Character) Dialogs

func (c *Character) Dialogs() (dls []*dialog.Dialog)

Dialogs returns all character dialogs.

func (*Character) Effects

func (c *Character) Effects() (effects []*effect.Effect)

Effects returns character all effects.

func (*Character) Equipment

func (c *Character) Equipment() *Equipment

Equipment returns character equipment.

func (*Character) Experience

func (c *Character) Experience() int

Experience returns current value of experience points.

func (*Character) Fighting

func (c *Character) Fighting() bool

Fighting checks if character is in combat.

func (*Character) Flags

func (c *Character) Flags() (flags []flag.Flag)

Flags returns all active flags.

func (*Character) Gender

func (c *Character) Gender() Gender

Gender returns character gender.

func (*Character) Guild

func (c *Character) Guild() Guild

Guild returns character guild.

func (*Character) HasFlag

func (c *Character) HasFlag(flag flag.Flag) bool

HasFlag checks if character has specified flag.

func (*Character) Health

func (c *Character) Health() int

Health returns current value of health points.

func (*Character) HitEffects

func (c *Character) HitEffects() []*effect.Effect

HitEffects returns character hit effects.

func (*Character) HitModifiers

func (c *Character) HitModifiers() []effect.Modifier

HitModifiers returns character hit modifiers.

func (*Character) ID

func (c *Character) ID() string

ID returns character ID.

func (*Character) Interrupt

func (c *Character) Interrupt()

Interrupt stops any acction(like skill casting) performed by character.

func (*Character) Inventory

func (c *Character) Inventory() *item.Inventory

Inventory returns character inventory.

func (*Character) Journal

func (c *Character) Journal() *quest.Journal

Journal returns quest journal.

func (*Character) Kills

func (c *Character) Kills() []res.KillData

Kills returns all character kill records.

func (*Character) Level

func (c *Character) Level() int

Level returns character level.

func (*Character) Live

func (c *Character) Live() bool

Live checks wheter character is live.

func (*Character) Mana

func (c *Character) Mana() int

Mana returns current value of mana points.

func (*Character) MaxExperience

func (c *Character) MaxExperience() int

MaxExperience returns maximal value of experience points.

func (*Character) MaxHealth

func (c *Character) MaxHealth() int

MaxHealth returns maximal value of health points.

func (*Character) MaxMana

func (c *Character) MaxMana() int

MaxMana returns maximal value of mana points.

func (*Character) MeetReqs

func (c *Character) MeetReqs(reqs ...req.Requirement) bool

ReqsMeet checks whether all specified requirements are meet by character.

func (*Character) MemorizeTarget

func (c *Character) MemorizeTarget(mem *TargetMemory)

MemorizeTarget saves specified target memory.

func (*Character) Memory

func (c *Character) Memory() (mem []*TargetMemory)

Memory returns character tergets memory.

func (*Character) MoveCooldown

func (c *Character) MoveCooldown() int64

MoveCooldown returns character movement cooldown in milliseconds.

func (*Character) Moving

func (c *Character) Moving() bool

Moving checks whether character is moving.

func (*Character) Position

func (c *Character) Position() (float64, float64)

Position returns current character position.

func (*Character) Race

func (c *Character) Race() Race

Race returns character race.

func (*Character) RemoveEffect

func (c *Character) RemoveEffect(e *effect.Effect)

RemoveEffect removes effect from character.

func (*Character) RemoveFlag

func (c *Character) RemoveFlag(f flag.Flag)

RemoveFlag removes specified flag.

func (*Character) RemoveSkill

func (c *Character) RemoveSkill(s *skill.Skill)

RemoveSkill removes specified skill.

func (*Character) Respawn

func (c *Character) Respawn() int64

Respawn returns time of character respawn in milliseconds.

func (*Character) Serial

func (c *Character) Serial() string

Serial returns serial value.

func (*Character) SetAlignment

func (c *Character) SetAlignment(ali Alignment)

SetAlignment sets character alignment.

func (*Character) SetAreaID

func (c *Character) SetAreaID(areaID string)

SetAreaID sets specifid area ID as character area ID.

func (*Character) SetAttitude

func (c *Character) SetAttitude(att Attitude)

SetAttitude sets character attitude.

func (*Character) SetChapterID

func (c *Character) SetChapterID(chapterID string)

SetChapterID sets specified chapter ID as character chapter ID.

func (*Character) SetDefaultPosition

func (c *Character) SetDefaultPosition(x, y float64)

SetDefaultPosition sets specified XY position as default character position.

func (*Character) SetDestPoint

func (c *Character) SetDestPoint(x, y float64)

SetDestPoint sets specified XY position as current destionation point of character.

func (*Character) SetExperience

func (c *Character) SetExperience(exp int)

SetExperience sets specified value as current amount of experience points.

func (*Character) SetGender

func (c *Character) SetGender(gender Gender)

SetGander sets character gender.

func (*Character) SetGuild

func (c *Character) SetGuild(guild Guild)

SetGuild sets character guild.

func (*Character) SetHealth

func (c *Character) SetHealth(hp int)

SetHealth sets specified value as current amount of health points.

func (*Character) SetMana

func (c *Character) SetMana(mana int)

SetMana sets specified value as current amount of mana points.

func (*Character) SetMoveCooldown

func (c *Character) SetMoveCooldown(cooldown int64)

SetMoveCooldown sets character movement cooldown to the specified value(in milliseconds).

func (*Character) SetPosition

func (c *Character) SetPosition(x, y float64)

SetPosition sets specified XY position as current position.

func (*Character) SetRespawn

func (c *Character) SetRespawn(respawn int64)

SetRespawn sets character respawn time in milliseconds.

func (*Character) SetSerial

func (c *Character) SetSerial(serial string)

SetSerial sets specified serial value for this character.

func (*Character) SetTarget

func (c *Character) SetTarget(t effect.Target)

SetTarget sets specified 'targetable' as current target.

func (*Character) SightRange

func (c *Character) SightRange() float64

SightRange returns current sight range.

func (*Character) Skills

func (c *Character) Skills() (skills []*skill.Skill)

Skills return all character skills.

func (*Character) TakeEffect

func (c *Character) TakeEffect(e *effect.Effect)

takeEffects adds specified effects

func (*Character) TakeModifiers

func (c *Character) TakeModifiers(source serial.Serialer, mods ...effect.Modifier)

TakeModifiers handles all specified modifiers. Source can be nil.

func (*Character) Targets

func (c *Character) Targets() (targets []effect.Target)

Targets returns character targets.

func (*Character) Trainings

func (c *Character) Trainings() []*training.TrainerTraining

Trainings returns all trainings.

func (*Character) Update

func (c *Character) Update(delta int64)

Update updates character.

func (*Character) Use

func (c *Character) Use(ob useaction.Usable) error

Use checks requirements and starts cast action for specified usable object. Returns an error if use requirements are not meet(REQS_NOT_MEET), if cooldown is active(NOT_READY_YET), if character is currently moving(IN_MOVE) or if character is dead or specified usable has no use action(CANT_USE).

func (*Character) UseAction

func (c *Character) UseAction() *useaction.UseAction

Action returns character use action.

type Equipment

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

Struct for character equipment.

func (*Equipment) Apply

func (eq *Equipment) Apply(data res.EquipmentData)

Apply applies specified data on the equipment.

func (*Equipment) Data

func (eq *Equipment) Data() res.EquipmentData

Data creates data resource for equipment.

func (*Equipment) Equiped

func (eq *Equipment) Equiped(item item.Equiper) bool

Equiped checks whether specified item is equiped.

func (*Equipment) Items

func (eq *Equipment) Items() (items []item.Equiper)

Items returns slice with all equiped items.

func (*Equipment) Slots

func (eq *Equipment) Slots() []*EquipmentSlot

Slots retuns all equipment slots.

func (*Equipment) Unequip

func (eq *Equipment) Unequip(it item.Equiper)

Unequip removes specified item from all compatible slots.

type EquipmentSlot

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

Struct for equipment slots.

func (*EquipmentSlot) ID

func (eqSlot *EquipmentSlot) ID() int

ID returns slot ID.

func (*EquipmentSlot) Item

func (eqSlot *EquipmentSlot) Item() item.Equiper

Item returns slot item or nil if slot is empty.

func (*EquipmentSlot) SetItem

func (eqSlot *EquipmentSlot) SetItem(it item.Equiper)

SetItem sets inserts specified item to slot.

func (*EquipmentSlot) Type

func (eqSlot *EquipmentSlot) Type() item.Slot

Type returns slot type.

type Gender

type Gender string

Type for character genders.

const (
	Male   Gender = Gender("genderMale")
	Female        = Gender("genderFemale")
)

type Guild

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

Guild struct represents chracter guild

func NewGuild

func NewGuild(id string) Guild

NewGuild return new guild with specified parameters

func (Guild) ID

func (g Guild) ID() string

ID return guild ID.

func (Guild) String

func (g Guild) String() string

String returns guild ID

type Race

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

Struct for character race.

func NewRace

func NewRace(data res.RaceData) Race

NewRace creates new race.

func (Race) ID

func (r Race) ID() string

ID retruns race ID.

func (Race) Playable

func (r Race) Playable() bool

Playable checks if race is playable.

func (Race) Skills

func (r Race) Skills() []res.ObjectSkillData

Skill return race skills.

type TargetMemory

type TargetMemory struct {
	TargetID     string
	TargetSerial string
	Attitude     Attitude
}

Struct for saved data about target.

Jump to

Keyboard shortcuts

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