task

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OnTaskDoneEvent

func OnTaskDoneEvent(task *Task)

OnTaskDoneEvent 任务完成事件

func RegTaskDoneEvent

func RegTaskDoneEvent(id int64, eventId int64, handle TaskDoneEventHandle)

RegTaskDoneEvent 注册任务完成事件

func UnRegTaskDoneEvent

func UnRegTaskDoneEvent(id int64, eventId int64)

UnRegTaskDoneEvent 取消注册任务完成事件

Types

type Option

type Option func(task *Task)

func WithDone

func WithDone(done int) Option

WithDone 通过指定任务完成计数的方式创建任务

func WithInitCount

func WithInitCount(count int) Option

WithInitCount 通过初始化计数的方式创建任务

type State

type State byte

State 任务状态

const (
	StateDoing  State = iota // 进行中
	StateDone                // 已完成
	StateReward              // 已领取
)

type Task

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

func NewTask

func NewTask(id int64, options ...Option) *Task

NewTask 新建任务

func (*Task) Add

func (slf *Task) Add(count int)

Add 增加任务计数

func (*Task) GetState

func (slf *Task) GetState() State

GetState 获取任务状态

func (*Task) Reset

func (slf *Task) Reset()

Reset 重置任务

func (*Task) Reward

func (slf *Task) Reward() bool

Reward 返回是否领取过奖励,并且设置任务为领取过奖励的状态

type TaskDoneEventHandle

type TaskDoneEventHandle func(eventId int64, task *Task)

Jump to

Keyboard shortcuts

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