Documentation ¶
Index ¶
- Constants
- Variables
- func AbsInt(v int) int
- func CalcWinTimesWithAI1(event *Event, num int, unit *Unit) int
- func CalcWinTimesWithAI2(event *Event, num int, unit *Unit) int
- func CountAvgLastHPPer(lst []*Event) int
- func CountEventNum(lst []*Event) int
- func CountNumWithID(lst []*Event, id int) int
- func CountWidth(lst []*Event) int
- func ForEach(data *StageDevData, arr []int, each FuncForEachStageDevData)
- func GenEnemy2(index int) error
- func GetHPAreaForUnitType(ut UnitType, total int) (int, int)
- func InitSystem(fnpath string) error
- func IsEquipment(id int) bool
- func IsItem(id int) bool
- func IsLeafNode(e *Event) bool
- func IsMonster(id int) bool
- func SaveEvents(fn string, events [][]*Event) error
- func SaveEvents2(fn string, events []*Event) error
- func UnitType2Str(ut UnitType) (string, error)
- type AddOn
- type BasicPropFunc
- type BattleResult
- type BattlesStatsNode
- type CharacterData
- type CharacterDataMgr
- type Equipment
- type Event
- func (event *Event) Add2Last(id int)
- func (event *Event) AddChild(e *Event)
- func (event *Event) BuildNextEvents() []*Event
- func (event *Event) BuildNextEventsEx(eachEvent ForEachEventFunc) []*Event
- func (event *Event) Clone() *Event
- func (event *Event) CloneOnlyMe() *Event
- func (event *Event) CountID(id int) int
- func (event *Event) CountNodes() int
- func (event *Event) ForEach(funcForEach ForEachEventFunc) bool
- func (event *Event) GetLeafNodes() []*Event
- func (event *Event) GetName() string
- func (event *Event) GetNotValidLeafNodes() []*Event
- func (event *Event) GetValidLeafNodes() []*Event
- func (event *Event) OutputExcel(f *excelize.File, sheet string) error
- type EventFunc
- type EventFuncMgr
- type EventPool
- type ForEachEventFunc
- type FuncForEachStageDevData
- type GenDPSLevelUp2Result
- type GenDPSLevelUpResult
- type GenDownAtkLevelUp2Result
- type GenDownAtkLevelUpResult
- type GenEnemyBattleResult
- type GenEnemyParam
- type GenEnemyResult
- type GenEnemyResultDetail
- type GenEnemyResultNode
- type GenEventData
- type GenEventFuncData
- type GenHPLevelUpResult
- type GenMapParams
- type GenMapRoomData
- type GenMapStatic
- func (params *GenMapStatic) IsDoor(v int) bool
- func (params *GenMapStatic) IsFloor(v int) bool
- func (params *GenMapStatic) IsNonRoomWall(v int) bool
- func (params *GenMapStatic) IsNotNearWall(v int) bool
- func (params *GenMapStatic) IsRoomFloor(v int) bool
- func (params *GenMapStatic) IsWall(v int) bool
- type ItemData
- type ItemDataMgr
- type MapData
- func (md *MapData) CalcValidTileNum(sx, sy int) int
- func (md *MapData) Clone() *MapData
- func (md *MapData) GenRoomPos(w, h int) []int
- func (md *MapData) GenRooms(lst []int) *MapData
- func (md *MapData) GetHeight() int
- func (md *MapData) GetWidth() int
- func (md *MapData) IsInRoom(x, y int) bool
- func (md *MapData) IsValidMap() bool
- func (md *MapData) IsValidPos(x, y int) bool
- func (md *MapData) SetRoom(sx, sy int, w, h int)
- func (md *MapData) ToJson(fn string) error
- func (md *MapData) ToXlsx(fn string) error
- func (md *MapData) ToYaml(fn string) error
- type PropFunc
- type PropFuncMgr
- func (mgr *PropFuncMgr) ChgProp(unit *Unit, prop PropType, val int) (int, error)
- func (mgr *PropFuncMgr) Reg(name string, funcItem PropFunc)
- func (mgr *PropFuncMgr) RegBasic(prop PropType, funcBasic BasicPropFunc)
- func (mgr *PropFuncMgr) Run(name string, target *Unit, addon *AddOn, state PropFuncState, ...) error
- type PropFuncState
- type PropType
- type RandWeights
- type RoomData
- type StageData
- type StageDataMgr
- type StageDevData
- type StageDevDataMgr
- type StaticMgr
- type Stats
- type StatsNode
- type Unit
- func (unit *Unit) Attack(target *Unit, isFirstAttack bool) bool
- func (unit *Unit) Battle(id int)
- func (unit *Unit) BeHurt(damage int) (bool, int)
- func (unit *Unit) ChgProp(prop PropType, val int) (int, error)
- func (unit *Unit) Clone() *Unit
- func (unit *Unit) Equip(id int) error
- func (unit *Unit) GetLastHPPer() int
- func (unit *Unit) HasEquipment(id int) bool
- func (unit *Unit) IsAlive() bool
- func (unit *Unit) ProcEvent(id int)
- func (unit *Unit) ProcStageAward(sd *StageData)
- func (unit *Unit) Reset()
- func (unit *Unit) RestoreHP(hp int) int
- func (unit *Unit) TakeOff(id int) error
- func (unit *Unit) UseItem(id int) error
- type UnitType
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 CalcWinTimesWithAI1 ¶
返回AI1玩num次,成功的次数
func CalcWinTimesWithAI2 ¶
返回AI2玩num次,成功的次数
func CountAvgLastHPPer ¶
func CountEventNum ¶
func CountNumWithID ¶
func CountWidth ¶
func ForEach ¶
func ForEach(data *StageDevData, arr []int, each FuncForEachStageDevData)
func InitSystem ¶
func IsEquipment ¶
func IsLeafNode ¶
func SaveEvents ¶
func SaveEvents2 ¶
func UnitType2Str ¶
Types ¶
type BasicPropFunc ¶
基本属性修改,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 CharacterData ¶
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)
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 GenEventWithStage ¶
func GenMultiLineEvent ¶
func (*Event) BuildNextEventsEx ¶
func (event *Event) BuildNextEventsEx(eachEvent ForEachEventFunc) []*Event
获得可以达到的全部event,增加一个外部接口来判断
func (*Event) CloneOnlyMe ¶
func (*Event) CountNodes ¶
func (*Event) ForEach ¶
func (event *Event) ForEach(funcForEach ForEachEventFunc) bool
func (*Event) GetLeafNodes ¶
func (*Event) GetNotValidLeafNodes ¶
func (*Event) GetValidLeafNodes ¶
func (*Event) OutputExcel ¶
type EventFuncMgr ¶
type EventFuncMgr struct {
// contains filtered or unexported fields
}
func (*EventFuncMgr) Reg ¶
func (mgr *EventFuncMgr) Reg(name string, funcEvent EventFunc)
type EventPool ¶
type EventPool struct {
Events []*GenEventData `yaml:"events"`
}
func LoadEventPool ¶
type ForEachEventFunc ¶
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 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 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 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 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 (*MapData) CalcValidTileNum ¶
func (*MapData) GenRoomPos ¶
func (*MapData) IsValidPos ¶
type PropFuncMgr ¶
type PropFuncMgr struct { MapFunc map[string]PropFunc MapBasicFunc map[PropType]BasicPropFunc }
func (*PropFuncMgr) Reg ¶
func (mgr *PropFuncMgr) Reg(name string, funcItem PropFunc)
func (*PropFuncMgr) RegBasic ¶
func (mgr *PropFuncMgr) RegBasic(prop PropType, funcBasic BasicPropFunc)
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 // 减伤 )
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 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 ¶
type StatsNode ¶
type StatsNode struct { MainUnit *Unit `json:"mainUnit"` Total BattlesStatsNode `json:"total"` ForceFirst BattlesStatsNode `json:"forceFirst"` ForceNotFirst BattlesStatsNode `json:"forceNotFirst"` }
func NewStatsNode ¶
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 (*Unit) GetLastHPPer ¶
func (*Unit) HasEquipment ¶
Source Files ¶
- addon.go
- ai1.go
- ai2.go
- basicdef.go
- basicpropfunc.go
- battle.go
- characterdata.go
- equipment.go
- err.go
- event.go
- eventfunc.go
- eventpool.go
- eventutils.go
- genenemy.go
- genenemy2.go
- genevent.go
- genlevelupdownatk.go
- genlevelupdownatk2.go
- genlevelupdps.go
- genlevelupdps2.go
- genleveluphp.go
- genmap.go
- genmap2.go
- genmapparams.go
- genmapstatic.go
- itemdata.go
- map.go
- propfunc.go
- randutils.go
- sim.go
- stagedata.go
- stagedev.go
- staticmgr.go
- stats.go
- unit.go
- utils.go
- xlsxutils.go
Click to show internal directories.
Click to hide internal directories.