battle3

package
v0.0.0-...-8af4b65 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxTurns     = 10 // 最大回合数
	LeechVal     = 5  // 吸血率
	FightBackVal = 15 // 反击率

	MinCharacterID = 1000 // 最小 CharacterID
	MaxCharacterID = 9999 // 最大 CharacterID

	MinItemID = 10000 // 最小 ItemID
	MaxItemID = 99999 // 最大 ItemID
)
View Source
const (
	PropFuncStateOn  = 1
	PropFuncStateOff = 2
)

Variables

View Source
var (
	// ErrInvalidPropStr - invalid prop string
	ErrInvalidPropStr = errors.New("invalid prop string")
	// ErrInvalidPropFunc - invalid PropFunc
	ErrInvalidPropFunc = errors.New("invalid PropFunc")
	// ErrInvalidFuncPropParam - invalid FuncItem parameter
	ErrInvalidFuncPropParam = errors.New("invalid FuncItem parameter")
	// ErrInvalidBasicPropFunc - invalid BasicPropFunc
	ErrInvalidBasicPropFunc = errors.New("invalid BasicPropFunc")
	// ErrInvalidItemID - invalid ItemID
	ErrInvalidItemID = errors.New("invalid ItemID")
	// ErrEquiped - equiped
	ErrEquiped = errors.New("equiped")
	// ErrCantEquip - can not equip
	ErrCantEquip = errors.New("can not equip")
	// ErrInvalidFuncEventParam - invalid FuncEvent parameter
	ErrInvalidFuncEventParam = errors.New("invalid FuncEvent parameter")
	// ErrInvalidCharacterID - invalid CharacterID
	ErrInvalidCharacterID = errors.New("invalid CharacterID")
	// ErrInvalidEventFunc - invalid EventFunc
	ErrInvalidEventFunc = errors.New("invalid EventFunc")
	// ErrNoEvent - no event
	ErrNoEvent = errors.New("no event")
	// ErrInvalidData - invalid data
	ErrInvalidData = errors.New("invalid data")
	// ErrInvalidStageDevIndex - invalid StageDev index
	ErrInvalidStageDevIndex = errors.New("invalid StageDev index")
	// ErrBattle - battle error
	ErrBattle = errors.New("battle error")
	// ErrInvalidUnitType - invalid UnitType
	ErrInvalidUnitType = errors.New("invalid UnitType")
	// ErrInvalidStageID - invalid StageID
	ErrInvalidStageID = errors.New("invalid StageID")
	// ErrCannotGenMap - cannot gen map
	ErrCannotGenMap = errors.New("cannot gen map")
	// ErrInvalidExitPos - invalid exit position
	ErrInvalidExitPos = errors.New("invalid exit position")
)

Functions

func AbsInt

func AbsInt(v int) int

func CalcWinTimesWithAI1

func CalcWinTimesWithAI1(event *Event, num int, unit *Unit) int

返回AI1玩num次,成功的次数

func CalcWinTimesWithAI2

func CalcWinTimesWithAI2(event *Event, num int, unit *Unit) int

返回AI2玩num次,成功的次数

func CountAvgLastHPPer

func CountAvgLastHPPer(lst []*Event) int

func CountEventNum

func CountEventNum(lst []*Event) int

func CountNumWithID

func CountNumWithID(lst []*Event, id int) int

func CountWidth

func CountWidth(lst []*Event) int

func ForEach

func ForEach(data *StageDevData, arr []int, each FuncForEachStageDevData)

func GenEnemy2

func GenEnemy2(index int) error

根据关卡配置里的主角属性,生成怪物(敌人)

func GetHPAreaForUnitType

func GetHPAreaForUnitType(ut UnitType, total int) (int, int)

func InitSystem

func InitSystem(fnpath string) error

func IsEquipment

func IsEquipment(id int) bool

func IsItem

func IsItem(id int) bool

func IsLeafNode

func IsLeafNode(e *Event) bool

func IsMonster

func IsMonster(id int) bool

