任务完成批处理

This commit is contained in:
meixiongfeng 2023-07-11 19:50:53 +08:00
parent ae2747e484
commit bc0c9f55c7
3 changed files with 23 additions and 21 deletions

View File

@ -16,7 +16,7 @@ type (
}
//任务完成
ITaskComplete interface {
TaskComplete(session IUserSession, taskid int32)
TaskComplete(session IUserSession, taskid ...int32)
}
//功能开启通知
IOpenCmdNotice interface {

View File

@ -307,7 +307,7 @@ func (this *Caravan) CleanCaravanTask(uid string, data *pb.DBCaravan) {
}
}
func (this *Caravan) TaskComplete(session comm.IUserSession, taskid int32) {
func (this *Caravan) TaskComplete(session comm.IUserSession, taskid ...int32) {
this.Debug("Caravan TaskComplete",
log.Field{Key: "session", Value: session.GetUserId()},
log.Field{Key: "taskid", Value: taskid},
@ -316,27 +316,29 @@ func (this *Caravan) TaskComplete(session comm.IUserSession, taskid int32) {
resp *pb.CaravanTaskCompletePush
)
if !this.IsCross() {
list, _ := this.modelCaravan.getCaravanList(session.GetUserId())
if list.Taskid == taskid {
if conf, err := this.configure.GetCaravanEventById(list.Eventid); err == nil {
this.CleanCaravanTask(session.GetUserId(), list) //任务完成 清理任务数据
resp = &pb.CaravanTaskCompletePush{}
resp.Data = list
resp.BSuccess = true
for _, v := range conf.Reword {
resp.Reward = append(resp.Reward, &pb.UserAssets{
A: v.A,
T: v.T,
N: v.N,
})
for _, t := range taskid {
list, _ := this.modelCaravan.getCaravanList(session.GetUserId())
if list.Taskid == t {
if conf, err := this.configure.GetCaravanEventById(list.Eventid); err == nil {
this.CleanCaravanTask(session.GetUserId(), list) //任务完成 清理任务数据
resp = &pb.CaravanTaskCompletePush{}
resp.Data = list
resp.BSuccess = true
for _, v := range conf.Reword {
resp.Reward = append(resp.Reward, &pb.UserAssets{
A: v.A,
T: v.T,
N: v.N,
})
}
if errdata := this.ModuleBase.DispenseRes(session, conf.Reword, true); errdata != nil {
this.Errorf("Caravan DispenseRes err:%v", conf.Reword)
}
session.SendMsg(string(this.GetType()), "taskcomplete", resp)
}
if errdata := this.ModuleBase.DispenseRes(session, conf.Reword, true); errdata != nil {
this.Errorf("Caravan DispenseRes err:%v", conf.Reword)
}
session.SendMsg(string(this.GetType()), "taskcomplete", resp)
}
}
}
}

View File

@ -196,7 +196,7 @@ func (this *Practice) AddItems(session comm.IUserSession, items map[string]int32
}
// 完成世界任务
func (this *Practice) TaskComplete(session comm.IUserSession, taskid int32) {
func (this *Practice) TaskComplete(session comm.IUserSession, taskid ...int32) {
this.Debug("TaskComplete",
log.Field{Key: "session", Value: session.GetUserId()},
log.Field{Key: "taskid", Value: taskid},