修改代码
This commit is contained in:
parent
0c3791c591
commit
512e1a69bd
@ -39,12 +39,16 @@ func (f *ArenaScene) Run(ai lib.IRobot) (err error) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if code = ai.SendMsg("arena", "info", &pb.ArenaInfoReq{}, &pb.ArenaInfoResp{}); code != pb.ErrorCode_Success {
|
||||
ai.Stop()
|
||||
return
|
||||
}
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
if code = ai.SendMsg("arena", "matche", &pb.ArenaMatcheReq{}, matche); code != pb.ErrorCode_Success {
|
||||
ai.Stop()
|
||||
return
|
||||
}
|
||||
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
for _, v := range matche.Players {
|
||||
if code = ai.SendMsg("arena", "challenge", &pb.ArenaChallengeReq{
|
||||
Playerid: v.Uid,
|
||||
|
@ -36,12 +36,12 @@ func (f *ChatScene) Run(ai lib.IRobot) (err error) {
|
||||
ai.Stop()
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Second * 1)
|
||||
Sleep(time.Second*0, time.Second*3)
|
||||
|
||||
//工会聊天
|
||||
if resp := ai.Get("user.login"); resp != nil {
|
||||
userlogin = resp.(*pb.UserLoginResp)
|
||||
if userlogin.Ex.SociatyId != "" {
|
||||
if userlogin.Ex != nil && userlogin.Ex.SociatyId != "" {
|
||||
if code = ai.SendMsg("chat", "send", &pb.ChatSendReq{
|
||||
Channel: pb.ChatChannel_Union,
|
||||
TargetId: userlogin.Ex.SociatyId,
|
||||
|
64
busi/hero.go
64
busi/hero.go
@ -26,44 +26,56 @@ func (f *HeroScene) Info() lib.SceneInfo {
|
||||
func (f *HeroScene) Run(robot lib.IRobot) error {
|
||||
|
||||
f.AddHero(robot, "25001") // 加阿宝
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
f.AddHero(robot, "44911") // 升级精灵
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
f.AddHero(robot, "45921") // 技能精灵
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
f.AddHero(robot, "45921") // 技能精灵
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
// f.AddAttrGold(robot) // 加金币
|
||||
// f.AddAttrDiamond(robot) // 加钻石
|
||||
time.Sleep(10 * time.Millisecond) // 等待10ms
|
||||
f.HeroLvUp(robot) // 英雄升级
|
||||
time.Sleep(10 * time.Millisecond) // 等待10ms
|
||||
f.HeroSkillLvUp(robot) // 技能升级
|
||||
f.HeroLvUp(robot) // 英雄升级
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
f.HeroSkillLvUp(robot) // 技能升级
|
||||
|
||||
// 升星
|
||||
|
||||
time.Sleep(10 * time.Millisecond) // 等待10ms
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
f.HeroStarUp(robot)
|
||||
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
// time.Sleep(50 * time.Millisecond)
|
||||
// f.HeroResonance(robot) // 共鸣
|
||||
|
||||
f.AddItem(robot, "50001") // 觉醒材料
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
f.HeroAwaken(robot)
|
||||
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
f.AddItem(robot, "30001") // 抽卡材料
|
||||
f.HeroDraw(robot) // 普通十连
|
||||
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
f.HeroDraw(robot) // 普通十连
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
// 购买抽卡道具
|
||||
|
||||
f.HeroDraw(robot)
|
||||
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
// 卡牌融合
|
||||
f.AddHero(robot, "25004") // 加英雄
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
f.AddHero(robot, "25004") // 加英雄
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
f.AddHero(robot, "25004") // 加英雄
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
f.AddHero(robot, "25004") // 加英雄
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
f.HeroFusion(robot)
|
||||
|
||||
f.AddItem(robot, "525001")
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
f.AddItem(robot, "25001")
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
f.HeroTalent(robot)
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
f.HeroTalentV2(robot) // 学习其他天赋
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -156,19 +168,21 @@ func (f *HeroScene) HeroLvUp(robot lib.IRobot) error {
|
||||
break
|
||||
}
|
||||
}
|
||||
// 升级
|
||||
lvReq := &pb.HeroStrengthenUplvReq{
|
||||
HeroObjID: lvcard.Id,
|
||||
ExpCards: []*pb.MapStringInt32{},
|
||||
}
|
||||
lvReq.ExpCards = append(lvReq.ExpCards, &pb.MapStringInt32{
|
||||
Key: expCard.Id,
|
||||
Value: 1,
|
||||
})
|
||||
lvRsp := &pb.HeroStrengthenUplvResp{}
|
||||
code = robot.SendMsg("hero", "strengthenuplv", lvReq, lvRsp)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return nil
|
||||
if lvcard != nil {
|
||||
// 升级
|
||||
lvReq := &pb.HeroStrengthenUplvReq{
|
||||
HeroObjID: lvcard.Id,
|
||||
ExpCards: []*pb.MapStringInt32{},
|
||||
}
|
||||
lvReq.ExpCards = append(lvReq.ExpCards, &pb.MapStringInt32{
|
||||
Key: expCard.Id,
|
||||
Value: 1,
|
||||
})
|
||||
lvRsp := &pb.HeroStrengthenUplvResp{}
|
||||
code = robot.SendMsg("hero", "strengthenuplv", lvReq, lvRsp)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -1,6 +1,8 @@
|
||||
package busi
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/Pallinder/go-randomdata"
|
||||
"legu.airobot/lib"
|
||||
"legu.airobot/pb"
|
||||
@ -33,5 +35,6 @@ func (l *LoginScene) Run(robot lib.IRobot) error {
|
||||
if code := robot.SendMsg("user", "login", req, rsp); code == pb.ErrorCode_Success {
|
||||
robot.Store("user.login", rsp)
|
||||
}
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
return nil
|
||||
}
|
||||
|
@ -40,17 +40,17 @@ func (f *MfantasyScene) Run(ai lib.IRobot) (err error) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
if code = ai.SendMsg("gm", "cmd", &pb.GMCmdReq{
|
||||
Cmod: "bingo:moon,1",
|
||||
}, &pb.GMCmdResp{}); code != pb.ErrorCode_Success {
|
||||
ai.Stop()
|
||||
}
|
||||
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
if code = ai.SendMsg("moonfantasy", "getlist", &pb.MoonfantasyGetListReq{}, mflist); code != pb.ErrorCode_Success {
|
||||
ai.Stop()
|
||||
}
|
||||
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
for _, v := range mflist.Dfantasys {
|
||||
if code = ai.SendMsg("moonfantasy", "battle", &pb.MoonfantasyBattleReq{
|
||||
Mid: v.Monster,
|
||||
|
18
busi/pay.go
18
busi/pay.go
@ -31,21 +31,21 @@ func (f *PayScene) Run(ai lib.IRobot) (err error) {
|
||||
}, &pb.PayDailyBuyResp{}); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Second)
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
if code = ai.SendMsg("pay", "dailybuy", &pb.PayDailyBuyReq{
|
||||
Id: 2,
|
||||
}, &pb.PayDailyBuyResp{}); code != pb.ErrorCode_Success {
|
||||
ai.Stop()
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Second)
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
|
||||
if code = ai.SendMsg("privilege", "buyyueka", &pb.PrivilegeBuyYuekaReq{
|
||||
CID: "yueka_lv1",
|
||||
}, &pb.PrivilegeBuyYuekaResp{}); code != pb.ErrorCode_Success {
|
||||
ai.Stop()
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Second)
|
||||
// if code = ai.SendMsg("privilege", "buyyueka", &pb.PrivilegeBuyYuekaReq{
|
||||
// CID: "yueka_lv1",
|
||||
// }, &pb.PrivilegeBuyYuekaResp{}); code != pb.ErrorCode_Success {
|
||||
// ai.Stop()
|
||||
// return
|
||||
// }
|
||||
// time.Sleep(time.Second)
|
||||
return
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package busi
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"legu.airobot/lib"
|
||||
"legu.airobot/pb"
|
||||
)
|
||||
@ -29,6 +31,7 @@ func (f *ResMgrScene) Run(ai lib.IRobot) (err error) {
|
||||
}, &pb.GMCmdResp{}); code != pb.ErrorCode_Success {
|
||||
ai.Stop()
|
||||
}
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
herolistreq := &pb.HeroListReq{}
|
||||
herolistresp := &pb.HeroListResp{}
|
||||
if code = ai.SendMsg("hero", "list", herolistreq, herolistresp); code != pb.ErrorCode_Success {
|
||||
@ -36,13 +39,14 @@ func (f *ResMgrScene) Run(ai lib.IRobot) (err error) {
|
||||
return
|
||||
}
|
||||
ai.Store("hero.list", herolistresp)
|
||||
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
itemlistreq := &pb.ItemsGetlistReq{}
|
||||
itemlistresp := &pb.ItemsGetlistResp{}
|
||||
if code = ai.SendMsg("item", "list", itemlistreq, itemlistresp); code != pb.ErrorCode_Success {
|
||||
if code = ai.SendMsg("items", "list", itemlistreq, itemlistresp); code != pb.ErrorCode_Success {
|
||||
ai.Stop()
|
||||
return
|
||||
}
|
||||
ai.Store("item.list", itemlistresp)
|
||||
ai.Store("items.list", itemlistresp)
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
return nil
|
||||
}
|
||||
|
13
busi/shop.go
13
busi/shop.go
@ -25,7 +25,7 @@ func (f *ShopScene) Info() lib.SceneInfo {
|
||||
func (f *ShopScene) Run(ai lib.IRobot) (err error) {
|
||||
var (
|
||||
code pb.ErrorCode
|
||||
shops *pb.ShopGetListResp
|
||||
shops *pb.ShopGetListResp = &pb.ShopGetListResp{}
|
||||
)
|
||||
if code = ai.SendMsg("gm", "cmd", &pb.GMCmdReq{
|
||||
Cmod: "bingo:attr,gold,100000",
|
||||
@ -42,11 +42,12 @@ func (f *ShopScene) Run(ai lib.IRobot) (err error) {
|
||||
}
|
||||
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)
|
||||
ai.SendMsg("shop", "buy", &pb.ShopBuyReq{
|
||||
ShopType: pb.ShopType_GoldShop,
|
||||
GoodsId: v.GoodsId,
|
||||
BuyNum: 1,
|
||||
}, &pb.ShopBuyResp{})
|
||||
Sleep(time.Second*0, time.Second*1)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
90
lib/robot.go
90
lib/robot.go
@ -207,7 +207,8 @@ func (m *Robot) Start() bool {
|
||||
|
||||
//设置状态为已启动
|
||||
atomic.StoreUint32(&m.status, STATUS_STARTED)
|
||||
|
||||
//显示场景结果
|
||||
go m.processResult()
|
||||
m.syncCall()
|
||||
|
||||
return true
|
||||
@ -238,8 +239,6 @@ func (m *Robot) syncCall() {
|
||||
|
||||
m.elipseTotal += elapsedTime
|
||||
logrus.WithField("t", elapsedTime.String()).Debug("场景【" + info.Name + "】执行完毕耗时统计")
|
||||
//显示场景结果
|
||||
m.processResult()
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,49 +265,31 @@ func (m *Robot) SendResult(result *CallResult) bool {
|
||||
}
|
||||
|
||||
func (m *Robot) processResult() {
|
||||
go func() {
|
||||
defer m.lock.Unlock()
|
||||
m.lock.Lock()
|
||||
for r := range m.resultCh {
|
||||
head := fmt.Sprintf("%s.%s", r.MainType, r.SubType)
|
||||
if routes, ok := m.ReportMap[r.Num]; ok {
|
||||
if route, y := routes[head]; y {
|
||||
max := route.MaxElapse
|
||||
min := route.MinElapse
|
||||
if r.Elapse > max {
|
||||
max = r.Elapse
|
||||
}
|
||||
|
||||
if r.Elapse < min {
|
||||
min = r.Elapse
|
||||
}
|
||||
statis := &Statistics{
|
||||
Route: head,
|
||||
SceneName: r.SceneName,
|
||||
ElapseTotal: route.ElapseTotal + r.Elapse,
|
||||
MaxElapse: max,
|
||||
MinElapse: min,
|
||||
CallCount: route.CallCount + 1,
|
||||
}
|
||||
avg := (statis.MaxElapse + statis.MinElapse) / 2
|
||||
statis.AvgElapse = avg
|
||||
routes[head] = statis
|
||||
} else {
|
||||
statis := &Statistics{
|
||||
Route: head,
|
||||
SceneName: r.SceneName,
|
||||
ElapseTotal: r.Elapse,
|
||||
MaxElapse: r.Elapse,
|
||||
MinElapse: r.Elapse,
|
||||
CallCount: 1,
|
||||
}
|
||||
avg := (statis.MaxElapse + statis.MinElapse) / 2
|
||||
statis.AvgElapse = avg
|
||||
routes[head] = statis
|
||||
for r := range m.resultCh {
|
||||
head := fmt.Sprintf("%s.%s", r.MainType, r.SubType)
|
||||
if routes, ok := m.ReportMap[r.Num]; ok {
|
||||
if route, y := routes[head]; y {
|
||||
max := route.MaxElapse
|
||||
min := route.MinElapse
|
||||
if r.Elapse > max {
|
||||
max = r.Elapse
|
||||
}
|
||||
m.ReportMap[r.Num] = routes
|
||||
|
||||
if r.Elapse < min {
|
||||
min = r.Elapse
|
||||
}
|
||||
statis := &Statistics{
|
||||
Route: head,
|
||||
SceneName: r.SceneName,
|
||||
ElapseTotal: route.ElapseTotal + r.Elapse,
|
||||
MaxElapse: max,
|
||||
MinElapse: min,
|
||||
CallCount: route.CallCount + 1,
|
||||
}
|
||||
avg := (statis.MaxElapse + statis.MinElapse) / 2
|
||||
statis.AvgElapse = avg
|
||||
routes[head] = statis
|
||||
} else {
|
||||
route := make(map[string]*Statistics)
|
||||
statis := &Statistics{
|
||||
Route: head,
|
||||
SceneName: r.SceneName,
|
||||
@ -319,12 +300,25 @@ func (m *Robot) processResult() {
|
||||
}
|
||||
avg := (statis.MaxElapse + statis.MinElapse) / 2
|
||||
statis.AvgElapse = avg
|
||||
route[head] = statis
|
||||
m.ReportMap[r.Num] = route
|
||||
routes[head] = statis
|
||||
}
|
||||
m.ReportMap[r.Num] = routes
|
||||
} else {
|
||||
route := make(map[string]*Statistics)
|
||||
statis := &Statistics{
|
||||
Route: head,
|
||||
SceneName: r.SceneName,
|
||||
ElapseTotal: r.Elapse,
|
||||
MaxElapse: r.Elapse,
|
||||
MinElapse: r.Elapse,
|
||||
CallCount: 1,
|
||||
}
|
||||
avg := (statis.MaxElapse + statis.MinElapse) / 2
|
||||
statis.AvgElapse = avg
|
||||
route[head] = statis
|
||||
m.ReportMap[r.Num] = route
|
||||
}
|
||||
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
// 将统计结果写入文件
|
||||
|
Loading…
Reference in New Issue
Block a user