fight

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Round

type Round[Data RoundData] struct {
	// contains filtered or unexported fields
}

Round 回合制游戏结构

func NewRound

func NewRound[Data RoundData](data Data, camps []*RoundCamp, roundGameOverVerifyHandle RoundGameOverVerifyHandle[Data], options ...RoundOption[Data]) *Round[Data]

NewRound 创建一个新的回合制游戏

  • data 游戏数据
  • camps 阵营
  • roundGameOverVerifyHandle 游戏结束验证函数
  • options 选项

func (*Round[Data]) ActionFinish

func (slf *Round[Data]) ActionFinish()

ActionFinish 结束行动

func (*Round[Data]) ActionRefresh

func (slf *Round[Data]) ActionRefresh()

ActionRefresh 刷新行动超时时间

func (*Round[Data]) AllowAction

func (slf *Round[Data]) AllowAction(camp, entity int) bool

AllowAction 是否允许行动

func (*Round[Data]) CampAllowAction

func (slf *Round[Data]) CampAllowAction(camp int) bool

CampAllowAction 阵容是否允许行动

func (*Round[Data]) GetActionTimeoutTime added in v0.0.24

func (slf *Round[Data]) GetActionTimeoutTime() int64

GetActionTimeoutTime 获取行动超时时间

func (*Round[Data]) GetCurrent

func (slf *Round[Data]) GetCurrent() (camp, entity int)

GetCurrent 获取当前行动的阵营和对象

func (*Round[Data]) GetCurrentCamp

func (slf *Round[Data]) GetCurrentCamp() int

GetCurrentCamp 获取当前行动的阵营

func (*Round[Data]) GetCurrentRoundProgressRate

func (slf *Round[Data]) GetCurrentRoundProgressRate() float64

GetCurrentRoundProgressRate 获取当前回合进度

func (*Round[Data]) GetData

func (slf *Round[Data]) GetData() Data

GetData 获取游戏数据

func (*Round[Data]) GetRound

func (slf *Round[Data]) GetRound() int

GetRound 获取当前回合数

func (*Round[Data]) OnActionRefreshEvent added in v0.0.24

func (slf *Round[Data]) OnActionRefreshEvent()

OnActionRefreshEvent 触发行动刷新事件

func (*Round[Data]) OnActionTimeoutEvent

func (slf *Round[Data]) OnActionTimeoutEvent()

OnActionTimeoutEvent 触发行动超时事件

func (*Round[Data]) OnChangeEvent

func (slf *Round[Data]) OnChangeEvent()

OnChangeEvent 触发回合变更事件

func (*Round[Data]) OnGameOverEvent

func (slf *Round[Data]) OnGameOverEvent()

OnGameOverEvent 触发游戏结束事件

func (*Round[Data]) OnSwapCampEvent

func (slf *Round[Data]) OnSwapCampEvent()

OnSwapCampEvent 触发阵营交换事件

func (*Round[Data]) OnSwapEntityEvent

func (slf *Round[Data]) OnSwapEntityEvent()

OnSwapEntityEvent 触发实体交换事件

func (*Round[Data]) Release

func (slf *Round[Data]) Release()

Release 释放资源

func (*Round[Data]) Reset added in v0.0.24

func (slf *Round[Data]) Reset()

Reset 重置回合

func (*Round[Data]) SetCurrent

func (slf *Round[Data]) SetCurrent(campId int, entityId int)

SetCurrent 设置当前行动对象

func (*Round[Data]) SkipCamp

func (slf *Round[Data]) SkipCamp()

SkipCamp 跳过当前阵营剩余对象的行动

func (*Round[Data]) Start added in v0.0.24

func (slf *Round[Data]) Start()

Start 开始回合

  • 将通过传入的 Camp 进行初始化,Camp 为一个二维数组,每个数组内的元素都是一个行动标识

func (*Round[Data]) Stop added in v0.0.24

func (slf *Round[Data]) Stop()

Stop 停止回合

  • 停止回合时仅会停止行动超时计时器,其他所有数据均会保留
  • 若要重置回合,需要调用 Reset 方法

