This commit is contained in:
liwei 2023-05-23 15:50:22 +08:00
parent 693c1fc434
commit ed50769ca0
8 changed files with 141 additions and 47 deletions

View File

@ -42,6 +42,7 @@ type Config struct {
ServiceDBInfo *pb.ServiceDBInfo `json:"serviceDBInfo,omitempty"` //
JsonDir string `json:"jsonDir,omitempty"` //json配置目录
PingConf *PingConf `json:"pingConf,omitempty"` //ping配置
MultiMgo map[string]*MgoDB `json:"multiMgo,omitempty"` //MongoDBMap
}
type PingConf struct {

View File

@ -1,11 +1,17 @@
package formview
import (
"fmt"
os_storage "go_dreamfactory/cmd/v2/lib/storage"
"go_dreamfactory/cmd/v2/model"
"strings"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/data/binding"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
"github.com/sirupsen/logrus"
"github.com/spf13/cast"
@ -29,36 +35,90 @@ func (this *GlobalConfView) CreateView(t *model.TestCase) fyne.CanvasObject {
logrus.Error(err)
return &fyne.Container{}
}
//redis form
redisForm := widget.NewForm()
//mongo form
// 表单
createForm := func() *widget.Form {
name := widget.NewEntry()
mongoUrl := widget.NewEntry()
port := widget.NewEntry()
user := widget.NewEntry()
passd := widget.NewEntry()
mongoDatabase := widget.NewEntry()
mongoForm := widget.NewForm(
widget.NewFormItem("Name", name),
widget.NewFormItem("Addr", container.NewBorder(nil, nil, nil, port, mongoUrl)),
widget.NewFormItem("User", user),
widget.NewFormItem("Pass", passd),
widget.NewFormItem("DBName", mongoDatabase),
)
if this.conf.ServiceDBInfo != nil {
user.Text = this.conf.MgoDB.User
passd.Text = this.conf.MgoDB.Password
mongoUrl.Text = this.conf.MgoDB.Host
port.Text = cast.ToString(this.conf.MgoDB.Port)
mongoDatabase.Text = this.conf.MgoDB.Database
return mongoForm
}
bottomBtn := widget.NewButton("保存", func() {
center := container.NewHBox()
topBtn := widget.NewButton("新建", func() {
//mongo form
mongoForm := createForm()
dconf := dialog.NewCustom("创建数据源", "关闭", mongoForm, this.w)
mongoForm.OnSubmit = func() {
if this.conf.MultiMgo == nil {
this.conf.MultiMgo = make(map[string]*os_storage.MgoDB)
}
name := mongoForm.Items[0]
mongoUrl := mongoForm.Items[1]
port := mongoForm.Items[2]
user := mongoForm.Items[3]
passd := mongoForm.Items[4]
mongoDatabase := mongoForm.Items[5]
if _, ok := this.conf.MultiMgo[name.Text]; ok {
dialog.NewInformation("提示", name.Text+" 数据源已存在", this.w)
return
}
this.conf.MultiMgo[name.Text] = &os_storage.MgoDB{
Name: name.Text,
Host: mongoUrl.Text,
Port: cast.ToInt32(port.Text),
User: user.Text,
Password: passd.Text,
Database: mongoDatabase.Text,
}
if err := this.storage.StoreConfig(this.conf); err != nil {
logrus.Error(err)
}
dconf.Hide()
center.Refresh()
}
mongoForm.SubmitText = "确定"
dconf.Resize(fyne.NewSize(400, 200))
dconf.Show()
})
layout := container.NewGridWithRows(2, redisForm, mongoForm)
c := container.NewBorder(nil, bottomBtn, nil, nil, layout)
editBtn := widget.NewButtonWithIcon("", theme.SettingsIcon(), func() {})
// 创建Card
for k, v := range this.conf.MultiMgo {
data := binding.BindStringList(&[]string{})
data.Append(fmt.Sprintf("%-3s\t: %s", "addr", strings.Join([]string{v.Host, cast.ToString(v.Port)}, ":")))
data.Append(fmt.Sprintf("user:%v", v.User))
data.Append(fmt.Sprintf("pass:%v", v.Password))
data.Append(fmt.Sprintf("DB:%v", v.Database))
dataList := widget.NewListWithData(data,
func() fyne.CanvasObject {
return widget.NewLabel("template")
},
func(i binding.DataItem, o fyne.CanvasObject) {
o.(*widget.Label).Bind(i.(binding.String))
},
)
obj := widget.NewCard("", "",
container.NewBorder(container.NewHBox(widget.NewLabel(k), layout.NewSpacer(), editBtn), nil, nil, nil, dataList),
)
obj.Resize(fyne.NewSize(400, 450))
center.AddObject(obj)
}
c := container.NewBorder(container.NewHBox(topBtn), nil, nil, nil, container.NewWithoutLayout(container.NewHBox(center)))
return c
}

View File

@ -72,6 +72,8 @@ func (a *apiComp) Do(session comm.IUserSession, req *pb.DispatchDoReq) (code pb.
return
}
go a.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype186, 1))
//扣除门票
a.module.ConsumeRes(session, []*cfg.Gameatn{ticketAtn}, true)

View File

@ -186,7 +186,8 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondHandle)
comm.Rtype62, comm.Rtype64, comm.Rtype69, comm.Rtype72, comm.Rtype88, comm.Rtype104,
comm.Rtype96, comm.Rtype105, comm.Rtype128, comm.Rtype130, comm.Rtype131,
comm.Rtype141, comm.Rtype142, comm.Rtype143, comm.Rtype144, comm.Rtype145, comm.Rtype146,
comm.Rtype147, comm.Rtype149, comm.Rtype153, comm.Rtype154, comm.Rtype155, comm.Rtype156:
comm.Rtype147, comm.Rtype149, comm.Rtype153, comm.Rtype154, comm.Rtype155, comm.Rtype156,
comm.Rtype171, comm.Rtype186:
condi := &rtaskCondHandle{
condId: v.Id,
find: this.modelRtaskRecord.lessEqualFirstParam,
@ -309,6 +310,17 @@ func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType com
return
}
if conf.Data == 1 { //接取
if r, ok := record.Vals[handle.condId]; ok {
if r.Flag == 0 { //非接取
r.Data = make(map[int32]int32)
r.Rtype = conf.Type
} else {
return
}
}
}
if handle.update != nil {
if err := handle.update(uid, record, conf, params...); err != nil {
log.Errorf("update task:%v", err)

View File

@ -87,6 +87,7 @@ func (this *apiComp) ActiveReceive(session comm.IUserSession, req *pb.TaskActive
log.Field{Key: "code", Value: code},
)
}
go this.moduleTask.ModuleRtask.TriggerTask(uid, comm.GettaskParam(comm.Rtype171, 1))
}
resp := &pb.TaskActiveReceiveResp{

View File

@ -146,6 +146,15 @@ func (this *ModelWorldtask) checkCondi(uid string, condiId int32) bool {
)
return false
}
//update flag=1
dr := iwt.GetCondiData(uid)
if dr != nil {
if v, ok := dr.Vals[condiId]; ok {
v.Flag = 1
iwt.ChangeCondi(uid, dr.Vals)
}
}
return true
}
}

