更新smithy_trade字段类型
This commit is contained in:
parent
0be6315357
commit
d70cd3a7c6
@ -7,6 +7,8 @@ import (
|
|||||||
"go_dreamfactory/cmd/v2/service/observer"
|
"go_dreamfactory/cmd/v2/service/observer"
|
||||||
mytheme "go_dreamfactory/cmd/v2/theme"
|
mytheme "go_dreamfactory/cmd/v2/theme"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"path"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
"fyne.io/fyne/v2/container"
|
"fyne.io/fyne/v2/container"
|
||||||
@ -19,25 +21,30 @@ import (
|
|||||||
|
|
||||||
type jsonFileList struct {
|
type jsonFileList struct {
|
||||||
selItemId string //选择的文件ID
|
selItemId string //选择的文件ID
|
||||||
cacheList common.List
|
cachedList common.List
|
||||||
itemList *widget.List
|
itemList *widget.List
|
||||||
fileTotal int //文件数
|
fileTotal int //文件数
|
||||||
|
|
||||||
|
//字段
|
||||||
|
columnList *widget.List
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newJsonFileList() *jsonFileList {
|
func newJsonFileList() *jsonFileList {
|
||||||
return &jsonFileList{
|
return &jsonFileList{
|
||||||
cacheList: common.NewList(""),
|
cachedList: common.NewList(""),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type appConfigValid struct {
|
type appConfigValid struct {
|
||||||
appAdapter
|
appAdapter
|
||||||
jsonFileList
|
jsonFileList *jsonFileList
|
||||||
|
jsonDirString string //json目录
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *appConfigValid) LazyInit(pt service.PttService, obs observer.Observer) error {
|
func (a *appConfigValid) LazyInit(pt service.PttService, obs observer.Observer) error {
|
||||||
a.tabItem = container.NewTabItemWithIcon(common.TOOLBAR_VALID, mytheme.ResourceExcelJpg, nil)
|
a.tabItem = container.NewTabItemWithIcon(common.TOOLBAR_VALID, mytheme.ResourceExcelJpg, nil)
|
||||||
a.jsonFileList = *newJsonFileList()
|
a.jsonFileList = newJsonFileList()
|
||||||
|
|
||||||
//load conf
|
//load conf
|
||||||
storage, _ := os_storage.NewOSStorage()
|
storage, _ := os_storage.NewOSStorage()
|
||||||
@ -48,7 +55,7 @@ func (a *appConfigValid) LazyInit(pt service.PttService, obs observer.Observer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if conf.JsonDir != "" {
|
if conf.JsonDir != "" {
|
||||||
|
a.jsonDirString = conf.JsonDir
|
||||||
}
|
}
|
||||||
content := container.NewMax()
|
content := container.NewMax()
|
||||||
content.Objects = []fyne.CanvasObject{}
|
content.Objects = []fyne.CanvasObject{}
|
||||||
@ -72,6 +79,10 @@ func (a *appConfigValid) LazyInit(pt service.PttService, obs observer.Observer)
|
|||||||
//配置json路径
|
//配置json路径
|
||||||
jsonDir := widget.NewEntry()
|
jsonDir := widget.NewEntry()
|
||||||
jsonDir.PlaceHolder = "json目录"
|
jsonDir.PlaceHolder = "json目录"
|
||||||
|
jsonDir.OnChanged = func(s string) {
|
||||||
|
a.jsonFileList.initItem(jsonDir.Text)
|
||||||
|
a.jsonDirString = jsonDir.Text
|
||||||
|
}
|
||||||
form := widget.NewForm(
|
form := widget.NewForm(
|
||||||
widget.NewFormItem("json目录", container.NewBorder(nil, nil, nil, widget.NewButtonWithIcon("", theme.FolderIcon(), func() {
|
widget.NewFormItem("json目录", container.NewBorder(nil, nil, nil, widget.NewButtonWithIcon("", theme.FolderIcon(), func() {
|
||||||
openFolder(jsonDir)
|
openFolder(jsonDir)
|
||||||
@ -81,7 +92,26 @@ func (a *appConfigValid) LazyInit(pt service.PttService, obs observer.Observer)
|
|||||||
|
|
||||||
jsonDir.SetText(conf.JsonDir)
|
jsonDir.SetText(conf.JsonDir)
|
||||||
|
|
||||||
c := container.NewBorder(form, nil, nil, nil)
|
confBtn := &widget.Button{Text: "保存配置", Icon: theme.DocumentCreateIcon()}
|
||||||
|
confBtn.OnTapped = func() {
|
||||||
|
conf.JsonDir = jsonDir.Text
|
||||||
|
|
||||||
|
if err := storage.StoreConfig(conf); err != nil {
|
||||||
|
logrus.WithField("err", err).Debug("保存配置")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建json文件 List
|
||||||
|
a.jsonFileList.itemList = a.jsonFileList.createList()
|
||||||
|
|
||||||
|
//创建字段
|
||||||
|
|
||||||
|
c := container.NewBorder(form,
|
||||||
|
container.NewHBox(confBtn),
|
||||||
|
nil, nil,
|
||||||
|
container.NewGridWithColumns(3,
|
||||||
|
container.NewVScroll(a.jsonFileList.itemList)))
|
||||||
|
|
||||||
content.Objects = append(content.Objects, c)
|
content.Objects = append(content.Objects, c)
|
||||||
a.tabItem.Content = content
|
a.tabItem.Content = content
|
||||||
@ -104,19 +134,39 @@ func (f *jsonFileList) initItem(dir string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
if file.IsDir() {
|
fileSuffix := path.Ext(file.Name())
|
||||||
if file.Name() == ".vscode" {
|
name := strings.TrimSuffix(file.Name(), fileSuffix)
|
||||||
continue
|
name = strings.TrimPrefix(name, "game_")
|
||||||
}
|
|
||||||
fm := common.Item{
|
fm := common.Item{
|
||||||
Text: file.Name(),
|
Id: file.Name(),
|
||||||
|
Text: name,
|
||||||
Checked: false,
|
Checked: false,
|
||||||
}
|
}
|
||||||
f.cacheList.Items = append(f.cacheList.Items, fm)
|
f.cachedList.Items = append(f.cachedList.Items, fm)
|
||||||
// f.selItemIds = append(f.selItemIds, fm.Id)
|
|
||||||
f.fileTotal++
|
f.fileTotal++
|
||||||
// logrus.Debugf("%v", fm.Id)
|
// logrus.Debugf("%v", fm.Id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *jsonFileList) createList() *widget.List {
|
||||||
|
f.itemList = widget.NewList(
|
||||||
|
func() int {
|
||||||
|
return len(f.cachedList.Items)
|
||||||
|
},
|
||||||
|
func() fyne.CanvasObject {
|
||||||
|
return widget.NewLabel("Template")
|
||||||
|
},
|
||||||
|
func(id widget.ListItemID, item fyne.CanvasObject) {
|
||||||
|
c, _ := item.(*widget.Label)
|
||||||
|
c.Text = f.cachedList.Items[id].Text
|
||||||
|
c.Refresh()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
f.itemList.OnSelected = func(id widget.ListItemID) {
|
||||||
|
selId := f.cachedList.Items[id].Id
|
||||||
|
f.selItemId = selId
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return f.itemList
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,25 @@ func (s *SmithyView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
customerBtn := widget.NewButton("顾客", loadCustomer)
|
|
||||||
|
|
||||||
btns := container.NewHBox(customerBtn)
|
//交易
|
||||||
|
jiaoyi := func() {
|
||||||
|
if err := service.GetPttService().SendToClient(
|
||||||
|
t.MainType,
|
||||||
|
"jiaoyi",
|
||||||
|
&pb.SmithySellReq{
|
||||||
|
EquipIds: []string{},
|
||||||
|
CustomerId: 1,
|
||||||
|
},
|
||||||
|
); err != nil {
|
||||||
|
logrus.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
customerBtn := widget.NewButton("顾客", loadCustomer)
|
||||||
|
jiaoyiBtn := widget.NewButton("交易", jiaoyi)
|
||||||
|
|
||||||
|
btns := container.NewHBox(customerBtn, jiaoyiBtn)
|
||||||
c := container.NewBorder(btns, nil, nil, nil)
|
c := container.NewBorder(btns, nil, nil, nil)
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
@ -150,12 +150,12 @@ func (s *modelTrade) updateCustomer(uid string, customerId int32) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 返回概率下的套装
|
// 返回概率下的套装
|
||||||
func (s *modelTrade) GetSuitRandom(uid string) string {
|
func (s *modelTrade) GetSuitRandom(uid string) (suiteId int32) {
|
||||||
//获取玩家所有解锁套装
|
//获取玩家所有解锁套装
|
||||||
uex, err := s.module.ModuleUser.GetUserExpand(uid)
|
uex, err := s.module.ModuleUser.GetUserExpand(uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.module.Errorln(err)
|
s.module.Errorln(err)
|
||||||
return ""
|
return
|
||||||
}
|
}
|
||||||
var unlockSuiteItems []*WeightItem
|
var unlockSuiteItems []*WeightItem
|
||||||
for _, v := range uex.SuiteId {
|
for _, v := range uex.SuiteId {
|
||||||
@ -168,7 +168,7 @@ func (s *modelTrade) GetSuitRandom(uid string) string {
|
|||||||
ec, suites := s.module.ModuleEquipment.GetActionableSuit(uid)
|
ec, suites := s.module.ModuleEquipment.GetActionableSuit(uid)
|
||||||
if ec!=pb.ErrorCode_Success {
|
if ec!=pb.ErrorCode_Success {
|
||||||
s.module.Error("获取玩家已有装备:", log.Field{Key:"code",Value: ec})
|
s.module.Error("获取玩家已有装备:", log.Field{Key:"code",Value: ec})
|
||||||
return ""
|
return
|
||||||
}
|
}
|
||||||
var ownerSuiteItems []*WeightItem
|
var ownerSuiteItems []*WeightItem
|
||||||
for _, v := range suites {
|
for _, v := range suites {
|
||||||
@ -182,9 +182,9 @@ func (s *modelTrade) GetSuitRandom(uid string) string {
|
|||||||
// 设置权重
|
// 设置权重
|
||||||
wr := newWeightedRandom(merge)
|
wr := newWeightedRandom(merge)
|
||||||
if c := wr.pick(); c != nil {
|
if c := wr.pick(); c != nil {
|
||||||
return c.Id.(string)
|
return c.Id.(int32)
|
||||||
}
|
}
|
||||||
return ""
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 交易
|
// 交易
|
||||||
|
@ -185,7 +185,7 @@ type CustomerInfo struct {
|
|||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
CustomerId int32 `protobuf:"varint,1,opt,name=customerId,proto3" json:"customerId"` //顾客ID
|
CustomerId int32 `protobuf:"varint,1,opt,name=customerId,proto3" json:"customerId"` //顾客ID
|
||||||
SuitId string `protobuf:"bytes,2,opt,name=suitId,proto3" json:"suitId"` //套装ID 随机套装
|
SuitId int32 `protobuf:"varint,2,opt,name=suitId,proto3" json:"suitId"` //套装ID 随机套装
|
||||||
EquipCount int32 `protobuf:"varint,3,opt,name=equipCount,proto3" json:"equipCount"` //装备数量
|
EquipCount int32 `protobuf:"varint,3,opt,name=equipCount,proto3" json:"equipCount"` //装备数量
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,11 +228,11 @@ func (x *CustomerInfo) GetCustomerId() int32 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *CustomerInfo) GetSuitId() string {
|
func (x *CustomerInfo) GetSuitId() int32 {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.SuitId
|
return x.SuitId
|
||||||
}
|
}
|
||||||
return ""
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *CustomerInfo) GetEquipCount() int32 {
|
func (x *CustomerInfo) GetEquipCount() int32 {
|
||||||
@ -773,7 +773,7 @@ var file_smithy_smithy_db_proto_rawDesc = []byte{
|
|||||||
0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x75,
|
0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x75,
|
||||||
0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a,
|
0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a,
|
||||||
0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x75,
|
0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x75,
|
||||||
0x69, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x75, 0x69, 0x74,
|
0x69, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x75, 0x69, 0x74,
|
||||||
0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x71, 0x75, 0x69, 0x70, 0x43, 0x6f, 0x75, 0x6e, 0x74,
|
0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x71, 0x75, 0x69, 0x70, 0x43, 0x6f, 0x75, 0x6e, 0x74,
|
||||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x65, 0x71, 0x75, 0x69, 0x70, 0x43, 0x6f, 0x75,
|
0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x65, 0x71, 0x75, 0x69, 0x70, 0x43, 0x6f, 0x75,
|
||||||
0x6e, 0x74, 0x22, 0x9b, 0x01, 0x0a, 0x0a, 0x44, 0x42, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65,
|
0x6e, 0x74, 0x22, 0x9b, 0x01, 0x0a, 0x0a, 0x44, 0x42, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65,
|
||||||
|
Loading…
Reference in New Issue
Block a user