开放任务触发协议

This commit is contained in:
wh_zcy 2023-02-02 10:42:49 +08:00
parent c722de346c
commit cdd3db85b2
10 changed files with 250 additions and 1100 deletions

View File

@ -102,14 +102,9 @@ var (
// pagoda // pagoda
ff(comm.ModulePagoda, "getlist"): &formview.PagodaListView{}, ff(comm.ModulePagoda, "getlist"): &formview.PagodaListView{},
// rtask // rtask
ff(comm.ModuleRtask, rtask.RtaskSubTypeList): &formview.RtaskListView{}, ff(comm.ModuleRtask, rtask.RtaskSubTypeList): &formview.RtaskListView{},
ff(comm.ModuleRtask, rtask.RtaskSubTypeApply): &formview.RtaskDoitView{}, ff(comm.ModuleRtask, "rtest"): &formview.RtaskTestView{},
ff(comm.ModuleRtask, rtask.RtaskSubTypeChoose): &formview.RtaskChooseView{}, ff(comm.ModuleRtask, rtask.RtaskSubTypeGetrecord): &formview.RtaskRecordView{},
ff(comm.ModuleRtask, rtask.RtaskSubTypeReward): &formview.RtaskRewardView{},
ff(comm.ModuleRtask, "rtest"): &formview.RtaskTestView{},
ff(comm.ModuleRtask, rtask.RtaskSubTypeBattleStart): &formview.RtaskBattlestartView{},
ff(comm.ModuleRtask, rtask.RtaskSubTypeBattleFinish): &formview.RtaskBattleFinishView{},
ff(comm.ModuleRtask, rtask.RtaskSubTypeGetrecord): &formview.RtaskRecordView{},
// linestory // linestory
ff(comm.ModuleLinestory, linestory.LinestorySubTypeChapter): &formview.LinestoryMineView{}, ff(comm.ModuleLinestory, linestory.LinestorySubTypeChapter): &formview.LinestoryMineView{},
ff(comm.ModuleLibrary, library.LibraryFetterstoryTaskResp): &formview.FetterstoryView{}, ff(comm.ModuleLibrary, library.LibraryFetterstoryTaskResp): &formview.FetterstoryView{},
@ -227,12 +222,6 @@ var (
}, },
"rtask": { "rtask": {
ff(comm.ModuleRtask, rtask.RtaskSubTypeList), ff(comm.ModuleRtask, rtask.RtaskSubTypeList),
ff(comm.ModuleRtask, rtask.RtaskSubTypeApply),
ff(comm.ModuleRtask, rtask.RtaskSubTypeChoose),
ff(comm.ModuleRtask, rtask.RtaskSubTypeReward),
ff(comm.ModuleRtask, rtask.RtaskSubTypeBattleStart),
ff(comm.ModuleRtask, rtask.RtaskSubTypeBattleFinish),
ff(comm.ModuleRtask, rtask.RtaskSubTypeGetrecord), ff(comm.ModuleRtask, rtask.RtaskSubTypeGetrecord),
ff(comm.ModuleRtask, "rtest"), ff(comm.ModuleRtask, "rtest"),
}, },
@ -770,41 +759,6 @@ var (
return "" return ""
}, },
}, },
ff(comm.ModuleRtask, rtask.RtaskSubTypeApply): {
NavLabel: "做任务",
Desc: "执行随机任务",
MainType: string(comm.ModuleRtask),
SubType: rtask.RtaskSubTypeApply,
Enabled: true,
},
ff(comm.ModuleRtask, rtask.RtaskSubTypeChoose): {
NavLabel: "情景对答",
Desc: "情景对答",
MainType: string(comm.ModuleRtask),
SubType: rtask.RtaskSubTypeChoose,
Enabled: true,
},
ff(comm.ModuleRtask, rtask.RtaskSubTypeReward): {
NavLabel: "领奖",
Desc: "领奖",
MainType: string(comm.ModuleRtask),
SubType: rtask.RtaskSubTypeReward,
Enabled: true,
},
ff(comm.ModuleRtask, rtask.RtaskSubTypeBattleStart): {
NavLabel: "战斗开始",
Desc: "战斗开始",
MainType: string(comm.ModuleRtask),
SubType: rtask.RtaskSubTypeBattleStart,
Enabled: true,
},
ff(comm.ModuleRtask, rtask.RtaskSubTypeBattleFinish): {
NavLabel: "战斗结束",
Desc: "战斗结束",
MainType: string(comm.ModuleRtask),
SubType: rtask.RtaskSubTypeBattleFinish,
Enabled: true,
},
ff(comm.ModuleRtask, rtask.RtaskSubTypeGetrecord): { ff(comm.ModuleRtask, rtask.RtaskSubTypeGetrecord): {
NavLabel: "任务数据", NavLabel: "任务数据",
Desc: "任务数据", Desc: "任务数据",

View File

@ -1,44 +0,0 @@
package formview
import (
"errors"
"go_dreamfactory/cmd/v2/model"
"go_dreamfactory/cmd/v2/service"
"go_dreamfactory/pb"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/widget"
"github.com/sirupsen/logrus"
"github.com/spf13/cast"
)
type RtaskDoitView struct {
BaseformView
}
func (this *RtaskDoitView) CreateView(t *model.TestCase) fyne.CanvasObject {
taskId := widget.NewEntry()
taskId.PlaceHolder = "任务ID"
subTaskId := widget.NewEntry()
subTaskId.PlaceHolder = "支线任务ID"
this.form.AppendItem(widget.NewFormItem("任务ID", taskId))
this.form.AppendItem(widget.NewFormItem("支线任务ID", subTaskId))
this.form.OnSubmit = func() {
if taskId.Text == "" {
dialog.ShowError(errors.New("请填写任务ID"), this.w)
return
}
if err := service.GetPttService().SendToClient(t.MainType, t.SubType, &pb.RtaskApplyReq{
RtaskId: cast.ToInt32(taskId.Text),
RtaskSubId: cast.ToInt32(subTaskId.Text),
}); err != nil {
logrus.Error(err)
}
}
return this.form
}

View File

@ -1,33 +0,0 @@
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
}

View File

@ -1,43 +0,0 @@
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
}

