diff --git a/bin/json/game_smithycustomer.json b/bin/json/game_smithycustomer.json index 820c34bfb..e9e196320 100644 --- a/bin/json/game_smithycustomer.json +++ b/bin/json/game_smithycustomer.json @@ -7,7 +7,13 @@ "text": "我需要{0}件【{1}】,如果你暂时没有备货的话我可以在这等一段时间,但不会太久。" }, "goods": [], - "reword": [], + "reword": [ + { + "a": "attr", + "t": "diamond", + "n": 10 + } + ], "weight": 4500 }, { @@ -18,7 +24,13 @@ "text": "我需要{0}件【{1}】,如果你暂时没有备货的话我可以在这等一段时间,但不会太久。" }, "goods": [], - "reword": [], + "reword": [ + { + "a": "item", + "t": "30001", + "n": 10 + } + ], "weight": 4500 }, { @@ -39,8 +51,20 @@ "key": "4", "text": "我有个宝贝,你要是喜欢的话便宜你点卖你。" }, - "goods": [], - "reword": [], + "goods": [ + { + "a": "item", + "t": "30001", + "n": 10 + } + ], + "reword": [ + { + "a": "attr", + "t": "diamond", + "n": 10 + } + ], "weight": 500 } ] \ No newline at end of file diff --git a/cmd/v2/ui/protocol.go b/cmd/v2/ui/protocol.go index f1a94a970..36cb77d70 100644 --- a/cmd/v2/ui/protocol.go +++ b/cmd/v2/ui/protocol.go @@ -120,6 +120,8 @@ var ( ff(comm.ModuleGrowtask, growtask.GrowtaskSubTypeList): &formview.GrowtaskListView{}, //worldtask ff(comm.ModuleWorldtask, worldtask.WorldtaskSubtypeMine): &formview.WorldtaskMineView{}, + //smithy + ff(comm.ModuleSmithy, "customer"): &formview.SmithyView{}, } ) @@ -147,6 +149,7 @@ var ( string(comm.ModuleGrowtask), string(comm.ModuleWorldtask), string(comm.ModuleReddot), + string(comm.ModuleSmithy), }, "gm": {ff(comm.ModuleGM, "cmd")}, "sys": { @@ -245,6 +248,9 @@ var ( "worldtask": { ff(comm.ModuleWorldtask, worldtask.WorldtaskSubtypeMine), }, + "smithy": { + ff(comm.ModuleSmithy, "customer"), + }, } ) @@ -877,6 +883,19 @@ var ( SubType: worldtask.WorldtaskSubtypeMine, Enabled: true, }, + // smithy + string(comm.ModuleSmithy): { + NavLabel: "铁匠铺", + MainType: string(comm.ModuleSmithy), + Enabled: true, + }, + ff(comm.ModuleSmithy, "customer"): { + NavLabel: "顾客", + Desc: "当前铁匠铺中的顾客", + MainType: string(comm.ModuleSmithy), + SubType: "customer", + Enabled: true, + }, } ) diff --git a/cmd/v2/ui/views/smithy.go b/cmd/v2/ui/views/smithy.go new file mode 100644 index 000000000..fad4d8847 --- /dev/null +++ b/cmd/v2/ui/views/smithy.go @@ -0,0 +1,35 @@ +package formview + +import ( + "go_dreamfactory/cmd/v2/model" + "go_dreamfactory/cmd/v2/service" + "go_dreamfactory/pb" + + "fyne.io/fyne/v2" + "fyne.io/fyne/v2/container" + "fyne.io/fyne/v2/widget" + "github.com/sirupsen/logrus" +) + +type SmithyView struct { + BaseformView +} + +func (s *SmithyView) CreateView(t *model.TestCase) fyne.CanvasObject { + //查询顾客 + loadCustomer := func() { + if err := service.GetPttService().SendToClient( + t.MainType, + "customer", + &pb.SmithyCustomerReq{}, + ); err != nil { + logrus.Error(err) + return + } + } + customerBtn := widget.NewButton("顾客", loadCustomer) + + btns := container.NewHBox(customerBtn) + c := container.NewBorder(btns, nil, nil, nil) + return c +} diff --git a/modules/smithy/api_trade.go b/modules/smithy/api_trade.go index 2bf2f76fe..4967039c0 100644 --- a/modules/smithy/api_trade.go +++ b/modules/smithy/api_trade.go @@ -4,7 +4,7 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/pb" - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" ) // 贸易 @@ -16,7 +16,7 @@ func (this *apiComp) SellCheck(session comm.IUserSession, req *pb.SmithySellReq) return } -func (this *apiComp) SellItem(session comm.IUserSession, req *pb.SmithySellReq) (code pb.ErrorCode, data proto.Message) { +func (this *apiComp) Sell(session comm.IUserSession, req *pb.SmithySellReq) (code pb.ErrorCode, data proto.Message) { if code = this.SellCheck(session, req); code != pb.ErrorCode_Success { return } diff --git a/modules/smithy/model_trade.go b/modules/smithy/model_trade.go index 793f675b5..4196c1c11 100644 --- a/modules/smithy/model_trade.go +++ b/modules/smithy/model_trade.go @@ -45,6 +45,9 @@ func newWeightedRandom(items []*cfg.GameSmithyCustomerData) *WeightedRandom { } func (wr *WeightedRandom) pick() *cfg.GameSmithyCustomerData { + if wr.totalWeight <= 0 { + return nil + } randomNumber := rand.Intn(wr.totalWeight) for _, item := range wr.items { if randomNumber < int(item.Weight) {