func SaveEvents

func SaveEvents(fn string, events [][]*Event) error

func SaveEvents2

func SaveEvents2(fn string, events []*Event) error

func UnitType2Str

func UnitType2Str(ut UnitType) (string, error)

Types

type AddOn

type AddOn struct {
	CacheVals []int
}

func (*AddOn) Clone

func (addon *AddOn) Clone() *AddOn

type BasicPropFunc

type BasicPropFunc func(unit *Unit, prop PropType, val int)

基本属性修改,val为改变量 注意,如果是状态数据,val为最终值

type BattleResult

type BattleResult struct {
	Units           []*Unit `json:"units"`           // 战斗单位,2个
	WinIndex        int     `json:"winIndex"`        // 胜利索引
	FirstIndex      int     `json:"firstIndex"`      // 先手索引
	ForceFirstIndex int     `json:"forceFirstIndex"` // 强制先手索引,只在速度相等时才有用,如果无意义为-1
	Turns           int     `json:"turns"`           // 回合数
}

func StartBattle

func StartBattle(src []*Unit) *BattleResult

type BattlesStatsNode

type BattlesStatsNode struct {
	TotalNums int `json:"totalNums"`
	WinNums   int `json:"winNums"`
	LastHP    int `json:"lastHP"`
}

type CharacterData

type CharacterData struct {
	ID      int    `yaml:"id"`
	Name    string `yaml:"name"`
	SPName  string `yaml:"spname"`
	HP      int    `yaml:"hp"`
	DPS     int    `yaml:"dps"`
	IsFirst bool   `yaml:"isfirst"`
}

type CharacterDataMgr

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

func LoadCharacter

func LoadCharacter(fn string) (*CharacterDataMgr, error)

func (*CharacterDataMgr) GetCharacterData

func (mgr *CharacterDataMgr) GetCharacterData(id int) (*CharacterData, error)

func (*CharacterDataMgr) NewUnit

func (mgr *CharacterDataMgr) NewUnit(id int) (*Unit, error)

type Equipment

type Equipment struct {
	Data  *ItemData
	AddOn *AddOn
}

func (*Equipment) Clone

func (equip *Equipment) Clone() *Equipment

type Event

type Event struct {
	ID       int      `yaml:"id"` // 0 是入口
	Children []*Event `yaml:"children"`
	IsEnding bool     `yaml:"isEnding"`

	Index   int `yaml:"index"`   // 索引,单线流程的顺序索引
	StartHP int `yaml:"startHP"` // 初始HP
	EndHP   int `yaml:"endHP"`   // 结束HP
	MaxHP   int `yaml:"maxHP"`   // 最大HP

	TotalNum int      `yaml:"-"` // AI跑了多少次
	WinNum   int      `yaml:"-"` // AI通关多少次
	Awards   []*Event `yaml:"awards"`
	// contains filtered or unexported fields
}

func AddEventDifficulty

func AddEventDifficulty(e *Event) (*Event, error)

func GenEvent

func GenEvent(fn string, unit *Unit) ([]*Event, error)

func GenEventWithStage

func GenEventWithStage(unit *Unit, startStage int, endStage int) ([]*Event, error)

func GenMultiLineEvent

func GenMultiLineEvent(lst []*Event) *Event

func (*Event) Add2Last

func (event *Event) Add2Last(id int)

加到最深的子节点

func (*Event) AddChild

func (event *Event) AddChild(e *Event)

func (*Event) BuildNextEvents

func (event *Event) BuildNextEvents() []*Event

获得可以达到的全部event

func (*Event) BuildNextEventsEx

func (event *Event) BuildNextEventsEx(eachEvent ForEachEventFunc) []*Event

获得可以达到的全部event,增加一个外部接口来判断

func (*Event) Clone

func (event *Event) Clone() *Event

func (*Event) CloneOnlyMe

func (event *Event) CloneOnlyMe() *Event

func (*Event) CountID

func (event *Event) CountID(id int) int

func (*Event) CountNodes

func (event *Event) CountNodes() int

func (*Event) ForEach

func (event *Event) ForEach(funcForEach ForEachEventFunc) bool

func (*Event) GetLeafNodes

func (event *Event) GetLeafNodes() []*Event

func (*Event) GetName

func (event *Event) GetName() string

func (*Event) GetNotValidLeafNodes

func (event *Event) GetNotValidLeafNodes() []*Event

func (*Event) GetValidLeafNodes

func (event *Event) GetValidLeafNodes() []*Event

func (*Event) OutputExcel

func (event *Event) OutputExcel(f *excelize.File, sheet string) error

type EventFunc

type EventFunc func(id int, params []int, strParams []string, unit *Unit, lst []*Event, cur *EventPool) bool

type EventFuncMgr

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

func (*EventFuncMgr) Reg

func (mgr *EventFuncMgr) Reg(name string, funcEvent EventFunc)

func (*EventFuncMgr) Run

func (mgr *EventFuncMgr) Run(name string,
	id int, params []int, strParams []string, unit *Unit, lst []*Event, cur *EventPool) bool

type EventPool

type EventPool struct {
	Events []*GenEventData `yaml:"events"`
}

func LoadEventPool

func LoadEventPool(fn string) (*EventPool, error)

func (*EventPool) GenEvent

func (ep *EventPool) GenEvent(lst []*Event, unit *Unit) *Event

type ForEachEventFunc

type ForEachEventFunc func(*Event) bool

type FuncForEachStageDevData

type FuncForEachStageDevData func(arr []int)

type GenDPSLevelUp2Result

type GenDPSLevelUp2Result struct {
	DPS    []int `json:"dps"`    // dps的值
	WinNum []int `json:"winnum"` // 该dps下,可能的胜利次数
}

func GenDPSLevelUp2

func GenDPSLevelUp2(index int, off int) (*GenDPSLevelUp2Result, error)

func (*GenDPSLevelUp2Result) Output

func (result *GenDPSLevelUp2Result) Output(fn string) error

type GenDPSLevelUpResult

type GenDPSLevelUpResult struct {
	DPS    []int `json:"dps"`    // dps的值
	LoseHP []int `json:"losehp"` // 该dps下,全部战斗完,损失的HP
}

func GenDPSLevelUp

func GenDPSLevelUp(index int, off int) (*GenDPSLevelUpResult, error)

判断dps成长回报,其实只需要考虑损失HP之和即可

func (*GenDPSLevelUpResult) Output

func (result *GenDPSLevelUpResult) Output(fn string) error

type GenDownAtkLevelUp2Result

type GenDownAtkLevelUp2Result struct {
	DownAtk []int `json:"downatk"` // downatk的值
	WinNum  []int `json:"winnum"`  // 可能的胜利次数
}

func GenDownAtkLevelUp2

func GenDownAtkLevelUp2(index int, off int) (*GenDownAtkLevelUp2Result, error)

判断DownAtk成长回报,其实只需要考虑损失HP之和即可

func (*GenDownAtkLevelUp2Result) Output

func (result *GenDownAtkLevelUp2Result) Output(fn string) error

type GenDownAtkLevelUpResult

type GenDownAtkLevelUpResult struct {
	DownAtk []int `json:"downatk"` // downatk的值
	LoseHP  []int `json:"losehp"`  // 该downatk下,全部战斗完,损失的HP
}

func GenDownAtkLevelUp

func GenDownAtkLevelUp(index int, off int) (*GenDownAtkLevelUpResult, error)

判断DownAtk成长回报,其实只需要考虑损失HP之和即可

func (*GenDownAtkLevelUpResult) Output

func (result *GenDownAtkLevelUpResult) Output(fn string) error

type GenEnemyBattleResult

type GenEnemyBattleResult struct {
	LastHP int `json:"lastHP"` // 获胜者剩下的HP
	MaxHP  int `json:"maxHP"`  // 获胜者的总HP
	Turns  int `json:"turns"`  // 战斗回合数
}

