Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
c753d2fc90
@ -3,52 +3,46 @@ package rtask
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
func (this *apiComp) RtestCheck(session comm.IUserSession, req *pb.RtaskTestReq) (code pb.ErrorCode) {
|
||||
if len(req.Params) < 1 {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *apiComp) Rtest(session comm.IUserSession, req *pb.RtaskTestReq) (code pb.ErrorCode, data *pb.ErrorData) {
|
||||
rsp := &pb.RtaskTestResp{Flag: true, RtaskType: req.RtaskType}
|
||||
if req.CondiId != 0 {
|
||||
if code = this.module.CheckCondi(session.GetUserId(), req.CondiId); code != pb.ErrorCode_Success {
|
||||
rsp.Flag = false
|
||||
}
|
||||
} else if req.GroupId != 0 {
|
||||
// 获取当前玩家
|
||||
rtask := this.module.modelRtask.GetRtask(session.GetUserId())
|
||||
if rtask == nil {
|
||||
code = pb.ErrorCode_RtaskNoRtask
|
||||
if code = this.RtestCheck(session, req); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
||||
rtaskIds := make([]int32, 0)
|
||||
ids := strings.Split(req.RtaskIds, ",")
|
||||
for _, id := range ids {
|
||||
rtaskIds = append(rtaskIds, cast.ToInt32(id))
|
||||
rsp := &pb.RtaskTestResp{Flag: true, RtaskType: req.RtaskType}
|
||||
// 校验
|
||||
if req.CondiId != 0 {
|
||||
condIds, err := this.module.ModuleBuried.CheckCondition(session.GetUserId(), req.CondiId)
|
||||
if err == nil && len(condIds) > 0 {
|
||||
rsp.Flag = false
|
||||
}
|
||||
|
||||
if v, ok := rtask.FrtaskIds[req.GroupId]; ok {
|
||||
v.RtaskIds = rtaskIds
|
||||
} else {
|
||||
rtask.FrtaskIds = make(map[int32]*pb.FrtaskIds)
|
||||
rtask.FrtaskIds[req.GroupId] = &pb.FrtaskIds{RtaskIds: rtaskIds}
|
||||
// 触发
|
||||
} else if req.RtaskType != 0 && len(req.Params) > 0 {
|
||||
conds := []int32{}
|
||||
switch len(req.Params) {
|
||||
case 2:
|
||||
conds[0] = req.Params[1]
|
||||
case 3:
|
||||
conds[0] = req.Params[1]
|
||||
conds[1] = req.Params[2]
|
||||
case 4:
|
||||
conds[0] = req.Params[1]
|
||||
conds[1] = req.Params[2]
|
||||
conds[2] = req.Params[3]
|
||||
case 5:
|
||||
conds[0] = req.Params[1]
|
||||
conds[1] = req.Params[2]
|
||||
conds[2] = req.Params[3]
|
||||
conds[3] = req.Params[4]
|
||||
}
|
||||
|
||||
update := map[string]interface{}{
|
||||
"frtaskIds": rtask.FrtaskIds,
|
||||
}
|
||||
|
||||
this.module.modelRtask.Change(rtask.Uid, update)
|
||||
} else {
|
||||
// this.module.ModuleBuried.TriggerBuried(session.GetUserId(), &comm.BuriedParam{
|
||||
// TT: comm.TaskType(req.RtaskType),
|
||||
// Params: req.Params,
|
||||
// })
|
||||
this.module.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.TaskType(req.RtaskType), req.Params[0], conds...))
|
||||
|
||||
rsp.Flag = true
|
||||
}
|
||||
|
@ -13,12 +13,13 @@ func (this *apiComp) SendCheck(session comm.IUserSession, req *pb.TaskSendReq) (
|
||||
}
|
||||
|
||||
func (this *apiComp) Send(session comm.IUserSession, req *pb.TaskSendReq) (code pb.ErrorCode, data *pb.ErrorData) {
|
||||
if imodule, err := this.service.GetModule(comm.ModuleRtask); err == nil {
|
||||
if itask, ok := imodule.(comm.IRtask); ok {
|
||||
itask.TriggerTask(session.GetUserId(), comm.GetTaskParam(comm.TaskType(req.TaskType), req.Params...))
|
||||
}
|
||||
}
|
||||
// if imodule, err := this.service.GetModule(comm.ModuleRtask); err == nil {
|
||||
// if itask, ok := imodule.(comm.IRtask); ok {
|
||||
// itask.TriggerTask(session.GetUserId(), comm.GetTaskParam(comm.TaskType(req.TaskType), req.Params...))
|
||||
// }
|
||||
// }
|
||||
|
||||
// this.module.ModuleBuried.TriggerBuried(session.GetUserId(),comm.GetBuriedParam(comm.TaskType(req.TaskType)))
|
||||
rsp := &pb.TaskSendResp{
|
||||
IsSucc: true,
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ func (this *ModelTaskActive) Init(service core.IService, module core.IModule, co
|
||||
return
|
||||
}
|
||||
|
||||
//初始化活跃度
|
||||
// 初始化活跃度
|
||||
func (this *ModelTaskActive) initActiveReward(uid string, taskTag comm.TaskTag) {
|
||||
task := &pb.DBActivity{}
|
||||
if err := this.Get(uid, task); err != nil {
|
||||
@ -72,7 +72,7 @@ func (this *ModelTaskActive) getActiveList(uid string) (list []*pb.ActivityData)
|
||||
return task.ActivityList
|
||||
}
|
||||
|
||||
//获取玩家活跃度列表
|
||||
// 获取玩家活跃度列表
|
||||
func (this *ModelTaskActive) getActiveListByTag(uid string, taskTag comm.TaskTag) (list []*pb.ActivityData) {
|
||||
task := &pb.DBActivity{}
|
||||
if err := this.Get(uid, task); err != nil {
|
||||
@ -98,7 +98,7 @@ func (this *ModelTaskActive) noReceiveTaskActive(uid string, taskTag comm.TaskTa
|
||||
}
|
||||
task := &pb.DBActivity{}
|
||||
if err := this.Get(uid, task); err != nil {
|
||||
this.moduleTask.Errorf("getTaskActivityList err %v", err)
|
||||
// this.moduleTask.Warnf("getTaskActivityList err %v", err)
|
||||
return false, err
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ func (this *ModelTaskActive) noReceiveTaskActive(uid string, taskTag comm.TaskTa
|
||||
return false, nil
|
||||
}
|
||||
|
||||
//获取玩家活跃记录 id 唯一ID
|
||||
// 获取玩家活跃记录 id 唯一ID
|
||||
func (this *ModelTaskActive) getUserActive(uid string, taskId int32, taskTag comm.TaskTag) *pb.ActivityData {
|
||||
record := this.getActiveListByTag(uid, taskTag)
|
||||
for _, v := range record {
|
||||
@ -140,7 +140,7 @@ func (this *ModelTaskActive) updateReceive(uid string, data map[string]interface
|
||||
return this.moduleTask.modelTaskActive.Change(uid, data)
|
||||
}
|
||||
|
||||
//清空活跃度任务
|
||||
// 清空活跃度任务
|
||||
func (this *ModelTaskActive) clearTask(uid string, taskTag ...comm.TaskTag) {
|
||||
if len(taskTag) == 0 {
|
||||
this.moduleTask.Errorf("least one param for taskTag")
|
||||
|
@ -81,9 +81,6 @@ func (this *apiComp) Battlefinish(session comm.IUserSession, req *pb.WorldtaskBa
|
||||
} else {
|
||||
//触发任务
|
||||
go this.module.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype70, 1, req.BattleConfId))
|
||||
}
|
||||
}
|
||||
}
|
||||
if userTask.CurrentTask == nil {
|
||||
userTask.CurrentTask = make(map[int32]*pb.Worldtask)
|
||||
}
|
||||
@ -101,11 +98,15 @@ func (this *apiComp) Battlefinish(session comm.IUserSession, req *pb.WorldtaskBa
|
||||
}
|
||||
|
||||
//推送
|
||||
session.SendMsg(string(this.module.GetType()), "completecondis", &pb.WorldtaskCompletecondisPush{
|
||||
GroupId: req.GroupId,
|
||||
TaskId: req.TaskId,
|
||||
CondiIds: userTask.CurrentTask[req.GroupId].CondiIds,
|
||||
})
|
||||
// session.SendMsg(string(this.module.GetType()), "completecondis", &pb.WorldtaskCompletecondisPush{
|
||||
// GroupId: req.GroupId,
|
||||
// TaskId: req.TaskId,
|
||||
// CondiIds: userTask.CurrentTask[req.GroupId].CondiIds,
|
||||
// })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
rsp.Code = code
|
||||
this.sendMsg(session, WorldtaskBattleFinish, rsp)
|
||||
|
Loading…
Reference in New Issue
Block a user