View File

@ -1,52 +0,0 @@
package formview
import (
"errors"
"go_dreamfactory/cmd/v2/model"
"go_dreamfactory/cmd/v2/service"
"go_dreamfactory/pb"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/widget"
"github.com/sirupsen/logrus"
"github.com/spf13/cast"
)
type RtaskChooseView struct {
BaseformView
}
func (this *RtaskChooseView) CreateView(t *model.TestCase) fyne.CanvasObject {
taskId := widget.NewEntry()
taskId.PlaceHolder = "任务ID"
subTaskId := widget.NewEntry()
subTaskId.PlaceHolder = "支线任务ID"
chooseId := widget.NewEntry()
chooseId.PlaceHolder = "选项ID"
this.form.AppendItem(widget.NewFormItem("任务ID", taskId))
this.form.AppendItem(widget.NewFormItem("支线任务ID", subTaskId))
this.form.AppendItem(widget.NewFormItem("选项ID", chooseId))
this.form.OnSubmit = func() {
if taskId.Text == "" {
dialog.ShowError(errors.New("请填写任务ID"), this.w)
return
}
if chooseId.Text == "" {
dialog.ShowError(errors.New("请填写选项ID"), this.w)
return
}
if err := service.GetPttService().SendToClient(t.MainType, t.SubType, &pb.RtaskChooseReq{
RtaskId: cast.ToInt32(taskId.Text),
RtaskSubId: cast.ToInt32(subTaskId.Text),
ChooseId: cast.ToInt32(chooseId.Text),
}); err != nil {
logrus.Error(err)
}
}
return this.form
}

View File