type GenEnemyParam

type GenEnemyParam struct {
	Title           string   `json:"title"`
	UnitType        UnitType `json:"unitType"`
	MinTurns        int      `json:"minTurns"`
	MaxTurns        int      `json:"maxTurns"`
	MinLastHP       int      `json:"minLastHP"`
	MaxLastHP       int      `json:"maxLastHP"`
	StartTotalVal   int      `json:"startTotalVal"`
	EndTotalVal     int      `json:"endTotalVal"`
	IsWinner        bool     `json:"isWinner"`
	DetailTurnOff   int      `json:"detailTurnOff"`
	DetailLastHPOff int      `json:"detailLastHPOff"`
}

type GenEnemyResult

type GenEnemyResult struct {
	Param       *GenEnemyParam          `json:"param"`       //
	Nodes       []*GenEnemyResultNode   `json:"nodes"`       //
	DetailNodes []*GenEnemyResultDetail `json:"detailNodes"` //
}

func GenEnemy

func GenEnemy(hero *Unit, param *GenEnemyParam) *GenEnemyResult

func (*GenEnemyResult) AddNodeForDetail

func (result *GenEnemyResult) AddNodeForDetail(param *GenEnemyParam, ret *BattleResult)

func (*GenEnemyResult) Output

func (result *GenEnemyResult) Output(fn string) error

func (*GenEnemyResult) OutputExcel

func (result *GenEnemyResult) OutputExcel(f *excelize.File) error

func (*GenEnemyResult) RebuildDetail

func (result *GenEnemyResult) RebuildDetail()

type GenEnemyResultDetail

type GenEnemyResultDetail struct {
	MinTurns  int                   `json:"minTurns"`
	MaxTurns  int                   `json:"maxTurns"`
	MinLastHP int                   `json:"minLastHP"`
	MaxLastHP int                   `json:"maxLastHP"`
	Nodes     []*GenEnemyResultNode `json:"nodes"` //
}

type GenEnemyResultNode

type GenEnemyResultNode struct {
	TotalVal        int                     `json:"totalVal"`        // 总值
	LstHP           []int                   `json:"lstHP"`           // HP
	LstBattleResult []*GenEnemyBattleResult `json:"lstBattleResult"` // 战斗结果结算
}

func (*GenEnemyResultNode) AddBattleResult

func (node *GenEnemyResultNode) AddBattleResult(param *GenEnemyParam, ret *BattleResult)

type GenEventData

type GenEventData struct {
	ID        int                 `yaml:"id"`
	EventFunc []*GenEventFuncData `yaml:"eventFunc"`
	IsEnding  bool                `yaml:"isEnding"`
	TotalNum  int                 `yaml:"totalNum"`
}

type GenEventFuncData

type GenEventFuncData struct {
	PreFunc          string   `yaml:"preFunc"`
	PreFuncParams    []int    `yaml:"preFuncParams"`
	PreFuncStrParams []string `yaml:"preFuncStrParams"`
}

type GenHPLevelUpResult

type GenHPLevelUpResult struct {
	HP     []int `json:"hp"`     // hp的值
	WinNum []int `json:"winnum"` // 该hp下,可能的胜利次数
}

func GenHPLevelUp

func GenHPLevelUp(index int, off int) (*GenHPLevelUpResult, error)

func (*GenHPLevelUpResult) Output

func (result *GenHPLevelUpResult) Output(fn string) error

type GenMapParams

type GenMapParams struct {
	Width           int               `yaml:"width"`
	Height          int               `yaml:"height"`
	Rooms           []*GenMapRoomData `yaml:"rooms"`
	IsEnclosingWall bool              `yaml:"isEnclosingWall"`
	StartPos        []int             `yaml:"startPos"`
	ExitPos         []int             `yaml:"exitPos"`
}

func LoadGenMapParams

func LoadGenMapParams(fn string) (*GenMapParams, error)

func (*GenMapParams) IsWall

