更新随机任务战斗任务
This commit is contained in:
parent
05fff27c2f
commit
6c8c6fba73
44
cmd/v2/ui/views/hero_zhaomu.go
Normal file
44
cmd/v2/ui/views/hero_zhaomu.go
Normal file
@ -0,0 +1,44 @@
|
||||
package formview
|
||||
|
||||
import (
|
||||
"go_dreamfactory/cmd/v2/model"
|
||||
"go_dreamfactory/cmd/v2/service"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
type HeroZhaomuView struct {
|
||||
BaseformView
|
||||
}
|
||||
|
||||
func (this *HeroZhaomuView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
||||
|
||||
var ckType, ckCount string
|
||||
// 抽卡类型 0 1 2 3 4
|
||||
ckTypeSelect := widget.NewSelect([]string{"0", "1", "2", "3", "4"}, func(s string) {
|
||||
ckType = s
|
||||
})
|
||||
|
||||
//数量
|
||||
ckCountSelect := widget.NewSelect([]string{"1", "10"}, func(s string) {
|
||||
ckCount = s
|
||||
})
|
||||
|
||||
this.form.AppendItem(widget.NewFormItem("抽卡类型", ckTypeSelect))
|
||||
this.form.AppendItem(widget.NewFormItem("数量", ckCountSelect))
|
||||
|
||||
this.form.OnSubmit = func() {
|
||||
if err := service.GetPttService().SendToClient(t.MainType, t.SubType,
|
||||
&pb.HeroDrawCardReq{
|
||||
DrawType: cast.ToInt32(ckType),
|
||||
DrawCount: cast.ToInt32(ckCount),
|
||||
}); err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
}
|
||||
return this.form
|
||||
}
|
33
cmd/v2/ui/views/rtask_battlefinish.go
Normal file
33
cmd/v2/ui/views/rtask_battlefinish.go
Normal file
@ -0,0 +1,33 @@
|
||||
package formview
|
||||
|
||||
import (
|
||||
"go_dreamfactory/cmd/v2/model"
|
||||
"go_dreamfactory/cmd/v2/service"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
type RtaskBattleFinishView struct {
|
||||
BaseformView
|
||||
}
|
||||
|
||||
func (this *RtaskBattleFinishView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
||||
taskId := widget.NewEntry()
|
||||
|
||||
this.form.AppendItem(widget.NewFormItem("任务ID", taskId))
|
||||
|
||||
this.form.OnSubmit = func() {
|
||||
if err := service.GetPttService().SendToClient(t.MainType, t.SubType,
|
||||
&pb.RtaskBattleFinishReq{
|
||||
RtaskId: cast.ToInt32(taskId.Text),
|
||||
}); err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
return this.form
|
||||
}
|
43
cmd/v2/ui/views/rtask_battlestart.go
Normal file
43
cmd/v2/ui/views/rtask_battlestart.go
Normal file
@ -0,0 +1,43 @@
|
||||
package formview
|
||||
|
||||
import (
|
||||
"go_dreamfactory/cmd/v2/model"
|
||||
"go_dreamfactory/cmd/v2/service"
|
||||
"go_dreamfactory/pb"
|
||||
"strings"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
type RtaskBattlestartView struct {
|
||||
BaseformView
|
||||
}
|
||||
|
||||
func (this *RtaskBattlestartView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
||||
confId := widget.NewEntry()
|
||||
|
||||
leadpos := widget.NewEntry()
|
||||
|
||||
teamIds := widget.NewEntry()
|
||||
teamIds.PlaceHolder = ",号分隔"
|
||||
|
||||
this.form.AppendItem(widget.NewFormItem("关卡ID", confId))
|
||||
this.form.AppendItem(widget.NewFormItem("队长位置", leadpos))
|
||||
this.form.AppendItem(widget.NewFormItem("阵容信息", teamIds))
|
||||
|
||||
this.form.OnSubmit = func() {
|
||||
if err := service.GetPttService().SendToClient(t.MainType, t.SubType,
|
||||
|
||||
&pb.RtaskBattleStartReq{
|
||||
BattleConfId: cast.ToInt32(confId.Text),
|
||||
Leadpos: cast.ToInt32(leadpos.Text),
|
||||
Teamids: strings.Split(teamIds.Text, ","),
|
||||
}); err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
}
|
||||
return this.form
|
||||
}
|
@ -290,6 +290,7 @@ const (
|
||||
Rtype67 TaskType = 67 //商店购物消耗xx货币xx个
|
||||
Rtype68 TaskType = 68 //任意渠道消耗xx金币
|
||||
Rtype69 TaskType = 69 //与其他玩家切磋xx次
|
||||
Rtype70 TaskType = 70 //通关随机任务XX关卡
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -202,11 +202,11 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype17, k, v)
|
||||
}
|
||||
}
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype14, drawCount)
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype18, drawCount)
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype14, req.DrawCount)
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype18, req.DrawCount)
|
||||
} else { // 阵营招募
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype15, drawCount)
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype19, drawCount)
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype15, req.DrawCount)
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype19, req.DrawCount)
|
||||
}
|
||||
for _, star := range szStar {
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype16, star, 1)
|
||||
|
@ -10,6 +10,8 @@ const (
|
||||
RtaskSubTypeList = "list" //随机任务列表
|
||||
RtaskSubTypeApply = "apply" //做任务
|
||||
RtaskSubTypeReward = "getreward" //奖励
|
||||
RtaskSubTypeBattleStart = "battlestart" //战斗开始
|
||||
RtaskSubTypeBattleFinish = "battlefinish" //战斗完成
|
||||
)
|
||||
|
||||
type apiComp struct {
|
||||
|
85
modules/rtask/api_battlefinish.go
Normal file
85
modules/rtask/api_battlefinish.go
Normal file
@ -0,0 +1,85 @@
|
||||
package rtask
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func (this *apiComp) BattleFinishCheck(session comm.IUserSession, req *pb.RtaskBattleFinishReq) (code pb.ErrorCode) {
|
||||
if req.RtaskId == 0 {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *apiComp) BattleFinish(session comm.IUserSession, req *pb.RtaskBattleFinishReq) (code pb.ErrorCode, data proto.Message) {
|
||||
if code = this.BattleFinishCheck(session, req); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
||||
//校验战斗结果
|
||||
iBattle, err := this.moduleRtask.modelRtask.service.GetModule(comm.ModuleBattle)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
|
||||
var isWin bool
|
||||
if b, y := iBattle.(comm.IBattle); y {
|
||||
if code, isWin = b.CheckBattleReport(session, req.Report); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
||||
if isWin {
|
||||
// 获取玩家的任务
|
||||
rtask := &pb.DBRtask{}
|
||||
if err := this.moduleRtask.modelRtask.Get(session.GetUserId(), rtask); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 获取当前任务配置
|
||||
conf := this.moduleRtask.configure.getRtaskById(req.RtaskId)
|
||||
if conf == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
log.Errorf("rdtask %v no found", req.RtaskId)
|
||||
return
|
||||
}
|
||||
|
||||
var (
|
||||
frtaskArr *pb.FrtaskIds //完成的任务
|
||||
ok bool
|
||||
)
|
||||
|
||||
if frtaskArr, ok = rtask.FrtaskIds[conf.Group]; !ok {
|
||||
frtaskArr = &pb.FrtaskIds{}
|
||||
}
|
||||
|
||||
// 更新完成的任务
|
||||
frtaskArr.RtaskIds = append(frtaskArr.RtaskIds, req.RtaskId)
|
||||
if rtask.FrtaskIds == nil {
|
||||
rtask.FrtaskIds = make(map[int32]*pb.FrtaskIds)
|
||||
}
|
||||
rtask.FrtaskIds[conf.Group] = frtaskArr
|
||||
update := map[string]interface{}{
|
||||
"frtaskIds": rtask.FrtaskIds,
|
||||
}
|
||||
if err := this.moduleRtask.modelRtask.Change(session.GetUserId(), update); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.moduleRtask.GetType()), RtaskSubTypeBattleFinish,
|
||||
&pb.RtaskBattleFinishResp{
|
||||
RtaskId: req.RtaskId,
|
||||
IsWin: isWin,
|
||||
}); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
|
||||
return
|
||||
}
|
71
modules/rtask/api_battlestart.go
Normal file
71
modules/rtask/api_battlestart.go
Normal file
@ -0,0 +1,71 @@
|
||||
package rtask
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func (this *apiComp) BattleStartCheck(session comm.IUserSession, req *pb.RtaskBattleStartReq) (code pb.ErrorCode) {
|
||||
if req.BattleConfId == 0 {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *apiComp) BattleStart(session comm.IUserSession, req *pb.RtaskBattleStartReq) (code pb.ErrorCode, data proto.Message) {
|
||||
if code = this.BattleStartCheck(session, req); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
||||
battleConf := this.moduleRtask.configure.getRtaskBattleById(req.BattleConfId)
|
||||
if battleConf == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
log.Errorf("rdtask_battle %v no found", req.BattleConfId)
|
||||
return
|
||||
}
|
||||
|
||||
iBattle, err := this.moduleRtask.modelRtask.service.GetModule(comm.ModuleBattle)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
|
||||
if b, y := iBattle.(comm.IBattle); y {
|
||||
var (
|
||||
record *pb.DBBattleRecord
|
||||
resp *pb.RtaskBattleStartResp
|
||||
)
|
||||
code, record = b.CreatePveBattle(session, &pb.BattlePVEReq{
|
||||
Ptype: pb.PlayType_mainline,
|
||||
Leadpos: req.Leadpos,
|
||||
Teamids: req.Teamids,
|
||||
Mformat: battleConf.FormatList,
|
||||
})
|
||||
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
||||
if record != nil {
|
||||
resp = &pb.RtaskBattleStartResp{
|
||||
Info: &pb.BattleInfo{
|
||||
Id: record.Id,
|
||||
Btype: record.Btype,
|
||||
Ptype: record.Ptype,
|
||||
RedCompId: record.RedCompId,
|
||||
Redflist: record.Redflist,
|
||||
BlueCompId: record.BlueCompId,
|
||||
Buleflist: record.Buleflist,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.moduleRtask.GetType()), RtaskSubTypeBattleStart, resp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
@ -2,6 +2,7 @@ package rtask
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/utils"
|
||||
|
||||
@ -20,6 +21,7 @@ func (this *apiComp) Choose(session comm.IUserSession, req *pb.RtaskChooseReq) (
|
||||
return
|
||||
}
|
||||
|
||||
// 获取玩家的任务
|
||||
rtask := &pb.DBRtask{}
|
||||
if err := this.moduleRtask.modelRtask.Get(session.GetUserId(), rtask); err != nil {
|
||||
return
|
||||
@ -29,6 +31,7 @@ func (this *apiComp) Choose(session comm.IUserSession, req *pb.RtaskChooseReq) (
|
||||
conf := this.moduleRtask.configure.getRtaskById(req.RtaskId)
|
||||
if conf == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
log.Errorf("rdtask %v no found", req.RtaskId)
|
||||
return
|
||||
}
|
||||
|
||||
@ -36,6 +39,7 @@ func (this *apiComp) Choose(session comm.IUserSession, req *pb.RtaskChooseReq) (
|
||||
sideConf := this.moduleRtask.configure.getRtaskSidById(req.RtaskSubId)
|
||||
if sideConf == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
log.Errorf("rdtask_side %v no found", req.RtaskSubId)
|
||||
return
|
||||
}
|
||||
|
||||
@ -43,6 +47,7 @@ func (this *apiComp) Choose(session comm.IUserSession, req *pb.RtaskChooseReq) (
|
||||
chooseCnf := this.moduleRtask.configure.getRtaskChooseCfg(req.ChooseId)
|
||||
if chooseCnf == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
log.Errorf("rdtask_choose %v no found", req.ChooseId)
|
||||
return
|
||||
}
|
||||
|
||||
@ -54,7 +59,7 @@ func (this *apiComp) Choose(session comm.IUserSession, req *pb.RtaskChooseReq) (
|
||||
}
|
||||
|
||||
var (
|
||||
frtaskArr *pb.FrtaskIds
|
||||
frtaskArr *pb.FrtaskIds //完成的任务
|
||||
ok bool
|
||||
)
|
||||
|
||||
@ -68,6 +73,7 @@ func (this *apiComp) Choose(session comm.IUserSession, req *pb.RtaskChooseReq) (
|
||||
return
|
||||
}
|
||||
|
||||
if chooseCnf.GotoLevel == "" {
|
||||
// 更新完成的任务
|
||||
frtaskArr.RtaskIds = append(frtaskArr.RtaskIds, req.RtaskId)
|
||||
if rtask.FrtaskIds == nil {
|
||||
@ -79,6 +85,8 @@ func (this *apiComp) Choose(session comm.IUserSession, req *pb.RtaskChooseReq) (
|
||||
}
|
||||
if err := this.moduleRtask.modelRtask.Change(session.GetUserId(), update); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
rsp := &pb.RtaskChooseResp{
|
||||
|
@ -2,6 +2,7 @@ package rtask
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/utils"
|
||||
|
||||
@ -30,6 +31,7 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.RtaskApplyReq) (co
|
||||
conf := this.moduleRtask.configure.getRtaskById(req.RtaskId)
|
||||
if conf == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
log.Errorf("rdtask %v no found", req.RtaskId)
|
||||
return
|
||||
}
|
||||
|
||||
@ -60,6 +62,7 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.RtaskApplyReq) (co
|
||||
sideConf := this.moduleRtask.configure.getRtaskSidById(req.RtaskSubId)
|
||||
if sideConf == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
log.Errorf("rdtask_side %v no found", req.RtaskSubId)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1,24 +0,0 @@
|
||||
package rtask
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func (this *apiComp) BattleFinishCheck(session comm.IUserSession, req *pb.RtaskBattleFinishReq) (code pb.ErrorCode) {
|
||||
if req.Result == 0 {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *apiComp) BattleFinish(session comm.IUserSession, req *pb.RtaskBattleFinishReq) (code pb.ErrorCode, data proto.Message) {
|
||||
if code = this.BattleFinishCheck(session, req); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
return
|
||||
}
|
@ -2,6 +2,7 @@ package rtask
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
@ -18,16 +19,12 @@ func (this *apiComp) GetReward(session comm.IUserSession, req *pb.RtaskGetReward
|
||||
if code = this.GetRewardCheck(session, req); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
// conf := this.moduleRtask.configure.getRtaskById(req.RtaskId)
|
||||
// if conf == nil {
|
||||
// code = pb.ErrorCode_ConfigNoFound
|
||||
// return
|
||||
// }
|
||||
|
||||
// 获取支线任务配置
|
||||
sideConf := this.moduleRtask.configure.getRtaskSidById(req.RtaskSubId)
|
||||
if sideConf == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
log.Errorf("rdtask_side %v no found", req.RtaskSubId)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -124,5 +124,4 @@ func (this *ModelRtaskRecord) lessThanParams(cfg *cfg.GameRdtaskCondiData, vals
|
||||
|
||||
condiId = cfg.Id
|
||||
return
|
||||
return
|
||||
}
|
||||
|
@ -149,16 +149,16 @@ func (this *ModuleRtask) initRtaskVerifyHandle() {
|
||||
case comm.Rtype14:
|
||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
||||
cfg: typeCfg,
|
||||
find: this.modelRtaskRecord.equalParams,
|
||||
find: this.modelRtaskRecord.lessThanParams,
|
||||
verify: this.modelRtaskRecord.verifyFromDb,
|
||||
update: this.modelRtaskRecord.overrideUpdate,
|
||||
update: this.modelRtaskRecord.addUpdate,
|
||||
})
|
||||
case comm.Rtype15:
|
||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
||||
cfg: typeCfg,
|
||||
find: this.modelRtaskRecord.equalParams,
|
||||
find: this.modelRtaskRecord.lessThanParams,
|
||||
verify: this.modelRtaskRecord.verifyFromDb,
|
||||
update: this.modelRtaskRecord.overrideUpdate,
|
||||
update: this.modelRtaskRecord.addUpdate,
|
||||
})
|
||||
case comm.Rtype16:
|
||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
||||
@ -177,7 +177,7 @@ func (this *ModuleRtask) initRtaskVerifyHandle() {
|
||||
case comm.Rtype18:
|
||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
||||
cfg: typeCfg,
|
||||
find: this.modelRtaskRecord.equalParams,
|
||||
find: this.modelRtaskRecord.lessThanParams,
|
||||
verify: this.modelRtaskRecord.verifyFromDb,
|
||||
update: this.modelRtaskRecord.overrideUpdate,
|
||||
})
|
||||
@ -534,7 +534,13 @@ func (this *ModuleRtask) initRtaskVerifyHandle() {
|
||||
verify: this.modelRtaskRecord.verifyFromDb,
|
||||
update: this.modelRtaskRecord.overrideUpdate,
|
||||
})
|
||||
|
||||
case comm.Rtype70:
|
||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
||||
cfg: typeCfg,
|
||||
find: this.modelRtaskRecord.equalParams,
|
||||
verify: this.modelRtaskRecord.verifyFromDb,
|
||||
update: this.modelRtaskRecord.overrideUpdate,
|
||||
})
|
||||
default:
|
||||
log.Warnf("rtaskType[%v] not register", typeCfg.Type)
|
||||
}
|
||||
|
@ -85,6 +85,8 @@ func (this *ModelRtaskRecord) addUpdate(uid string, cfg *cfg.GameRdtaskCondiData
|
||||
if record.Vals == nil {
|
||||
data := &pb.RtaskData{
|
||||
Data: toMap(vals...),
|
||||
Rtype: cfg.Type,
|
||||
Timestamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
record.Vals = map[int32]*pb.RtaskData{
|
||||
@ -94,30 +96,34 @@ func (this *ModelRtaskRecord) addUpdate(uid string, cfg *cfg.GameRdtaskCondiData
|
||||
return errors.Wrapf(err, "添加玩家任务记录 err: %v rtype[%v]", uid, cfg.Id)
|
||||
}
|
||||
} else {
|
||||
data := make(map[int32]int32)
|
||||
|
||||
//查找任务数据
|
||||
if v, ok := record.Vals[cfg.Id]; ok {
|
||||
// 只有第一个参数为累加数值
|
||||
if paramLen == 1 {
|
||||
data[0] += v.Data[0]
|
||||
} else if paramLen == 2 {
|
||||
//第一个参数为累加,后续参数为判断条件
|
||||
if data[1] == cfg.Data2 {
|
||||
data[1] += v.Data[1]
|
||||
v.Data[0] += vals[0]
|
||||
v.Timestamp = time.Now().Unix()
|
||||
}
|
||||
} else if paramLen == 3 {
|
||||
if data[1] == cfg.Data2 && data[2] == cfg.Data3 {
|
||||
data[2] += v.Data[2]
|
||||
}
|
||||
}
|
||||
if len(data) > 0 {
|
||||
|
||||
update := map[string]interface{}{
|
||||
"vals": data,
|
||||
"vals": record.Vals,
|
||||
}
|
||||
err = this.Change(uid, update)
|
||||
|
||||
} else {
|
||||
data := map[int32]int32{
|
||||
0: vals[0],
|
||||
}
|
||||
record.Vals[cfg.Id] = &pb.RtaskData{
|
||||
Data: data,
|
||||
Rtype: cfg.Type,
|
||||
Timestamp: time.Now().Unix(),
|
||||
}
|
||||
update := map[string]interface{}{
|
||||
"vals": record.Vals,
|
||||
}
|
||||
err = this.Change(uid, update)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package user
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
@ -17,6 +18,7 @@ func (this *ModelSession) Init(service core.IService, module core.IModule, comp
|
||||
this.module = module.(*User)
|
||||
this.TableName = comm.TableSession
|
||||
this.Expired = 0 //不自动过期
|
||||
this.clean()
|
||||
return
|
||||
}
|
||||
|
||||
@ -29,3 +31,18 @@ func (this *ModelSession) getUserSession(uid string) (user *pb.CacheUser) {
|
||||
}
|
||||
return user
|
||||
}
|
||||
|
||||
// 启动时清理session
|
||||
func (this *ModelSession) clean() {
|
||||
keys, err := this.Redis.Keys("session:*")
|
||||
if err != nil {
|
||||
log.Errorf("redis keys err:%v", err)
|
||||
return
|
||||
}
|
||||
|
||||
for _, k := range keys {
|
||||
if err := this.Redis.Delete(k); err != nil {
|
||||
log.Errorf("redis delete key err:%v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,8 +33,11 @@ func OnInit(config map[string]interface{}, option ...Option) (err error) {
|
||||
return
|
||||
}
|
||||
defsys, err = newSys(options)
|
||||
<<<<<<< HEAD
|
||||
|
||||
// defsys.Local().Redis.GetClient().FlushAll(context.TODO())
|
||||
=======
|
||||
>>>>>>> 5774dd3b (更新随机任务战斗任务)
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user