airobot/busi/shop.go
2022-12-13 10:38:33 +08:00

54 lines
985 B
Go

package busi
import (
"time"
"legu.airobot/lib"
"legu.airobot/pb"
)
//商店场景
var _ lib.IScene = (*ShopScene)(nil)
type ShopScene struct {
lib.Action
}
func (f *ShopScene) Info() lib.SceneInfo {
return lib.SceneInfo{
Name: "商店",
Desc: "测试商店购买",
}
}
func (f *ShopScene) Run(ai lib.IRobot) (err error) {
var (
code pb.ErrorCode
shops *pb.ShopGetListResp
)
if code = ai.SendMsg("gm", "cmd", &pb.GMCmdReq{
Cmod: "bingo:attr,gold,100000",
}, &pb.GMCmdResp{}); code != pb.ErrorCode_Success {
ai.Stop()
}
if code = ai.SendMsg("shop", "getlist", &pb.ShopGetListReq{
SType: pb.ShopType_GoldShop,
IsManualRefresh: true,
}, shops); code != pb.ErrorCode_Success {
ai.Stop()
return
}
for _, v := range shops.Goods {
if v.LeftBuyNum > 0 {
ai.SendMsg("shop", "buy", &pb.ChatSendReq{
Channel: pb.ChatChannel_World,
Content: "hello! are you good?",
}, shops)
time.Sleep(time.Second * 1)
}
}
return nil
}