View File

@ -197,7 +197,7 @@ func (this *Worldtask) BingoJumpTask(session comm.IUserSession, groupId, taskId
mytask.CurrentTask = make(map[int32]*pb.Worldtask)
}
if len(nextTaskIds) == 1 {
if len(nextTaskIds) >= 1 {
mytask.CurrentTask[groupId] = &pb.Worldtask{
TaskId: nextTaskIds[0],
TaskType: 2, //设置主线类型

View File

@ -455,6 +455,7 @@ type RtaskData struct {
Data map[int32]int32 `protobuf:"bytes,1,rep,name=data,proto3" json:"data" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"data"` // 当前任务值
Rtype int32 `protobuf:"varint,2,opt,name=rtype,proto3" json:"rtype" bson:"rtype"` // 任务类型
Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp"` //@go_tasg(`bson:"timestamp"`) 时间戳
Flag int32 `protobuf:"varint,4,opt,name=flag,proto3" json:"flag"` //@go_tasg(`bson:"flag"`) 任务是接取时记录 flag:1表示已记录 再次记录时不清除
}
func (x *RtaskData) Reset() {
@ -510,6 +511,13 @@ func (x *RtaskData) GetTimestamp() int64 {
return 0
}
func (x *RtaskData) GetFlag() int32 {
if x != nil {
return x.Flag
}
return 0
}
// 玩家任务记录
type DBRtaskRecord struct {
state protoimpl.MessageState
@ -636,30 +644,31 @@ var file_task_task_db_proto_rawDesc = []byte{
0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x20, 0x0a, 0x05,
0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x66, 0x72,
0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02,
0x38, 0x01, 0x22, 0xa2, 0x01, 0x0a, 0x09, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61,
0x38, 0x01, 0x22, 0xb6, 0x01, 0x0a, 0x09, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61,
0x12, 0x28, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14,
0x2e, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x45,
0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x74,
0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x74, 0x79, 0x70, 0x65,
0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20,
0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x1a, 0x37,
0x0a, 0x09, 0x44, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b,
0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a,
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61,
0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xba, 0x01, 0x0a, 0x0d, 0x44, 0x42, 0x52, 0x74,
0x61, 0x73, 0x6b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x2c, 0x0a, 0x04, 0x76,
0x61, 0x6c, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x44, 0x42, 0x52, 0x74,
0x61, 0x73, 0x6b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2e, 0x56, 0x61, 0x6c, 0x73, 0x45, 0x6e,
0x74, 0x72, 0x79, 0x52, 0x04, 0x76, 0x61, 0x6c, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x74, 0x69,
0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x1a,
0x43, 0x0a, 0x09, 0x56, 0x61, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03,
0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x20,
0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e,
0x72, 0x74, 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x12,
0x0a, 0x04, 0x66, 0x6c, 0x61, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x6c,
0x61, 0x67, 0x1a, 0x37, 0x0a, 0x09, 0x44, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12,
0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65,
0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05,
0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xba, 0x01, 0x0a, 0x0d,
0x44, 0x42, 0x52, 0x74, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x0e, 0x0a,
0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a,
0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12,
0x2c, 0x0a, 0x04, 0x76, 0x61, 0x6c, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e,
0x44, 0x42, 0x52, 0x74, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2e, 0x56, 0x61,
0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x76, 0x61, 0x6c, 0x73, 0x12, 0x14, 0x0a,
0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x74,
0x69, 0x6d, 0x65, 0x1a, 0x43, 0x0a, 0x09, 0x56, 0x61, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79,
0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b,
0x65, 0x79, 0x12, 0x20, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x0a, 0x2e, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x52, 0x05, 0x76,
0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (