Documentation ¶
Index ¶
- Variables
- func OnRefreshTaskChildCount(taskType int, key any, increase int64)
- func OnRefreshTaskCount(taskType int, increase int64)
- func RegRefreshTaskChildCount(taskType int, handler RefreshTaskChildCountEvent)
- func RegRefreshTaskCount(taskType int, handler RefreshTaskCountEvent)
- type Option
- func WithChild(key any, childCondition int64) Option
- func WithChildCount(key any, childCount int64) Option
- func WithCount(count int64) Option
- func WithDisableNotStartGetReward() Option
- func WithFront(fronts ...*Task) Option
- func WithLimitedTime(limitTime time.Duration) Option
- func WithOffsetTime(offset *offset.Time) Option
- func WithStartTime(startTime time.Time) Option
- type RefreshTaskChildCountEvent
- type RefreshTaskCountEvent
- type State
- type Task
- func (slf *Task) AddChildCount(key any, count int64)
- func (slf *Task) AddCount(count int64)
- func (slf *Task) FrontsIsFinish() bool
- func (slf *Task) GetCondition() int64
- func (slf *Task) GetCount() int64
- func (slf *Task) GetFronts() map[int64]*Task
- func (slf *Task) GetFrontsWithState(state State) map[int64]*Task
- func (slf *Task) GetID() int64
- func (slf *Task) GetReward(rewardHandle func() error) error
- func (slf *Task) GetState() State
- func (slf *Task) GetType() int
- func (slf *Task) IsStart() bool
- func (slf *Task) Reset()
- func (slf *Task) SetChildCount(key any, count int64)
- func (slf *Task) SetCount(count int64)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrTaskNotFinish 任务未完成 ErrTaskNotFinish = errors.New("task not finish") // ErrTaskRewardReceived 任务奖励已领取 ErrTaskRewardReceived = errors.New("task reward received") // ErrTaskNotStart 任务未开始 ErrTaskNotStart = errors.New("task not start") // ErrTaskFail 任务失败 ErrTaskFail = errors.New("task fail") )
Functions ¶
func OnRefreshTaskChildCount ¶ added in v0.0.13
OnRefreshTaskChildCount 触发任务子计数刷新事件
func OnRefreshTaskCount ¶ added in v0.0.13
OnRefreshTaskCount 触发任务计数刷新事件
func RegRefreshTaskChildCount ¶ added in v0.0.13
func RegRefreshTaskChildCount(taskType int, handler RefreshTaskChildCountEvent)
RegRefreshTaskChildCount 注册任务子计数刷新事件
func RegRefreshTaskCount ¶ added in v0.0.13
func RegRefreshTaskCount(taskType int, handler RefreshTaskCountEvent)
RegRefreshTaskCount 注册任务计数刷新事件
Types ¶
type Option ¶
type Option func(task *Task)
func WithChildCount ¶ added in v0.0.13
WithChildCount 通过初始化子计数的方式创建任务
func WithDisableNotStartGetReward ¶ added in v0.0.13
func WithDisableNotStartGetReward() Option
WithDisableNotStartGetReward 禁止未开始的任务领取奖励
func WithLimitedTime ¶ added in v0.0.13
WithLimitedTime 通过限时的方式创建任务
func WithOffsetTime ¶ added in v0.0.13
WithOffsetTime 通过指定偏移时间的方式创建任务
type RefreshTaskChildCountEvent ¶ added in v0.0.13
type RefreshTaskCountEvent ¶ added in v0.0.13
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
Task 通用任务数据结构
func (*Task) AddChildCount ¶ added in v0.0.13
AddChildCount 增加子计数
func (*Task) FrontsIsFinish ¶ added in v0.0.13
FrontsIsFinish 判断前置任务是否完成
func (*Task) GetCondition ¶ added in v0.0.13
GetCondition 获取计数条件
func (*Task) GetFrontsWithState ¶ added in v0.0.13
GetFrontsWithState 获取特定状态的前置任务
func (*Task) GetReward ¶ added in v0.0.13
GetReward 获取任务奖励
- 当任务状态为 StateFinish 时,调用 rewardHandle 函数
- 当任务状态不为 StateFinish 或奖励函数发生错误时,返回错误
func (*Task) SetChildCount ¶ added in v0.0.13
SetChildCount 设置子计数
Click to show internal directories.
Click to hide internal directories.