entity

package
v0.0.0-...-35568d9 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OptActive

func OptActive(active bool) func(m *figure)

OptActive option

func OptAlive

func OptAlive(alive bool) func(m *figure)

OptAlive option

func OptAttackMax

func OptAttackMax(a int) func(m *figure)

OptAttackMax option

func OptAttackMin

func OptAttackMin(a int) func(m *figure)

OptAttackMin option

func OptDefence

func OptDefence(d int) func(m *figure)

OptDefence option

func OptHP

func OptHP(hp int) func(m *figure)

OptHP option

func OptMP

func OptMP(mp int) func(m *figure)

OptMP option

func OptMovable

func OptMovable(movable bool) func(m *figure)

OptMovable option

func OptOwner

func OptOwner(owner string) func(m *figure)

OptOwner option

func OptPrevX

func OptPrevX(x int) func(m *figure)

OptPrevX option

func OptPrevY

func OptPrevY(y int) func(m *figure)

OptPrevY option

func OptX

func OptX(x int) func(m *figure)

OptX option

func OptY

func OptY(y int) func(m *figure)

OptY option

Types

type AppliedSkill

type AppliedSkill struct {
	Board string
	// How many times skill will be applied
	Times int
	From  Point
	To    Point
	Name  string
}

AppliedSkill Entity of skill application from one unit to another

type Buffable

type Buffable interface {
	AddAttack(int, int)
	AddDefense(int)
}

Buffable represents actions for buff mechanics

type Clonable

type Clonable interface {
	Clone() Figurable
}

Clonable let object behind interface be cloned

type CombatEvent

type CombatEvent struct {
	// think about consumption and different skills animation
	From *Point
	To   *Point
	Dmg  int
	// if it's empty, figure uses auto-attack
	AnimationName string
}

CombatEvent represents combat event for front-ent animation

type Combatable

type Combatable interface {
	PerformAttack() int
	GetInitiative() int
	GetAlive() bool
	SetAlive(bool)
	SetHP(int)
	GetHP() int
	SetMP(int)
	GetMP() int
	GetDefence() int
	GetAttack() (int, int)
	GetAttackStr() string
}

Combatable represents actions performed in combat with other units

type Figurable

Figurable represents actions with figures

type Mage

type Mage struct {
	SkillSet *SkillSet
	// contains filtered or unexported fields
}

Mage unit

func NewMage

func NewMage(opts ...func(m *figure)) *Mage

NewMage creates new grunt unit

func (*Mage) Activate

func (m *Mage) Activate(walking bool)

Activate activates unit making it walk forward for one cell

func (*Mage) AddAttack

func (m *Mage) AddAttack(minAtk, maxAtk int)

AddAttack adds min/max attack according to buff mechanics

func (*Mage) AddDefense

func (m *Mage) AddDefense(def int)

AddDefense adds defense according to buff mechanics

func (*Mage) AddSkillToRotation

func (m *Mage) AddSkillToRotation(boardName string, skillName string, from Point, to Point)

AddSkillToRotation Adds skill to rotation

func (*Mage) ApplySkills

func (m *Mage) ApplySkills(updatedFigures *[]Figurable, updatedPlayers *[]Player, clog *[]CombatEvent)

ApplySkills Applies skills from rotation in order, calling every skill from self skillbook

func (*Mage) Clone

func (m *Mage) Clone() Figurable

Clone copies unit

func (*Mage) GetActive

func (m *Mage) GetActive() bool

GetActive gets active flag

func (*Mage) GetAlive

func (m *Mage) GetAlive() bool

GetAlive gets unit alive flag

func (*Mage) GetAttack

func (m *Mage) GetAttack() (int, int)

GetAttack gets unit min-max attack

func (*Mage) GetAttackStr

func (m *Mage) GetAttackStr() string

GetAttackStr gets unit min-max attack for visualization

func (*Mage) GetCoords

func (m *Mage) GetCoords() (int, int)

GetCoords gets unit X,Y coords

func (*Mage) GetDefence

func (m *Mage) GetDefence() int

GetDefence gets unit defences

func (*Mage) GetHP

func (m *Mage) GetHP() int

GetHP gets unit hp

func (*Mage) GetInitiative

func (m *Mage) GetInitiative() int

