修改日常任务配置逻辑
This commit is contained in:
parent
50ceaa59ec
commit
babd410071
@ -98,6 +98,7 @@ func (ui *MainWindowImpl) createWindowContainer() {
|
|||||||
ui.at = newAppContainer(appRegister, ui.obs)
|
ui.at = newAppContainer(appRegister, ui.obs)
|
||||||
content := container.NewBorder(ui.tb.toolbar, ui.sb.widget, nil, ui.toys.widget, ui.at)
|
content := container.NewBorder(ui.tb.toolbar, ui.sb.widget, nil, ui.toys.widget, ui.at)
|
||||||
ui.w.SetContent(content)
|
ui.w.SetContent(content)
|
||||||
|
ui.w.SetFullScreen(true)
|
||||||
ui.w.SetCloseIntercept(ui.quiteHandle)
|
ui.w.SetCloseIntercept(ui.quiteHandle)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +107,13 @@ func (ui *MainWindowImpl) SetStatusMsg(msg string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ui *MainWindowImpl) quiteHandle() {
|
func (ui *MainWindowImpl) quiteHandle() {
|
||||||
ui.app.Quit()
|
dialog.ShowConfirm("推出系统", "确定退出吗", func(b bool) {
|
||||||
|
if !b {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ui.app.Quit()
|
||||||
|
}, ui.w)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateWindow ....
|
// CreateWindow ....
|
||||||
|
@ -363,7 +363,7 @@ func (this *appGen) LazyInit(obs observer.Observer) error {
|
|||||||
quesWin := fyne.CurrentApp().NewWindow("使用说明")
|
quesWin := fyne.CurrentApp().NewWindow("使用说明")
|
||||||
quesWin.SetContent(widget.NewRichTextFromMarkdown(
|
quesWin.SetContent(widget.NewRichTextFromMarkdown(
|
||||||
`
|
`
|
||||||
1. 先更新excel文件
|
1. SVN更新excel文件
|
||||||
2. 配置Luban(已做可忽略)
|
2. 配置Luban(已做可忽略)
|
||||||
3. 选择**生成类型**,单击生成
|
3. 选择**生成类型**,单击生成
|
||||||
4. 选择要覆盖的文件
|
4. 选择要覆盖的文件
|
||||||
@ -475,6 +475,12 @@ func (f *fileList) changeItem(tmpDir, projectDir string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if len(tmpFiles) == 0 || len(f.cachedList.Items) == 0 {
|
||||||
|
showTip("没有任何变更的文件,请确定SVN拉取最新文件")
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
projectFiles, err := ioutil.ReadDir(projectDir)
|
projectFiles, err := ioutil.ReadDir(projectDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error(err)
|
logrus.Error(err)
|
||||||
|
@ -192,7 +192,7 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren
|
|||||||
this.module.ModuleTask.SendToTask(session, comm.TaskTypeUpHeroLevel, &pb.TaskParam{Second: iLvUp})
|
this.module.ModuleTask.SendToTask(session, comm.TaskTypeUpHeroLevel, &pb.TaskParam{Second: iLvUp})
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype4, utils.ToInt32(_hero.HeroID), _hero.Lv)
|
this.module.ModuleRtask.SendToRtask(session, comm.Rtype4, utils.ToInt32(_hero.HeroID), _hero.Lv)
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype23, 1, _hero.Star, _hero.Lv)
|
this.module.ModuleRtask.SendToRtask(session, comm.Rtype23, 1, _hero.Star, _hero.Lv)
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype24, iLvUp)
|
this.module.ModuleRtask.SendToRtask(session, comm.Rtype24, 1)
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype29, 1, _hero.Lv, utils.ToInt32(_hero.HeroID))
|
this.module.ModuleRtask.SendToRtask(session, comm.Rtype29, 1, _hero.Lv, utils.ToInt32(_hero.HeroID))
|
||||||
cfg := this.module.configure.GetHero(_hero.HeroID)
|
cfg := this.module.configure.GetHero(_hero.HeroID)
|
||||||
if cfg != nil {
|
if cfg != nil {
|
||||||
|
@ -1,27 +1,34 @@
|
|||||||
// 匹配类型和参数,返回任务条件ID
|
// 匹配类型和参数,返回任务条件ID
|
||||||
package rtask
|
package rtask
|
||||||
|
|
||||||
import cfg "go_dreamfactory/sys/configure/structs"
|
import (
|
||||||
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
|
||||||
func (this *ModelRtaskRecord) equalFirstParam(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32) {
|
"github.com/pkg/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (this *ModelRtaskRecord) equalFirstParam(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32, err error) {
|
||||||
//只查询参数于配置相等的情况下设置condiId,否则返回0
|
//只查询参数于配置相等的情况下设置condiId,否则返回0
|
||||||
if !soEqual(vals[0], cfg.Data1) {
|
if ok, err1 := soEqual(vals[0], cfg.Data1); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
condiId = cfg.Id
|
condiId = cfg.Id
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ModelRtaskRecord) greatEqualFirstParam(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32) {
|
func (this *ModelRtaskRecord) greatEqualFirstParam(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32, err error) {
|
||||||
if !soGreatEqual(vals[0], cfg.Data1) {
|
if ok, err1 := soGreatEqual(vals[0], cfg.Data1); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
condiId = cfg.Id
|
condiId = cfg.Id
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ModelRtaskRecord) lessEqualFirstParam(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32) {
|
func (this *ModelRtaskRecord) lessEqualFirstParam(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32, err error) {
|
||||||
if !soLessEqual(vals[0], cfg.Data1) {
|
if ok, err1 := soLessEqual(vals[0], cfg.Data1); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
condiId = cfg.Id
|
condiId = cfg.Id
|
||||||
@ -29,10 +36,8 @@ func (this *ModelRtaskRecord) lessEqualFirstParam(cfg *cfg.GameRdtaskCondiData,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 与每个参数比较
|
// 与每个参数比较
|
||||||
// Deprecated
|
func (this *ModelRtaskRecord) equalParams(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32, err error) {
|
||||||
func (this *ModelRtaskRecord) equalParams(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32) {
|
|
||||||
var (
|
var (
|
||||||
err error
|
|
||||||
paramLen int
|
paramLen int
|
||||||
)
|
)
|
||||||
if paramLen, err = lenParam(cfg, vals...); err != nil {
|
if paramLen, err = lenParam(cfg, vals...); err != nil {
|
||||||
@ -41,25 +46,68 @@ func (this *ModelRtaskRecord) equalParams(cfg *cfg.GameRdtaskCondiData, vals ...
|
|||||||
|
|
||||||
switch paramLen {
|
switch paramLen {
|
||||||
case 1:
|
case 1:
|
||||||
if !soEqual(vals[0], cfg.Data1) {
|
if ok, err1 := soEqual(vals[0], cfg.Data1); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
if !(soEqual(vals[0], cfg.Data1) && soGreatEqual(vals[1], cfg.Data2)) {
|
if ok, err1 := soEqual(vals[0], cfg.Data1); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[1], cfg.Data2); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
if !(soEqual(vals[0], cfg.Data1) && soGreatEqual(vals[1], cfg.Data2) && soGreatEqual(vals[2], cfg.Data3)) {
|
if ok, err1 := soEqual(vals[0], cfg.Data1); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[1], cfg.Data2); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[2], cfg.Data3); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 4:
|
case 4:
|
||||||
if !(soEqual(vals[0], cfg.Data1) && soGreatEqual(vals[1], cfg.Data2) &&
|
if ok, err1 := soEqual(vals[0], cfg.Data1); !ok {
|
||||||
soGreatEqual(vals[2], cfg.Data3) && soGreatEqual(vals[3], cfg.Data4)) {
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[1], cfg.Data2); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[2], cfg.Data3); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[3], cfg.Data4); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 5:
|
case 5:
|
||||||
if !(soEqual(vals[0], cfg.Data1) && soGreatEqual(vals[1], cfg.Data2) &&
|
if ok, err1 := soEqual(vals[0], cfg.Data1); !ok {
|
||||||
soGreatEqual(vals[2], cfg.Data3) && soGreatEqual(vals[3], cfg.Data4) && soGreatEqual(vals[4], cfg.Data5)) {
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[1], cfg.Data2); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[2], cfg.Data3); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[3], cfg.Data4); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[4], cfg.Data5); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -71,9 +119,8 @@ func (this *ModelRtaskRecord) equalParams(cfg *cfg.GameRdtaskCondiData, vals ...
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ModelRtaskRecord) greatThanParams(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32) {
|
func (this *ModelRtaskRecord) greatThanParams(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32, err error) {
|
||||||
var (
|
var (
|
||||||
err error
|
|
||||||
paramLen int
|
paramLen int
|
||||||
)
|
)
|
||||||
if paramLen, err = lenParam(cfg, vals...); err != nil {
|
if paramLen, err = lenParam(cfg, vals...); err != nil {
|
||||||
@ -82,25 +129,68 @@ func (this *ModelRtaskRecord) greatThanParams(cfg *cfg.GameRdtaskCondiData, vals
|
|||||||
|
|
||||||
switch paramLen {
|
switch paramLen {
|
||||||
case 1:
|
case 1:
|
||||||
if !soGreatEqual(vals[0], cfg.Data1) {
|
if ok, err1 := soGreatEqual(vals[0], cfg.Data1); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
if !(soGreatEqual(vals[0], cfg.Data1) && soEqual(vals[1], cfg.Data2)) {
|
if ok, err1 := soGreatEqual(vals[0], cfg.Data1); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[1], cfg.Data2); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
if !(soGreatEqual(vals[0], cfg.Data1) && soEqual(vals[1], cfg.Data2) && soEqual(vals[2], cfg.Data3)) {
|
if ok, err1 := soGreatEqual(vals[0], cfg.Data1); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[1], cfg.Data2); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[2], cfg.Data3); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 4:
|
case 4:
|
||||||
if !(soGreatEqual(vals[0], cfg.Data1) && soEqual(vals[1], cfg.Data2) &&
|
if ok, err1 := soGreatEqual(vals[0], cfg.Data1); !ok {
|
||||||
soEqual(vals[2], cfg.Data3) && soEqual(vals[3], cfg.Data4)) {
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[1], cfg.Data2); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[2], cfg.Data3); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[3], cfg.Data4); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 5:
|
case 5:
|
||||||
if !(soGreatEqual(vals[0], cfg.Data1) && soEqual(vals[1], cfg.Data2) &&
|
if ok, err1 := soGreatEqual(vals[0], cfg.Data1); !ok {
|
||||||
soEqual(vals[2], cfg.Data3) && soEqual(vals[3], cfg.Data4) && soEqual(vals[4], cfg.Data5)) {
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[1], cfg.Data2); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[2], cfg.Data3); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[3], cfg.Data4); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[4], cfg.Data5); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -112,9 +202,8 @@ func (this *ModelRtaskRecord) greatThanParams(cfg *cfg.GameRdtaskCondiData, vals
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 需要累加更新的查询
|
// 需要累加更新的查询
|
||||||
func (this *ModelRtaskRecord) lessThanParams(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32) {
|
func (this *ModelRtaskRecord) lessThanParams(cfg *cfg.GameRdtaskCondiData, vals ...int32) (condiId int32, err error) {
|
||||||
var (
|
var (
|
||||||
err error
|
|
||||||
paramLen int
|
paramLen int
|
||||||
)
|
)
|
||||||
if paramLen, err = lenParam(cfg, vals...); err != nil {
|
if paramLen, err = lenParam(cfg, vals...); err != nil {
|
||||||
@ -123,25 +212,68 @@ func (this *ModelRtaskRecord) lessThanParams(cfg *cfg.GameRdtaskCondiData, vals
|
|||||||
|
|
||||||
switch paramLen {
|
switch paramLen {
|
||||||
case 1:
|
case 1:
|
||||||
if !soLessEqual(vals[0], cfg.Data1) {
|
if ok, err1 := soLessEqual(vals[0], cfg.Data1); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
if !(soLessEqual(vals[0], cfg.Data1) && soGreatEqual(vals[1], cfg.Data2)) {
|
if ok, err1 := soLessEqual(vals[0], cfg.Data1); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[1], cfg.Data2); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
if !(soLessEqual(vals[0], cfg.Data1) && soGreatEqual(vals[1], cfg.Data2) && soGreatEqual(vals[2], cfg.Data3)) {
|
if ok, err1 := soLessEqual(vals[0], cfg.Data1); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[1], cfg.Data2); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[2], cfg.Data3); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 4:
|
case 4:
|
||||||
if !(soLessEqual(vals[0], cfg.Data1) && soGreatEqual(vals[1], cfg.Data2) &&
|
if ok, err1 := soLessEqual(vals[0], cfg.Data1); !ok {
|
||||||
soGreatEqual(vals[2], cfg.Data3) && soGreatEqual(vals[3], cfg.Data4)) {
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[1], cfg.Data2); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[2], cfg.Data3); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[3], cfg.Data4); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 5:
|
case 5:
|
||||||
if !(soLessEqual(vals[0], cfg.Data1) && soGreatEqual(vals[1], cfg.Data2) &&
|
if ok, err1 := soLessEqual(vals[0], cfg.Data1); !ok {
|
||||||
soGreatEqual(vals[2], cfg.Data3) && soGreatEqual(vals[3], cfg.Data4) && soGreatEqual(vals[4], cfg.Data5)) {
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[1], cfg.Data2); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[2], cfg.Data3); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[3], cfg.Data4); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err1 := soGreatEqual(vals[4], cfg.Data5); !ok {
|
||||||
|
err = errors.WithMessagef(err1, "id: %v type:%v", cfg.Id, cfg.Type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -154,27 +154,27 @@ func lessEqual(actual, expected int32) bool {
|
|||||||
return actual <= expected
|
return actual <= expected
|
||||||
}
|
}
|
||||||
|
|
||||||
func soEqual[T Num](actual T, expected T) (ok bool) {
|
func soEqual[T Num](actual T, expected T) (ok bool, err error) {
|
||||||
if !equal(actual, expected) {
|
if !equal(actual, expected) {
|
||||||
log.Debugf("实际:%v 期望:%v", actual, expected)
|
err = errors.New(fmt.Sprintf("soEqual actual:%v expect:%v", actual, expected))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ok = true
|
ok = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func soGreatEqual(actual, expected int32) (ok bool) {
|
func soGreatEqual(actual, expected int32) (ok bool, err error) {
|
||||||
if !greatEual(actual, expected) {
|
if !greatEual(actual, expected) {
|
||||||
log.Debugf("实际:%v 期望:%v", actual, expected)
|
err = errors.New(fmt.Sprintf("soGreatEqual actual:%v expect:%v", actual, expected))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ok = true
|
ok = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func soLessEqual(actual, expected int32) (ok bool) {
|
func soLessEqual(actual, expected int32) (ok bool, err error) {
|
||||||
if !lessEqual(actual, expected) {
|
if !lessEqual(actual, expected) {
|
||||||
log.Debugf("实际:%v 期望:%v", actual, expected)
|
err = errors.New(fmt.Sprintf("soLessEqual actual:%v expect:%v", actual, expected))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ok = true
|
ok = true
|
||||||
|
@ -73,7 +73,7 @@ func (this *ModelRtask) checkCondi(uid string, condiId int32) (err error, ok boo
|
|||||||
var condi *rtaskCondi
|
var condi *rtaskCondi
|
||||||
if condi, ok = this.moduleRtask.handleMap[condiId]; ok {
|
if condi, ok = this.moduleRtask.handleMap[condiId]; ok {
|
||||||
if condi.verify != nil {
|
if condi.verify != nil {
|
||||||
if err, ok = condi.verify(uid, condi.cfg); !ok {
|
if ok, err = condi.verify(uid, condi.cfg); !ok {
|
||||||
err = errors.WithMessagef(err, "uid: %v do rtask %v condition not reach", uid, condiId)
|
err = errors.WithMessagef(err, "uid: %v do rtask %v condition not reach", uid, condiId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@ type rtaskCondi struct {
|
|||||||
update updateDataHandle //更新任务数据
|
update updateDataHandle //更新任务数据
|
||||||
}
|
}
|
||||||
|
|
||||||
type verifyHandle func(uid string, cfg *cfg.GameRdtaskCondiData) (error, bool)
|
type verifyHandle func(uid string, cfg *cfg.GameRdtaskCondiData) (bool, error)
|
||||||
type condiFindHandle func(cfg *cfg.GameRdtaskCondiData, vals ...int32) int32
|
type condiFindHandle func(cfg *cfg.GameRdtaskCondiData, vals ...int32) (int32, error)
|
||||||
type updateDataHandle func(uid string, cfg *cfg.GameRdtaskCondiData, vals ...int32) error
|
type updateDataHandle func(uid string, cfg *cfg.GameRdtaskCondiData, vals ...int32) error
|
||||||
|
|
||||||
type ModuleRtask struct {
|
type ModuleRtask struct {
|
||||||
@ -193,10 +193,12 @@ func (this *ModuleRtask) initRtaskVerifyHandle() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.TaskType, params ...int32) (code pb.ErrorCode) {
|
func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.TaskType, params ...int32) (code pb.ErrorCode) {
|
||||||
log.Debugf("Rtask params: %v", params)
|
this.Debugf("receive Rtask %v params: %v", rtaskType, params)
|
||||||
var (
|
var (
|
||||||
|
err error
|
||||||
condiId int32
|
condiId int32
|
||||||
condi *rtaskCondi
|
// condi *rtaskCondi
|
||||||
|
condis []*rtaskCondi
|
||||||
)
|
)
|
||||||
|
|
||||||
user := this.ModuleUser.GetUser(session.GetUserId())
|
user := this.ModuleUser.GetUser(session.GetUserId())
|
||||||
@ -211,29 +213,34 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T
|
|||||||
if v.find == nil {
|
if v.find == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if condiId = v.find(v.cfg, params...); condiId == 0 {
|
if condiId, err = v.find(v.cfg, params...); condiId == 0 {
|
||||||
|
if err != nil {
|
||||||
|
this.Error(err.Error())
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
//数据记录方式是1
|
//数据记录方式是1
|
||||||
// if v.cfg.Datatype == 1 ||
|
// if v.cfg.Datatype == 1 ||
|
||||||
// v.cfg.Datatype == 2 && this.ModuleSys.IsAccess("task", user.Lv) {
|
// v.cfg.Datatype == 2 && this.ModuleSys.IsAccess("task", user.Lv) {
|
||||||
condi = v
|
condis = append(condis, v)
|
||||||
// }
|
// }
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if condiId == 0 {
|
if len(condis) == 0 {
|
||||||
log.Debugf("condi not found, typeId: %v params: %v", rtaskType, params)
|
this.Warnf("没有找到符合的条件任务, typeId: %v params: %v", rtaskType, params)
|
||||||
code = pb.ErrorCode_RtaskCondiNoFound
|
code = pb.ErrorCode_RtaskCondiNoFound
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
if condi.update != nil {
|
for _, v := range condis {
|
||||||
if err := condi.update(session.GetUserId(), condi.cfg, params...); err != nil {
|
if v.update != nil {
|
||||||
code = pb.ErrorCode_DBError
|
if err := v.update(session.GetUserId(), v.cfg, params...); err != nil {
|
||||||
|
code = pb.ErrorCode_DBError
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/spf13/cast"
|
"github.com/spf13/cast"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (this *ModelRtaskRecord) verifyFromDb(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
|
func (this *ModelRtaskRecord) verifyFromDb(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
|
||||||
var rd *pb.RtaskData
|
var rd *pb.RtaskData
|
||||||
if rd, err = this.GetVerifyData(uid, cfg.Id); rd != nil {
|
if rd, err = this.GetVerifyData(uid, cfg.Id); rd != nil {
|
||||||
if len(rd.Data) == 0 {
|
if len(rd.Data) == 0 {
|
||||||
@ -23,23 +23,60 @@ func (this *ModelRtaskRecord) verifyFromDb(uid string, cfg *cfg.GameRdtaskCondiD
|
|||||||
//参数比较,默认第一个参数soGreateEqual,其它soEqual
|
//参数比较,默认第一个参数soGreateEqual,其它soEqual
|
||||||
switch paramLen {
|
switch paramLen {
|
||||||
case 1:
|
case 1:
|
||||||
return nil, soGreatEqual(rd.Data[0], cfg.Data1)
|
return soGreatEqual(rd.Data[0], cfg.Data1)
|
||||||
case 2:
|
case 2:
|
||||||
return nil, soGreatEqual(rd.Data[0], cfg.Data1) && soEqual(rd.Data[1], cfg.Data2)
|
if ok, err = soGreatEqual(rd.Data[0], cfg.Data1); !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err = soEqual(rd.Data[1], cfg.Data2); !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
case 3:
|
case 3:
|
||||||
return nil, soGreatEqual(rd.Data[0], cfg.Data1) && soEqual(rd.Data[1], cfg.Data2) && soEqual(rd.Data[2], cfg.Data3)
|
if ok, err = soGreatEqual(rd.Data[0], cfg.Data1); !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err = soEqual(rd.Data[1], cfg.Data2); !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err = soEqual(rd.Data[2], cfg.Data3); !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
case 4:
|
case 4:
|
||||||
return nil, soGreatEqual(rd.Data[0], cfg.Data1) && soEqual(rd.Data[1], cfg.Data2) && soEqual(rd.Data[2], cfg.Data3) && soEqual(rd.Data[3], cfg.Data4)
|
if ok, err = soGreatEqual(rd.Data[0], cfg.Data1); !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err = soEqual(rd.Data[1], cfg.Data2); !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err = soEqual(rd.Data[2], cfg.Data3); !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err = soEqual(rd.Data[3], cfg.Data4); !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
case 5:
|
case 5:
|
||||||
return nil, soGreatEqual(rd.Data[0], cfg.Data1) && soEqual(rd.Data[1], cfg.Data2) && soEqual(rd.Data[2], cfg.Data3) &&
|
if ok, err = soGreatEqual(rd.Data[0], cfg.Data1); !ok {
|
||||||
soEqual(rd.Data[3], cfg.Data4) && soEqual(rd.Data[4], cfg.Data5)
|
return
|
||||||
|
}
|
||||||
|
if ok, err = soEqual(rd.Data[1], cfg.Data2); !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err = soEqual(rd.Data[2], cfg.Data3); !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err = soEqual(rd.Data[3], cfg.Data4); !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok, err = soEqual(rd.Data[4], cfg.Data5); !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ModelRtaskRecord) verifyFirstEqualParam(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
|
func (this *ModelRtaskRecord) verifyFirstEqualParam(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
|
||||||
var rd *pb.RtaskData
|
var rd *pb.RtaskData
|
||||||
if rd, err = this.GetVerifyData(uid, cfg.Id); rd != nil {
|
if rd, err = this.GetVerifyData(uid, cfg.Id); rd != nil {
|
||||||
if len(rd.Data) == 0 {
|
if len(rd.Data) == 0 {
|
||||||
@ -47,12 +84,12 @@ func (this *ModelRtaskRecord) verifyFirstEqualParam(uid string, cfg *cfg.GameRdt
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, soEqual(rd.Data[0], cfg.Data1)
|
return soEqual(rd.Data[0], cfg.Data1)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ModelRtaskRecord) verifyFirstGreatEqualParam(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
|
func (this *ModelRtaskRecord) verifyFirstGreatEqualParam(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
|
||||||
var rd *pb.RtaskData
|
var rd *pb.RtaskData
|
||||||
if rd, err = this.GetVerifyData(uid, cfg.Id); rd != nil {
|
if rd, err = this.GetVerifyData(uid, cfg.Id); rd != nil {
|
||||||
if len(rd.Data) == 0 {
|
if len(rd.Data) == 0 {
|
||||||
@ -60,22 +97,22 @@ func (this *ModelRtaskRecord) verifyFirstGreatEqualParam(uid string, cfg *cfg.Ga
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, soGreatEqual(rd.Data[0], cfg.Data1)
|
return soGreatEqual(rd.Data[0], cfg.Data1)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 英雄指定
|
// 英雄指定
|
||||||
func (this *ModelRtask) verfiyRtype1(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
|
func (this *ModelRtask) verfiyRtype1(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
|
||||||
heroModule, err := this.service.GetModule(comm.ModuleHero)
|
heroModule, err := this.service.GetModule(comm.ModuleHero)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err, false
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if h, y := heroModule.(comm.IHero); y {
|
if h, y := heroModule.(comm.IHero); y {
|
||||||
for _, v := range h.GetHeroList(uid) {
|
for _, v := range h.GetHeroList(uid) {
|
||||||
if soEqual(cast.ToString(cfg.Data1), v.HeroID) {
|
ok, err = soEqual(cast.ToString(cfg.Data1), v.HeroID)
|
||||||
ok = true
|
if ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,7 +121,7 @@ func (this *ModelRtask) verfiyRtype1(uid string, cfg *cfg.GameRdtaskCondiData) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 剧情
|
// 剧情
|
||||||
func (this *ModelRtask) verifyRtype2(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
|
func (this *ModelRtask) verifyRtype2(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
|
||||||
m, err := this.service.GetModule(comm.ModuleMainline)
|
m, err := this.service.GetModule(comm.ModuleMainline)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -92,13 +129,13 @@ func (this *ModelRtask) verifyRtype2(uid string, cfg *cfg.GameRdtaskCondiData) (
|
|||||||
|
|
||||||
if ml, y := m.(comm.IMainline); y {
|
if ml, y := m.(comm.IMainline); y {
|
||||||
qjId := ml.GetUsermainLineData(uid)
|
qjId := ml.GetUsermainLineData(uid)
|
||||||
return nil, soEqual(qjId, cfg.Data1)
|
return soEqual(qjId, cfg.Data1)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 每日任务
|
// 每日任务
|
||||||
func (this *ModelRtask) verifyRtype3(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
|
func (this *ModelRtask) verifyRtype3(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
|
||||||
m, err := this.service.GetModule(comm.ModuleTask)
|
m, err := this.service.GetModule(comm.ModuleTask)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -116,7 +153,7 @@ func (this *ModelRtask) verifyRtype3(uid string, cfg *cfg.GameRdtaskCondiData) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 指定英雄等级
|
// 指定英雄等级
|
||||||
func (this *ModelRtask) verifyRtype4(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
|
func (this *ModelRtask) verifyRtype4(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
|
||||||
defer printCondiLog(uid, cfg)
|
defer printCondiLog(uid, cfg)
|
||||||
m, err := this.service.GetModule(comm.ModuleHero)
|
m, err := this.service.GetModule(comm.ModuleHero)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -132,15 +169,19 @@ func (this *ModelRtask) verifyRtype4(uid string, cfg *cfg.GameRdtaskCondiData) (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if hero != nil {
|
if hero != nil {
|
||||||
return nil, soEqual(hero.HeroID, cast.ToString(cfg.Data1)) &&
|
if ok, err = soEqual(hero.HeroID, cast.ToString(cfg.Data1)); !ok {
|
||||||
soGreatEqual(hero.Lv, cfg.Data2)
|
return
|
||||||
|
}
|
||||||
|
if ok, err = soGreatEqual(hero.Lv, cfg.Data2); !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 指定英雄的指定装备数量
|
// 指定英雄的指定装备数量
|
||||||
func (this *ModelRtask) verifyRtype5(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
|
func (this *ModelRtask) verifyRtype5(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
|
||||||
defer printCondiLog(uid, cfg)
|
defer printCondiLog(uid, cfg)
|
||||||
m, err := this.service.GetModule(comm.ModuleHero)
|
m, err := this.service.GetModule(comm.ModuleHero)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -164,14 +205,16 @@ func (this *ModelRtask) verifyRtype5(uid string, cfg *cfg.GameRdtaskCondiData) (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, soEqual(hero.HeroID, cast.ToString(cfg.Data1)) &&
|
if ok, err = soEqual(hero.HeroID, cast.ToString(cfg.Data1)); !ok {
|
||||||
soGreatEqual(count, cfg.Data2)
|
return
|
||||||
|
}
|
||||||
|
return soGreatEqual(count, cfg.Data2)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 指定英雄星级
|
// 指定英雄星级
|
||||||
func (this *ModelRtask) verifyRtype6(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
|
func (this *ModelRtask) verifyRtype6(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
|
||||||
defer printCondiLog(uid, cfg)
|
defer printCondiLog(uid, cfg)
|
||||||
m, err := this.service.GetModule(comm.ModuleHero)
|
m, err := this.service.GetModule(comm.ModuleHero)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -188,15 +231,17 @@ func (this *ModelRtask) verifyRtype6(uid string, cfg *cfg.GameRdtaskCondiData) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if hero != nil {
|
if hero != nil {
|
||||||
return nil, soEqual(hero.HeroID, cast.ToString(cfg.Data1)) &&
|
if ok, err = soEqual(hero.HeroID, cast.ToString(cfg.Data1)); !ok {
|
||||||
soGreatEqual(hero.Star, cfg.Data2)
|
return
|
||||||
|
}
|
||||||
|
return soGreatEqual(hero.Star, cfg.Data2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 日常登录一次
|
// 日常登录一次
|
||||||
func (this *ModelRtask) verfiyRtype7(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
|
func (this *ModelRtask) verfiyRtype7(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
|
||||||
defer printCondiLog(uid, cfg)
|
defer printCondiLog(uid, cfg)
|
||||||
userModule, err := this.service.GetModule(comm.ModuleUser)
|
userModule, err := this.service.GetModule(comm.ModuleUser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -205,14 +250,14 @@ func (this *ModelRtask) verfiyRtype7(uid string, cfg *cfg.GameRdtaskCondiData) (
|
|||||||
|
|
||||||
if um, y := userModule.(comm.IUser); y {
|
if um, y := userModule.(comm.IUser); y {
|
||||||
if user := um.GetUser(uid); user != nil {
|
if user := um.GetUser(uid); user != nil {
|
||||||
return nil, soEqual(utils.IsToday(user.Logintime), true)
|
return soEqual(utils.IsToday(user.Logintime), true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 累计登陆xx天
|
// 累计登陆xx天
|
||||||
func (this *ModelRtask) verfiyRtype8(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
|
func (this *ModelRtask) verfiyRtype8(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
|
||||||
defer printCondiLog(uid, cfg)
|
defer printCondiLog(uid, cfg)
|
||||||
userModule, err := this.service.GetModule(comm.ModuleUser)
|
userModule, err := this.service.GetModule(comm.ModuleUser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -222,15 +267,15 @@ func (this *ModelRtask) verfiyRtype8(uid string, cfg *cfg.GameRdtaskCondiData) (
|
|||||||
if um, y := userModule.(comm.IUser); y {
|
if um, y := userModule.(comm.IUser); y {
|
||||||
ud, err := um.GetUserExpand(uid)
|
ud, err := um.GetUserExpand(uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err, false
|
return false, err
|
||||||
}
|
}
|
||||||
return nil, soGreatEqual(ud.LoginAddCount, cfg.Data1)
|
return soGreatEqual(ud.LoginAddCount, cfg.Data1)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 连续登陆xx天
|
// 连续登陆xx天
|
||||||
func (this *ModelRtask) verfiyRtype9(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
|
func (this *ModelRtask) verfiyRtype9(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
|
||||||
defer printCondiLog(uid, cfg)
|
defer printCondiLog(uid, cfg)
|
||||||
userModule, err := this.service.GetModule(comm.ModuleUser)
|
userModule, err := this.service.GetModule(comm.ModuleUser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -240,15 +285,15 @@ func (this *ModelRtask) verfiyRtype9(uid string, cfg *cfg.GameRdtaskCondiData) (
|
|||||||
if um, y := userModule.(comm.IUser); y {
|
if um, y := userModule.(comm.IUser); y {
|
||||||
ud, err := um.GetUserExpand(uid)
|
ud, err := um.GetUserExpand(uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err, false
|
return false, err
|
||||||
}
|
}
|
||||||
return nil, soGreatEqual(ud.LoginContinueCount, cfg.Data1)
|
return soGreatEqual(ud.LoginContinueCount, cfg.Data1)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拥有xx个好友
|
// 拥有xx个好友
|
||||||
func (this *ModelRtask) verfiyRtype10(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
|
func (this *ModelRtask) verfiyRtype10(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
|
||||||
defer printCondiLog(uid, cfg)
|
defer printCondiLog(uid, cfg)
|
||||||
m, err := this.service.GetModule(comm.ModuleFriend)
|
m, err := this.service.GetModule(comm.ModuleFriend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -257,13 +302,13 @@ func (this *ModelRtask) verfiyRtype10(uid string, cfg *cfg.GameRdtaskCondiData)
|
|||||||
|
|
||||||
if mi, y := m.(comm.IFriend); y {
|
if mi, y := m.(comm.IFriend); y {
|
||||||
count := mi.GetFriendCount(uid)
|
count := mi.GetFriendCount(uid)
|
||||||
return nil, soGreatEqual(count, cfg.Data1)
|
return soGreatEqual(count, cfg.Data1)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用户等级达到xx级
|
// 用户等级达到xx级
|
||||||
func (this *ModelRtask) verifyRtype20(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
|
func (this *ModelRtask) verifyRtype20(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
|
||||||
defer printCondiLog(uid, cfg)
|
defer printCondiLog(uid, cfg)
|
||||||
userModule, err := this.service.GetModule(comm.ModuleUser)
|
userModule, err := this.service.GetModule(comm.ModuleUser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -272,14 +317,14 @@ func (this *ModelRtask) verifyRtype20(uid string, cfg *cfg.GameRdtaskCondiData)
|
|||||||
|
|
||||||
if um, y := userModule.(comm.IUser); y {
|
if um, y := userModule.(comm.IUser); y {
|
||||||
if user := um.GetUser(uid); user != nil {
|
if user := um.GetUser(uid); user != nil {
|
||||||
return nil, soGreatEqual(user.Lv, cfg.Data1)
|
return soGreatEqual(user.Lv, cfg.Data1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 日常任务活跃度达到xx
|
// 日常任务活跃度达到xx
|
||||||
func (this *ModelRtask) verifyRtype63(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
|
func (this *ModelRtask) verifyRtype63(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) {
|
||||||
userModule, err := this.service.GetModule(comm.ModuleUser)
|
userModule, err := this.service.GetModule(comm.ModuleUser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -288,11 +333,11 @@ func (this *ModelRtask) verifyRtype63(uid string, cfg *cfg.GameRdtaskCondiData)
|
|||||||
if um, y := userModule.(comm.IUser); y {
|
if um, y := userModule.(comm.IUser); y {
|
||||||
de, err := um.GetUserExpand(uid)
|
de, err := um.GetUserExpand(uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err, false
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if de != nil {
|
if de != nil {
|
||||||
ok = soGreatEqual(de.Activeday, cfg.Data1)
|
return soGreatEqual(de.Activeday, cfg.Data1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ func TestVerify2(t *testing.T) {
|
|||||||
patches3 := gomonkey.ApplyGlobalVar(&vals, []int32{25001})
|
patches3 := gomonkey.ApplyGlobalVar(&vals, []int32{25001})
|
||||||
defer patches3.Reset()
|
defer patches3.Reset()
|
||||||
|
|
||||||
condiId := rtask.equalParams(conf, vals...)
|
condiId, _ := rtask.equalParams(conf, vals...)
|
||||||
So(condiId, ShouldEqual, 101)
|
So(condiId, ShouldEqual, 101)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package task
|
package task
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
event_v2 "go_dreamfactory/lego/sys/event/v2"
|
event_v2 "go_dreamfactory/lego/sys/event/v2"
|
||||||
@ -8,6 +9,7 @@ import (
|
|||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -257,18 +259,22 @@ func (this *ModelTask) inStrategy(uid string, heroCfgId int32) (taskIds []int32,
|
|||||||
func (this *ModelTask) doTaskHandle(event interface{}, next func(event interface{})) {
|
func (this *ModelTask) doTaskHandle(event interface{}, next func(event interface{})) {
|
||||||
tl := event.(*TaskListen)
|
tl := event.(*TaskListen)
|
||||||
|
|
||||||
|
// 获取玩家的指定事件列表
|
||||||
data, err := this.moduleTask.configure.getTasks(int32(tl.TaskType))
|
data, err := this.moduleTask.configure.getTasks(int32(tl.TaskType))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.moduleTask.Errorf("taskHandle err %v", err)
|
this.moduleTask.Errorf("taskHandle err %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取玩家的任务条件数据
|
||||||
dr := this.moduleTask.ModuleRtask.GetCondiData(tl.Uid)
|
dr := this.moduleTask.ModuleRtask.GetCondiData(tl.Uid)
|
||||||
if dr == nil {
|
if dr == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 遍历事件列表
|
||||||
for _, conf := range data {
|
for _, conf := range data {
|
||||||
|
// 从任务条件中查找
|
||||||
ret, ok := dr.Vals[conf.TypeId]
|
ret, ok := dr.Vals[conf.TypeId]
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
@ -286,6 +292,7 @@ func (this *ModelTask) doTaskHandle(event interface{}, next func(event interface
|
|||||||
"progress": progress,
|
"progress": progress,
|
||||||
"status": 1,
|
"status": 1,
|
||||||
}
|
}
|
||||||
|
err = this.updateActive(tl.Uid, conf.Key)
|
||||||
} else {
|
} else {
|
||||||
if ret != nil && len(ret.Data) > 0 {
|
if ret != nil && len(ret.Data) > 0 {
|
||||||
progress = ret.Data[0]
|
progress = ret.Data[0]
|
||||||
@ -298,11 +305,38 @@ func (this *ModelTask) doTaskHandle(event interface{}, next func(event interface
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 更新活跃度
|
||||||
|
func (this *ModelTask) updateActive(uid string, cfgId int32) error {
|
||||||
|
// 更新活跃度
|
||||||
|
de, err := this.moduleTask.ModuleUser.GetUserExpand(uid)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
conf := this.moduleTask.configure.getTaskById(cfgId)
|
||||||
|
if conf == nil {
|
||||||
|
return errors.New(fmt.Sprintf("%v config nil", cfgId))
|
||||||
|
}
|
||||||
|
|
||||||
|
switch conf.IdTag {
|
||||||
|
case int32(comm.TASK_DAILY):
|
||||||
|
de.Activeday += conf.Active
|
||||||
|
case int32(comm.TASK_WEEKLY):
|
||||||
|
de.Activeweek += conf.Active
|
||||||
|
}
|
||||||
|
|
||||||
|
update := map[string]interface{}{
|
||||||
|
"activeday": de.Activeday,
|
||||||
|
"activeweek": de.Activeweek,
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.moduleTask.ModuleUser.ChangeUserExpand(uid, update)
|
||||||
|
}
|
||||||
|
|
||||||
type TaskListen struct {
|
type TaskListen struct {
|
||||||
event_v2.Event
|
event_v2.Event
|
||||||
Uid string
|
Uid string
|
||||||
|
Loading…
Reference in New Issue
Block a user