@ -1,37 +0,0 @@
package formview
import (
"errors"
"go_dreamfactory/cmd/v2/model"
"go_dreamfactory/cmd/v2/service"
"go_dreamfactory/pb"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/widget"
"github.com/sirupsen/logrus"
"github.com/spf13/cast"
)
type RtaskRewardView struct {
BaseformView
}
func (this *RtaskRewardView) CreateView(t *model.TestCase) fyne.CanvasObject {
taskId := widget.NewEntry()
taskId.PlaceHolder = "任务ID"
this.form.AppendItem(widget.NewFormItem("任务ID", taskId))
this.form.OnSubmit = func() {
if taskId.Text == "" {
dialog.ShowError(errors.New("请填写任务ID"), this.w)
return
}
if err := service.GetPttService().SendToClient(t.MainType, t.SubType, &pb.RtaskGetRewardReq{
RtaskId: cast.ToInt32(taskId.Text),
}); err != nil {
logrus.Error(err)
}
}
return this.form
}

View File

@ -6,13 +6,9 @@ import (
) )
const ( const (
RtaskSubTypeChoose = "choose" //选择 RtaskSubTypeList = "list" //随机任务列表
RtaskSubTypeList = "list" //随机任务列表 RtaskSubTypeGetrecord = "getrecord" //任务数据
RtaskSubTypeApply = "apply" //做任务 RtaskSubTypeSend = "send" //触发任务
RtaskSubTypeReward = "getreward" //奖励
RtaskSubTypeBattleStart = "battlestart" //战斗开始
RtaskSubTypeBattleFinish = "battlefinish" //战斗完成
RtaskSubTypeGetrecord = "getrecord" //任务数据
) )
type apiComp struct { type apiComp struct {

29
modules/rtask/api_send.go Normal file
View File

@ -0,0 +1,29 @@
package rtask
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
func (this *apiComp) SendCheck(session comm.IUserSession, req *pb.RtaskSendReq) (code pb.ErrorCode) {
if len(req.Params) == 0 || req.TaskType == 0 {
code = pb.ErrorCode_ReqParameterError
}
return
}
func (this *apiComp) Send(session comm.IUserSession, req *pb.RtaskSendReq) (code pb.ErrorCode, data proto.Message) {
if code = this.moduleRtask.SendToRtask(session, comm.TaskType(req.TaskType), req.Params...); code != pb.ErrorCode_Success {
return
}
rsp := &pb.RtaskSendResp{
IsSucc: true,
}
if err := session.SendMsg(string(this.moduleRtask.GetType()), RtaskSubTypeSend, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
return
}

File diff suppressed because it is too large Load Diff

View File

@ -55,7 +55,7 @@ type DBUserExpand struct {
Recovertimeunifiedticket int64 `protobuf:"varint,31,opt,name=recovertimeunifiedticket,proto3" json:"recovertimeunifiedticket"` //@go_tags(`bson:"recovertimeunifiedticket"`)同意门票恢复时间 Recovertimeunifiedticket int64 `protobuf:"varint,31,opt,name=recovertimeunifiedticket,proto3" json:"recovertimeunifiedticket"` //@go_tags(`bson:"recovertimeunifiedticket"`)同意门票恢复时间
SociatyTicketBuyNum int32 `protobuf:"varint,32,opt,name=sociatyTicketBuyNum,proto3" json:"sociatyTicketBuyNum" bson:"sociatyTicketBuyNum"` //公会boss挑战券购买次数 SociatyTicketBuyNum int32 `protobuf:"varint,32,opt,name=sociatyTicketBuyNum,proto3" json:"sociatyTicketBuyNum" bson:"sociatyTicketBuyNum"` //公会boss挑战券购买次数
SociatyTicket int32 `protobuf:"varint,33,opt,name=sociatyTicket,proto3" json:"sociatyTicket" bson:"sociatyTicket"` //公会boss挑战券数量 SociatyTicket int32 `protobuf:"varint,33,opt,name=sociatyTicket,proto3" json:"sociatyTicket" bson:"sociatyTicket"` //公会boss挑战券数量
Mline map[int32]int32 `protobuf:"bytes,34,rep,name=mline,proto3" json:"mline" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"mline"` //主线关卡最大进度 Mline map[int32]int32 `protobuf:"bytes,34,rep,name=mline,proto3" json:"mline" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"mline"` //主线关卡最大进度 key难度val是关卡ID
} }
func (x *DBUserExpand) Reset() { func (x *DBUserExpand) Reset() {