Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
2b979efb5c
@ -23,8 +23,11 @@ var user_builders = []*TestCase{
|
|||||||
mainType: string(comm.ModuleUser),
|
mainType: string(comm.ModuleUser),
|
||||||
subType: user.UserSubTypeAddRes,
|
subType: user.UserSubTypeAddRes,
|
||||||
req: &pb.UserAddResReq{ //设置请求参数
|
req: &pb.UserAddResReq{ //设置请求参数
|
||||||
ResType: comm.ResGold,
|
Res: &pb.UserAssets{
|
||||||
Count: 100,
|
A: comm.ResGold,
|
||||||
|
T:"",
|
||||||
|
N: 100,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
rsp: &pb.UserAddResResp{},
|
rsp: &pb.UserAddResResp{},
|
||||||
// enabled: true,
|
// enabled: true,
|
||||||
|
@ -18,6 +18,9 @@ func (this *apiComp) ActiveListCheck(session comm.IUserSession, req *pb.TaskActi
|
|||||||
|
|
||||||
func (this *apiComp) ActiveList(session comm.IUserSession, req *pb.TaskActiveListReq) (code pb.ErrorCode, data proto.Message) {
|
func (this *apiComp) ActiveList(session comm.IUserSession, req *pb.TaskActiveListReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
// this.moduleTask.ModuleTask.SendToTask(session.GetUserId(), comm.TaskTypeGetHero, &pb.TaskParam{First: 5})
|
// this.moduleTask.ModuleTask.SendToTask(session.GetUserId(), comm.TaskTypeGetHero, &pb.TaskParam{First: 5})
|
||||||
|
if code = this.ActiveListCheck(session, req); code != pb.ErrorCode_Success {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
resp := &pb.TaskActiveListResp{}
|
resp := &pb.TaskActiveListResp{}
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -17,6 +17,9 @@ func (this *apiComp) ActiveReceiveCheck(session comm.IUserSession, req *pb.TaskA
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *apiComp) ActiveReceive(session comm.IUserSession, req *pb.TaskActiveReceiveReq) (code pb.ErrorCode, data proto.Message) {
|
func (this *apiComp) ActiveReceive(session comm.IUserSession, req *pb.TaskActiveReceiveReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
|
if code = this.ActiveReceiveCheck(session, req); code != pb.ErrorCode_Success {
|
||||||
|
return
|
||||||
|
}
|
||||||
resp := &pb.TaskActiveReceiveResp{
|
resp := &pb.TaskActiveReceiveResp{
|
||||||
TaskTag: req.TaskTag,
|
TaskTag: req.TaskTag,
|
||||||
Id: req.Id,
|
Id: req.Id,
|
||||||
|
@ -18,6 +18,10 @@ func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.TaskReceive
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq) (code pb.ErrorCode, data proto.Message) {
|
func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
|
if code = this.ReceiveCheck(session, req); code != pb.ErrorCode_Success {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
resp := &pb.TaskReceiveResp{}
|
resp := &pb.TaskReceiveResp{}
|
||||||
defer func() {
|
defer func() {
|
||||||
err := session.SendMsg(string(this.moduleTask.GetType()), TaskSubTypeList, resp)
|
err := session.SendMsg(string(this.moduleTask.GetType()), TaskSubTypeList, resp)
|
||||||
|
@ -161,10 +161,6 @@ func (this *ModelTask) finishHandle(userTask *pb.DBTask, taskTag comm.TaskTag, c
|
|||||||
log.Errorf("err %v", err)
|
log.Errorf("err %v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
//修改玩家任务活跃度 成就没有活跃度
|
|
||||||
if config.IdTag != int32(comm.TASK_ACHIEVE) {
|
|
||||||
this.moduleTask.ModuleUser.AddAttributeValue(userTask.Uid, comm.ResTaskActive, config.Active)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ModuleTask struct {
|
type ModuleTask struct {
|
||||||
@ -15,8 +14,6 @@ type ModuleTask struct {
|
|||||||
modelTaskActive *ModelTaskActive
|
modelTaskActive *ModelTaskActive
|
||||||
api *apiComp
|
api *apiComp
|
||||||
configure *configureComp
|
configure *configureComp
|
||||||
lastDayTime int64 //上次日任务执行时间戳
|
|
||||||
lastWeekTime int64 //上次周任务执行时间戳
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewModule() core.IModule {
|
func NewModule() core.IModule {
|
||||||
@ -29,16 +26,6 @@ func (this *ModuleTask) GetType() core.M_Modules {
|
|||||||
|
|
||||||
func (this *ModuleTask) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
func (this *ModuleTask) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
||||||
err = this.ModuleBase.Init(service, module, options)
|
err = this.ModuleBase.Init(service, module, options)
|
||||||
|
|
||||||
go func() {
|
|
||||||
tickC := time.NewTicker(time.Second * 1)
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case tc := <-tickC.C:
|
|
||||||
this.update(tc)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,33 +43,6 @@ func (this *ModuleTask) Start() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ModuleTask) update(t time.Time) {
|
|
||||||
this.taskEveryDay(t)
|
|
||||||
this.taskWeekDay(t)
|
|
||||||
}
|
|
||||||
|
|
||||||
//日任务
|
|
||||||
func (this *ModuleTask) taskEveryDay(t time.Time) {
|
|
||||||
n := time.Now().Unix()
|
|
||||||
if t.Hour() == 4 && t.Minute() == 0 {
|
|
||||||
this.lastDayTime = n
|
|
||||||
} else {
|
|
||||||
this.lastDayTime = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//周任务
|
|
||||||
func (this *ModuleTask) taskWeekDay(t time.Time) {
|
|
||||||
n := time.Now().Unix()
|
|
||||||
if int(t.Weekday()) == 1 { //周一
|
|
||||||
if t.Hour() == 0 && t.Minute() == 0 {
|
|
||||||
this.lastWeekTime = n
|
|
||||||
} else {
|
|
||||||
this.lastWeekTime = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//初始化任务
|
//初始化任务
|
||||||
func (this *ModuleTask) InitTask(uid string, taskTag comm.TaskTag) {
|
func (this *ModuleTask) InitTask(uid string, taskTag comm.TaskTag) {
|
||||||
if err := this.modelTask.initTaskByTag(uid, taskTag); err != nil {
|
if err := this.modelTask.initTaskByTag(uid, taskTag); err != nil {
|
||||||
|
@ -104,15 +104,16 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if this.module.modelUser.isLoginFirst(user.Logintime) {
|
go func() {
|
||||||
//清空日常
|
if this.module.modelUser.isLoginFirst(user.Logintime) {
|
||||||
this.module.ModuleTask.ResetTask(user.Uid, comm.TASK_DAILY)
|
//清空日常
|
||||||
//清周常
|
this.module.ModuleTask.ResetTask(user.Uid, comm.TASK_DAILY)
|
||||||
if utils.IsAfterWeek(user.Logintime) {
|
//清周常
|
||||||
this.module.ModuleTask.ResetTask(user.Uid, comm.TASK_WEEKLY)
|
if utils.IsAfterWeek(user.Logintime) {
|
||||||
|
this.module.ModuleTask.ResetTask(user.Uid, comm.TASK_WEEKLY)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user