GetInitiative gets unit initiative

func (*Mage) GetMP

func (m *Mage) GetMP() int

GetMP gets unit mp

func (*Mage) GetMovable

func (m *Mage) GetMovable() bool

GetMovable gets unit movable flag

func (*Mage) GetName

func (m *Mage) GetName() string

GetName gets unit name

func (*Mage) GetOwnerName

func (m *Mage) GetOwnerName() string

GetOwnerName gets unit owner

func (*Mage) GetPrevCoords

func (m *Mage) GetPrevCoords() (int, int)

GetPrevCoords gets previous turn unit coords

func (*Mage) GetRotation

func (m *Mage) GetRotation() []*AppliedSkill

GetRotation Gets skills rotation

func (*Mage) GetSkillSet

func (m *Mage) GetSkillSet() *SkillSet

GetSkillSet Gets skillset

func (*Mage) GetVisualMark

func (m *Mage) GetVisualMark() string

GetVisualMark gets mark for visualization

func (*Mage) LearnSkill

func (m *Mage) LearnSkill(name string, skill SkillFunc)

LearnSkill Learns skill consuming xp

func (*Mage) PerformAttack

func (m *Mage) PerformAttack() int

PerformAttack calculates unit dmg

func (*Mage) SetAlive

func (m *Mage) SetAlive(alive bool)

SetAlive sets unit alive flag

func (*Mage) SetCoords

func (m *Mage) SetCoords(X, Y int)

SetCoords sets unit X,Y coords

func (*Mage) SetHP

func (m *Mage) SetHP(hp int)

SetHP sets unit hp

func (*Mage) SetMP

func (m *Mage) SetMP(mp int)

SetMP sets unit mp

func (*Mage) SetMovable

func (m *Mage) SetMovable(movable bool)

SetMovable sets unit movable flag

func (*Mage) SetPrevCoords

func (m *Mage) SetPrevCoords(X, Y int)

SetPrevCoords sets previous turn unit coords, needed for front-end to delete figure

func (*Mage) SetSkillSet

func (m *Mage) SetSkillSet(ss *SkillSet)

SetSkillSet Sets skill set

type Movable

type Movable interface {
	GetMovable() bool
	SetMovable(bool)
	Activate(bool)
	GetActive() bool
	SetCoords(int, int)
	GetCoords() (int, int)
	SetPrevCoords(int, int)
	GetPrevCoords() (int, int)
}

Movable represents actions to move figures on the board

type Player

type Player struct {
	Name string
	HP   int
	MP   int
}

Player represents player changes for front-end

type Point

type Point struct {
	X int
	Y int
}

Point X,Y coordinates

type Poolable

type Poolable interface {
	GetFigures() []Figurable
	Fill(string)
	Get(int) Figurable
	Visualize()
}

Poolable represents actions with figures pool

type SkillFunc

type SkillFunc func(string, Point, Point, *[]Figurable, *[]Player, *[]CombatEvent)

SkillFunc skill mechanics goes here

type SkillSet

type SkillSet struct {
	// SKill rotation to be applied in order
	Rotation []*AppliedSkill
	// All learned skills mechanics will be here
	// front-end doesn't need to know them
	SkillBook map[string]SkillFunc `json:"-"`
}

SkillSet Entity of current skills figure may have

func NewEmptySkillSet

func NewEmptySkillSet() *SkillSet

NewEmptySkillSet Creates new empty skillset

type SkillUsable

type SkillUsable interface {
	GetSkillSet() *SkillSet
	SetSkillSet(*SkillSet)
	ApplySkills(*[]Figurable, *[]Player, *[]CombatEvent)
	AddSkillToRotation(string, string, Point, Point)
	LearnSkill(string, SkillFunc)
}

SkillUsable represents actions for figures with skills

type Visualizable

type Visualizable interface {
	GetName() string
	GetVisualMark() string
	GetOwnerName() string
}

Visualizable represents actions with visualization of figures

type Warrior

type Warrior struct {
	SkillSet *SkillSet
	// contains filtered or unexported fields
}

Warrior unit

func NewConstDmgWarrior

func NewConstDmgWarrior(opts ...func(m *figure)) *Warrior

NewConstDmgWarrior creates new peon unit with const dps

