/** 任务承接条件判断 task_id: 任务编号 false:失败 true:成功 */ func (tb *TaskBaseRule) OnTestTaskAccept(player *entity.Player, task *Task) bool { //是否已经接了 if player.TaskAccepted_r.FindID(task.ID) != -1 { return false } //前置任务是否已经完成 if task.PreTaskId != "" && task.PreTaskId != "0" { row := player.TaskAccepted_r.FindID(task.PreTaskId) if row == -1 { return false } if flag, _ := player.TaskAccepted_r.GetFlag(row); flag != TASK_FLAG_COMPLETE { return false } } //等级是否满足条件 if task.Level > int32(player.GetLevel()) { return false } return true }
func (tb *TaskBase) AddPropRecord(player *entity.Player, taskid string, property string, needval string) bool { if property == "" { return true } val, err := player.Get(property) //没有这个属性 if err != nil { log.LogError("task need property not found, ", property) return true } res, err := datatype.CompareNumber(needval, val) if err != nil { log.LogError(err) return true } row := player.TaskPropRecord_r.FindID(taskid) //表中是否已经有记录 for row != -1 { _, prop, _, _ := player.TaskPropRecord_r.GetRow(row) if prop == property { if res <= 0 { //已经满条件,删除这条记录 player.TaskPropRecord_r.Del(row) return true } return false } row = player.TaskRecord_r.FindNextID(taskid, row) } if res <= 0 { return true } player.TaskPropRecord_r.AddRowValue(-1, taskid, property, needval) return false }