type RoundActionRefreshEvent added in v0.0.24

type RoundActionRefreshEvent[Data RoundData] func(round *Round[Data], campId, entity int)

type RoundActionTimeoutEvent

type RoundActionTimeoutEvent[Data RoundData] func(round *Round[Data], campId, entity int)

type RoundCamp

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

RoundCamp 回合制游戏阵营

func NewRoundCamp

func NewRoundCamp(campId, entity int, entities ...int) *RoundCamp

NewRoundCamp 创建一个新的回合制游戏阵营

type RoundChangeEvent

type RoundChangeEvent[Data RoundData] func(round *Round[Data])

type RoundData

type RoundData interface {
}

RoundData 回合制游戏数据

type RoundGameOverEvent

type RoundGameOverEvent[Data RoundData] func(round *Round[Data])

type RoundGameOverVerifyHandle

type RoundGameOverVerifyHandle[Data RoundData] func(round *Round[Data]) bool

RoundGameOverVerifyHandle 回合制游戏结束验证函数

type RoundOption

type RoundOption[Data RoundData] func(round *Round[Data])

RoundOption 回合制游戏选项

func WithRoundActionRefreshEvent added in v0.0.24

func WithRoundActionRefreshEvent[Data RoundData](refreshEventHandle RoundActionRefreshEvent[Data]) RoundOption[Data]

WithRoundActionRefreshEvent 设置游戏的行动刷新事件

func WithRoundActionTimeout

func WithRoundActionTimeout[Data RoundData](timeout time.Duration) RoundOption[Data]

WithRoundActionTimeout 设置游戏的行动超时时间

func WithRoundActionTimeoutEvent

func WithRoundActionTimeoutEvent[Data RoundData](timeoutEventHandle RoundActionTimeoutEvent[Data]) RoundOption[Data]

WithRoundActionTimeoutEvent 设置游戏的超时事件

func WithRoundCampCounterclockwise

func WithRoundCampCounterclockwise[Data RoundData]() RoundOption[Data]

WithRoundCampCounterclockwise 设置游戏阵营逆序执行

func WithRoundChangeEvent

func WithRoundChangeEvent[Data RoundData](changeEventHandle RoundChangeEvent[Data]) RoundOption[Data]

WithRoundChangeEvent 设置游戏的回合变更事件

  • 该事件在触发时已经完成了回合的变更

func WithRoundEntityCounterclockwise

func WithRoundEntityCounterclockwise[Data RoundData]() RoundOption[Data]

WithRoundEntityCounterclockwise 设置游戏实体逆序执行

func WithRoundGameOverEvent

func WithRoundGameOverEvent[Data RoundData](gameOverEventHandle RoundGameOverEvent[Data]) RoundOption[Data]

WithRoundGameOverEvent 设置游戏的结束事件

func WithRoundShareAction

func WithRoundShareAction[Data RoundData](share bool) RoundOption[Data]

WithRoundShareAction 设置游戏的行动是否共享

func WithRoundSwapCampEvent

func WithRoundSwapCampEvent[Data RoundData](swapCampEventHandle RoundSwapCampEvent[Data]) RoundOption[Data]

WithRoundSwapCampEvent 设置游戏的阵营交换事件

  • 该事件在触发时已经完成了阵营的交换

func WithRoundSwapEntityEvent

func WithRoundSwapEntityEvent[Data RoundData](swapEntityEventHandle RoundSwapEntityEvent[Data]) RoundOption[Data]

WithRoundSwapEntityEvent 设置游戏的实体交换事件

  • 该事件在触发时已经完成了实体的交换

func WithRoundTicker

func WithRoundTicker[Data RoundData](ticker *timer.Ticker) RoundOption[Data]

WithRoundTicker 设置游戏的计时器

type RoundSwapCampEvent

type RoundSwapCampEvent[Data RoundData] func(round *Round[Data], campId int)

type RoundSwapEntityEvent

type RoundSwapEntityEvent[Data RoundData] func(round *Round[Data], campId, entity int)

Jump to

Keyboard shortcuts

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