func (params *GenMapParams) IsWall(x, y int) bool

type GenMapRoomData

type GenMapRoomData struct {
	Width  int `yaml:"width"`
	Height int `yaml:"height"`
	Num    int `yaml:"num"`
}

type GenMapStatic

type GenMapStatic struct {
	Floor *RandWeights `yaml:"floor"`
	Wall  *RandWeights `yaml:"wall"`
	Road  *RandWeights `yaml:"road"`
	Start *RandWeights `yaml:"start"`
	Exit  *RandWeights `yaml:"exit"`
	Door  *RandWeights `yaml:"door"`
}

func LoadGenMapStatic

func LoadGenMapStatic(fn string) (*GenMapStatic, error)

func (*GenMapStatic) IsDoor

func (params *GenMapStatic) IsDoor(v int) bool

func (*GenMapStatic) IsFloor

func (params *GenMapStatic) IsFloor(v int) bool

func (*GenMapStatic) IsNonRoomWall

func (params *GenMapStatic) IsNonRoomWall(v int) bool

不能作为房间墙壁的,出口、入口等

func (*GenMapStatic) IsNotNearWall

func (params *GenMapStatic) IsNotNearWall(v int) bool

门不能挨着门、起点、终点

func (*GenMapStatic) IsRoomFloor

func (params *GenMapStatic) IsRoomFloor(v int) bool

func (*GenMapStatic) IsWall

func (params *GenMapStatic) IsWall(v int) bool

type ItemData

type ItemData struct {
	ID         int        `yaml:"id"`
	Name       string     `yaml:"name"`
	SPName     string     `yaml:"spname"`
	Type       string     `yaml:"type"`
	ValType    []string   `yaml:"valtype"`
	TargetProp []PropType `yaml:"-"`
	ValFunc    string     `yaml:"valfunc"`
	Val        []int      `yaml:"val"`
	StrVal     []string   `yaml:"strval"`
}

type ItemDataMgr

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

func LoadItem

func LoadItem(fn string) (*ItemDataMgr, error)

func (*ItemDataMgr) GetItemData

func (mgr *ItemDataMgr) GetItemData(id int) (*ItemData, error)

type MapData

type MapData struct {
	Data  [][]int     `yaml:"data" json:"data"`
	Rooms []*RoomData `yaml:"rooms" json:"rooms"`
	Start []int       `yaml:"start" json:"start"`
	Exit  []int       `yaml:"exit" json:"exit"`
}

func GenMap

func GenMap(params *GenMapParams) (*MapData, error)

构建房间方式来生成地图

func GenMap2

func GenMap2(params *GenMapParams) (*MapData, error)

构建房间方式来生成地图

func (*MapData) CalcValidTileNum

func (md *MapData) CalcValidTileNum(sx, sy int) int

func (*MapData) Clone

func (md *MapData) Clone() *MapData

func (*MapData) GenRoomPos

func (md *MapData) GenRoomPos(w, h int) []int

func (*MapData) GenRooms

func (md *MapData) GenRooms(lst []int) *MapData

func (*MapData) GetHeight

func (md *MapData) GetHeight() int

func (*MapData) GetWidth

func (md *MapData) GetWidth() int

func (*MapData) IsInRoom

func (md *MapData) IsInRoom(x, y int) bool

func (*MapData) IsValidMap

func (md *MapData) IsValidMap() bool

判断这个地图是否合法

func (*MapData) IsValidPos

func (md *MapData) IsValidPos(x, y int) bool

func (*MapData) SetRoom

func (md *MapData) SetRoom(sx, sy int, w, h int)

func (*MapData) ToJson

func (md *MapData) ToJson(fn string) error

func (*MapData) ToXlsx

func (md *MapData) ToXlsx(fn string) error

func (*MapData) ToYaml

func (md *MapData) ToYaml(fn string) error

type PropFunc

type PropFunc func(target *Unit, addon *AddOn, state PropFuncState, targetProp []PropType, param []int, strParam []string) error

