公会场景

This commit is contained in:
wh_zcy 2022-12-14 19:52:35 +08:00
parent afe52e8070
commit 610aaec652
2 changed files with 47 additions and 2 deletions

View File

@ -5,6 +5,11 @@ import (
"time"
)
const (
USER_LOGIN = "user.login"
SOCIATY_MINE = "sociaty.mine"
)
func Sleep(min, max time.Duration) {
ulit := int64(max - min)
t := time.Duration(rand.Int63n(ulit)) + min

View File

@ -1,9 +1,21 @@
package busi
import "legu.airobot/lib"
import (
"fmt"
"time"
"github.com/Pallinder/go-randomdata"
"github.com/sirupsen/logrus"
"legu.airobot/lib"
"legu.airobot/pb"
)
var _ lib.IScene = (*SociatyScene)(nil)
const (
SociatyMainType = "sociaty"
)
type SociatyScene struct {
lib.Action
}
@ -17,6 +29,34 @@ func (s *SociatyScene) Info() lib.SceneInfo {
func (s *SociatyScene) Run(robot lib.IRobot) error {
createSociaty(robot)
Sleep(time.Second, time.Second*3)
mine(robot)
return nil
}
// 创建公会
func createSociaty(robot lib.IRobot) {
req := &pb.SociatyCreateReq{}
rsp := &pb.SociatyCreateResp{}
req.Name = fmt.Sprintf("%s_%s", randomdata.SillyName(), randomdata.City())
req.IsApplyCheck = false
req.ApplyLv = 1
if code := robot.SendMsg(SociatyMainType, "create", req, rsp); code != pb.ErrorCode_Success {
logrus.Debugf("公会创建:%v", code)
return
}
}
func mine(robot lib.IRobot) {
req := &pb.SociatyMineReq{}
rsp := &pb.SociatyMineResp{}
if code := robot.SendMsg(SociatyMainType, "mine", req, rsp); code != pb.ErrorCode_Success {
logrus.Debugf("我的公会:%v", code)
}
robot.Store(SOCIATY_MINE, rsp)
}