func NewWarrior

func NewWarrior(opts ...func(m *figure)) *Warrior

NewWarrior creates new peon unit

func (*Warrior) Activate

func (m *Warrior) Activate(walking bool)

Activate activates unit making it walk forward for one cell

func (*Warrior) AddAttack

func (m *Warrior) AddAttack(minAtk, maxAtk int)

AddAttack adds min/max attack according to buff mechanics

func (*Warrior) AddDefense

func (m *Warrior) AddDefense(def int)

AddDefense adds defense according to buff mechanics

func (*Warrior) AddSkillToRotation

func (m *Warrior) AddSkillToRotation(boardName string, skillName string, from Point, to Point)

AddSkillToRotation adds skill to skill rotation

func (*Warrior) ApplySkills

func (m *Warrior) ApplySkills(updatedFigures *[]Figurable, updatedPlayers *[]Player, clog *[]CombatEvent)

ApplySkills Applies skills from rotation in order, calling every skill from self skillbook

func (*Warrior) Clone

func (m *Warrior) Clone() Figurable

Clone copies unit

func (*Warrior) GetActive

func (m *Warrior) GetActive() bool

GetActive gets active flag

func (*Warrior) GetAlive

func (m *Warrior) GetAlive() bool

GetAlive gets unit alive flag

func (*Warrior) GetAttack

func (m *Warrior) GetAttack() (int, int)

GetAttack gets unit min-max attack

func (*Warrior) GetAttackStr

func (m *Warrior) GetAttackStr() string

GetAttackStr gets unit min-max attack for visualization

func (*Warrior) GetCoords

func (m *Warrior) GetCoords() (int, int)

GetCoords gets unit X,Y coords

func (*Warrior) GetDefence

func (m *Warrior) GetDefence() int

GetDefence gets unit defences

func (*Warrior) GetHP

func (m *Warrior) GetHP() int

GetHP gets unit hp

func (*Warrior) GetInitiative

func (m *Warrior) GetInitiative() int

GetInitiative gets unit initiative

func (*Warrior) GetMP

func (m *Warrior) GetMP() int

GetMP gets unit mp

func (*Warrior) GetMovable

func (m *Warrior) GetMovable() bool

GetMovable gets unit movable flag

func (*Warrior) GetName

func (m *Warrior) GetName() string

GetName gets unit name

func (*Warrior) GetOwnerName

func (m *Warrior) GetOwnerName() string

GetOwnerName gets unit owner

func (*Warrior) GetPrevCoords

func (m *Warrior) GetPrevCoords() (int, int)

GetPrevCoords gets previous turn unit coords

func (*Warrior) GetRotation

func (m *Warrior) GetRotation() []*AppliedSkill

GetRotation Gets skill rotation

func (*Warrior) GetSkillSet

func (m *Warrior) GetSkillSet() *SkillSet

GetSkillSet Gets skillset

func (*Warrior) GetVisualMark

func (m *Warrior) GetVisualMark() string

GetVisualMark gets mark for visualization

func (*Warrior) LearnSkill

func (m *Warrior) LearnSkill(name string, skill SkillFunc)

LearnSkill Learns skill consuming xp

func (*Warrior) PerformAttack

func (m *Warrior) PerformAttack() int

PerformAttack calculates unit dmg

func (*Warrior) SetAlive

func (m *Warrior) SetAlive(alive bool)

SetAlive sets unit alive flag

func (*Warrior) SetCoords

func (m *Warrior) SetCoords(X, Y int)

SetCoords sets unit X,Y coords

func (*Warrior) SetHP

func (m *Warrior) SetHP(hp int)

SetHP sets unit hp

func (*Warrior) SetMP

func (m *Warrior) SetMP(mp int)

SetMP sets unit mp

func (*Warrior) SetMovable

func (m *Warrior) SetMovable(movable bool)

SetMovable sets unit movable flag

func (*Warrior) SetPrevCoords

func (m *Warrior) SetPrevCoords(X, Y int)

SetPrevCoords sets previous turn unit coords, needed for front-end to delete figure

func (*Warrior) SetSkillSet

func (m *Warrior) SetSkillSet(ss *SkillSet)

SetSkillSet Sets skill set

Jump to

Keyboard shortcuts

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