type PropFuncMgr

type PropFuncMgr struct {
	MapFunc      map[string]PropFunc
	MapBasicFunc map[PropType]BasicPropFunc
}

func (*PropFuncMgr) ChgProp

func (mgr *PropFuncMgr) ChgProp(unit *Unit, prop PropType, val int) (int, error)

func (*PropFuncMgr) Reg

func (mgr *PropFuncMgr) Reg(name string, funcItem PropFunc)

func (*PropFuncMgr) RegBasic

func (mgr *PropFuncMgr) RegBasic(prop PropType, funcBasic BasicPropFunc)

func (*PropFuncMgr) Run

func (mgr *PropFuncMgr) Run(name string, target *Unit, addon *AddOn, state PropFuncState,
	targetProp []PropType, param []int, strParam []string) error

type PropFuncState

type PropFuncState int

type PropType

type PropType int
const (
	// 这一组是基本属性
	PropTypeHP  PropType = 1 // 初始HP
	PropTypeDPS PropType = 2 // 初始dps

	// 这一组是实际参与战斗的基本属性,一般是经过培养系统以后的值
	PropTypeMaxHP  PropType = 100 // 最大HP
	PropTypeCurHP  PropType = 101 // 当前HP
	PropTypeCurDPS PropType = 102 // 当前dps

	// 这一组是状态,0/1
	PropTypeIsFirst        PropType = 1000 // 是否先手
	PropTypeIsDouble       PropType = 1001 // 是否连击
	PropTypeIsFightBack    PropType = 1002 // 是否反击
	PropTypeIsLeech        PropType = 1003 // 是否吸血
	PropTypeIsReturnDamage PropType = 1004 // 是否反伤

	// 这一组是战斗里需要用的其它属性
	PropTypeReturnDamageVal PropType = 2000 // 反伤率
	PropTypeLeechVal        PropType = 2001 // 吸血率
	PropTypeUpAtk           PropType = 2002 // 加攻
	PropTypeDownAtk         PropType = 2003 // 减攻
	PropTypeUpDamage        PropType = 2004 // 加伤
	PropTypeDownDamage      PropType = 2005 // 减伤
)

func Str2Prop

func Str2Prop(str string) (PropType, error)

type RandWeights

type RandWeights struct {
	Vals       []int `yaml:"vals"`
	ValWeights []int `yaml:"weights"`
	MaxWeight  int   `yaml:"maxweight"`
}

func (*RandWeights) GenVal

func (rw *RandWeights) GenVal() int

type RoomData

type RoomData struct {
	Width  int `yaml:"width" json:"width"`
	Height int `yaml:"height" json:"height"`
	X      int `yaml:"x" json:"x"`
	Y      int `yaml:"y" json:"y"`
}

func (*RoomData) Clone

func (rd *RoomData) Clone() *RoomData

func (*RoomData) IsInRoom

func (rd *RoomData) IsInRoom(x, y int) bool

type StageData

type StageData struct {
	ID    int
	Award []int
}

type StageDataMgr

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

func LoadStageData

func LoadStageData(fn string) (*StageDataMgr, error)

func (*StageDataMgr) GetData

func (mgr *StageDataMgr) GetData(id int) *StageData

type StageDevData

type StageDevData struct {
	Name        string // 名字,易读而已,没用
	Monsters    []int  // 怪物,id列表
	MonsterNums []int  // 怪物数量,和Monsters对应
	HP          int    // 玩家HP
	DPS         int    // 玩家DPS
	UpAtk       int    // 加攻
	DownAtk     int    // 减攻
	Equipments  []int  // 玩家装备
	MinTurn     []int  // 允许的回合数
	MaxTurn     []int  // 允许的回合数
	MinLastHP   []int  // 剩余血量百分比
	MaxLastHP   []int  // 剩余血量百分比
	MinTotalVal int    // 怪物总属性
	MaxTotalVal int    // 怪物总属性
}

func (*StageDevData) Clone

func (data *StageDevData) Clone() *StageDevData

