This commit is contained in:
wh_zcy 2023-02-17 11:59:38 +08:00
parent 61daf826cc
commit 15df32ec6d
5 changed files with 87 additions and 6 deletions

View File

@ -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
}
]

View File

@ -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,
},
}
)

35
cmd/v2/ui/views/smithy.go Normal file
View File

@ -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
}

View File

@ -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
}

View File

@ -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) {