func (*StageDevData) GetTotalMonsterNum

func (data *StageDevData) GetTotalMonsterNum() int

func (*StageDevData) RemoveMonster

func (data *StageDevData) RemoveMonster(monster int)

type StageDevDataMgr

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

func LoadStageDevData

func LoadStageDevData(fn string) (*StageDevDataMgr, error)

func (*StageDevDataMgr) GetData

func (mgr *StageDevDataMgr) GetData(index int) *StageDevData

type StaticMgr

type StaticMgr struct {
	MgrCharacter *CharacterDataMgr
	MgrItem      *ItemDataMgr
	MgrPropFunc  *PropFuncMgr
	MgrEventFunc *EventFuncMgr
	MgrStageDev  *StageDevDataMgr
	MgrStage     *StageDataMgr
	StaticGenMap *GenMapStatic
	CfgPath      string
}
var MgrStatic *StaticMgr

func LoadAllStatic

func LoadAllStatic(fnpath string) (*StaticMgr, error)

type Stats

type Stats struct {
	Title string       `json:"title"`
	Nodes []*StatsNode `json:"nodes"`
}

func Sim

func Sim(totalval int, minhp int, mindps int, minspeed int, title string, fn string) *Stats

给定初始属性,模拟全战斗

func (*Stats) Output

func (stats *Stats) Output(fn string) error

type StatsNode

type StatsNode struct {
	MainUnit      *Unit            `json:"mainUnit"`
	Total         BattlesStatsNode `json:"total"`
	ForceFirst    BattlesStatsNode `json:"forceFirst"`
	ForceNotFirst BattlesStatsNode `json:"forceNotFirst"`
}

func NewStatsNode

func NewStatsNode(unit *Unit) *StatsNode

func (*StatsNode) AddResult

func (node *StatsNode) AddResult(ret *BattleResult)

type Unit

type Unit struct {
	Props        map[PropType]int `json:"props"`
	UnitType     UnitType         `json:"unitType"`
	LstEquipment []*Equipment     `json:"-"`
	Nickname     string           `json:"-"`
	Data         *CharacterData   `json:"-"`
}

func NewUnit

func NewUnit(hp int, dps int) *Unit

func (*Unit) Attack

func (unit *Unit) Attack(target *Unit, isFirstAttack bool) bool

攻击

func (*Unit) Battle

func (unit *Unit) Battle(id int)

func (*Unit) BeHurt

func (unit *Unit) BeHurt(damage int) (bool, int)

受到伤害

func (*Unit) ChgProp

func (unit *Unit) ChgProp(prop PropType, val int) (int, error)

func (*Unit) Clone

func (unit *Unit) Clone() *Unit

func (*Unit) Equip

func (unit *Unit) Equip(id int) error

func (*Unit) GetLastHPPer

func (unit *Unit) GetLastHPPer() int

func (*Unit) HasEquipment

func (unit *Unit) HasEquipment(id int) bool

func (*Unit) IsAlive

func (unit *Unit) IsAlive() bool

是否活着

func (*Unit) ProcEvent

func (unit *Unit) ProcEvent(id int)

func (*Unit) ProcStageAward

func (unit *Unit) ProcStageAward(sd *StageData)

这个接口不用于最终环境,只用于生成局面下

func (*Unit) Reset

func (unit *Unit) Reset()

func (*Unit) RestoreHP

func (unit *Unit) RestoreHP(hp int) int

回血

func (*Unit) TakeOff

func (unit *Unit) TakeOff(id int) error

func (*Unit) UseItem

func (unit *Unit) UseItem(id int) error

type UnitType

type UnitType int
const (
	UnitTypeUnknow  UnitType = 0
	UnitTypeMoreHP  UnitType = 1
	UnitTypeHP      UnitType = 2
	UnitTypeNormal  UnitType = 3
	UnitTypeDPS     UnitType = 4
	UnitTypeMoreDPS UnitType = 5
)

Jump to

Keyboard shortcuts

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