package main import ( "f1-game/internal/pb" "f1-game/tool/client-cli/cli" "fmt" "math/rand" "sync" "testing" "time" cherryTime "github.com/cherry-game/cherry/extend/time" clog "github.com/cherry-game/cherry/logger" ) func TestLcs_Local_10000_League(t *testing.T) { var ( loginURL = "http://dev.f1.chun-pu.com" gateAddr = "127.0.0.1:30001" serverId = "5" pid = "2188005" maxAccountNum = 1000 testAccounts = make(map[string]string) ) for i := 1; i <= maxAccountNum; i++ { key := fmt.Sprintf("lcs%d", i) testAccounts[key] = key cli.RegisterDevAccount(loginURL, key, key) } now := cherryTime.Now() wg := &sync.WaitGroup{} for userName, password := range testAccounts { wg.Add(1) go func(userName, password string) { robot := cli.EnterServer(loginURL, pid, userName, password, gateAddr, serverId, true) if robot != nil { time.Sleep(time.Duration(rand.Int31n(100)) * time.Millisecond) robot.MapLogin() time.Sleep(time.Duration(rand.Int31n(100)) * time.Millisecond) } else { clog.Warnf("Failed to enter game robot for user %s", userName) } wg.Done() }(userName, password) } wg.Wait() clog.Infof("elapsedTime = %dms", now.NowDiffMillisecond()) } func testLcsSetup() *cli.Robot { var ( loginURL = "http://dev.f1.chun-pu.com" //loginURL = "http://192.168.1.232:18080" gateAddr = "127.0.0.1:30001" //gateAddr = "192.168.1.232:30001" serverId = "5" account = "l10" password = "123456" pid = "2188005" ) cli.RegisterDevAccount(loginURL, account, password) robot := cli.EnterServer(loginURL, pid, account, password, gateAddr, serverId, true) robot.MapLogin() return robot } func TestRankList(t *testing.T) { robot := testLcsSetup() // 获取排行榜 robot.MapPlayerRankList(101) time.Sleep(500 * time.Millisecond) //robot.MapPlayerRankList(102) //time.Sleep(500 * time.Millisecond) //robot.MapLeagueRankList(201) // 获取地图城池被攻占列表 robot.MapOccupyCastleList() select {} } func TestSignIn(t *testing.T) { robot := testLcsSetup() // 签到 robot.SignIn() time.Sleep(500 * time.Millisecond) // 补签 robot.ReSignIn(1) time.Sleep(500 * time.Millisecond) // 领取累签奖励 robot.SignInReward(101) time.Sleep(500 * time.Millisecond) select {} } func TestLcsBuild(t *testing.T) { robot := testLcsSetup() // 建筑建设 //robot.MapLeagueBuild(201007, 927, 347) robot.MapLeagueBuildUpgrade(107573) //robot.MapLeagueBuildUpgrade(107576) //robot.BuildSet(1000, 1000, 1000, 1000, 1000, 1000) select {} } func TestOutsideConscript(t *testing.T) { robot := testLcsSetup() teamID := int32(1) // 设置城外自动征兵 // robot.TeamOutsideAutoTroopsSet(teamID) // time.Sleep(500 * time.Millisecond) // 城外征兵 troopNums := []*pb.I32I32{} troopNums = append(troopNums, &pb.I32I32{Key: 1, Value: 1000}) troopNums = append(troopNums, &pb.I32I32{Key: 3, Value: 500}) robot.TeamOutsideTroops(teamID, troopNums) time.Sleep(500 * time.Millisecond) // 取消城外征兵 // teamIndexs := []int32{} // teamIndexs = append(teamIndexs, 1) // //teamIndexs = append(teamIndexs, 2) // teamIndexs = append(teamIndexs, 3) // robot.TeamOutsideTroopsCancel(teamID, teamIndexs) select {} } func TestLordInfo(t *testing.T) { robot := testLcsSetup() // 查看领主个人信息 robot.LordInfo(1051321) // 改名 //robot.LordChangeName("测试名字") // 更换头像框 更换失败 //robot.LordChangeFrame(201) // 头像框激活 //robot.LordShowActive(201) // 主页背景激活 有时效 //robot.LordShowActive(304) // 更换头像 //robot.LordChangeIcon(102) // 查看头像 //robot.LordShowView(101) // 编辑个人简介 //robot.LordChangeDesc("测试个人简介") // 语言选择 //robot.LordLangSelect("th") // 展示数据设置 // showDataList := []*pb.LordShowData{ // {ShowType: 7, IsShow: true}, // {ShowType: 1, IsShow: true}, // {ShowType: 5, IsShow: true}, // {ShowType: 2, IsShow: true}, // {ShowType: 6, IsShow: true}, // {ShowType: 3, IsShow: true}, // {ShowType: 4, IsShow: false}, // } // robot.LordShowDataSet(showDataList) select {} } func TestMapMark(t *testing.T) { robot := testLcsSetup() //robot.MapPlayerMapMark("", 1, 10) //time.Sleep(500 * time.Millisecond) //robot.MapPlayerMapMark("测试", 10, 10) //time.Sleep(500 * time.Millisecond) // 地图标记删除 //robot.MapPlayerMapMarkDelete(10002) //time.Sleep(500 * time.Millisecond) // 联盟标记 //robot.LeagueMapMark("测试", "测试指挥邮件", 10, 10, 1) //time.Sleep(500 * time.Millisecond) // 联盟地图标记编辑 //robot.LeagueMapMarkEdit(10011, "兄弟们", "往前冲啊", 2) //time.Sleep(500 * time.Millisecond) // 联盟地图标记删除 robot.LeagueMapMarkDelete(10011) time.Sleep(500 * time.Millisecond) select {} } func TestShop(t *testing.T) { robot := testLcsSetup() goodsList := []*pb.I32I32{} goodsList = append(goodsList, &pb.I32I32{Key: 1, Value: 1}) goodsList = append(goodsList, &pb.I32I32{Key: 1, Value: 1}) // 购买商店 //robot.ShopBuy(105, goodsList) //time.Sleep(500 * time.Millisecond) // 购买超出上限 //robot.ShopBuy(101, 1, 10) //time.Sleep(500 * time.Millisecond) // 购买其他商店 //robot.ShopBuy(102, 1, 1) //time.Sleep(500 * time.Millisecond) // 地图商店购买 robot.MapShopBuy(105, goodsList) select {} } func TestMedicineUse(t *testing.T) { robot := testLcsSetup() // 使用体力药 robot.TeamMedicineUse(1, 120001) time.Sleep(500 * time.Millisecond) // 使用补兵药 robot.TeamMedicineUse(1, 120002) time.Sleep(500 * time.Millisecond) // 使用重伤药 robot.TeamMedicineUse(1, 120003) time.Sleep(500 * time.Millisecond) select {} } // 领取任务奖励 func TestQuestReward(t *testing.T) { robot := testLcsSetup() //robot.QuestGetReward(21001001) //time.Sleep(1 * time.Second) // robot.QuestGetReward(21004002) // time.Sleep(1 * time.Second) // robot.QuestGetReward(21004003) // time.Sleep(1 * time.Second) // robot.QuestGetReward(21004004) // time.Sleep(1 * time.Second) // robot.QuestGetReward(21004005) // 领取主线章节奖励 robot.QuestChapterReward(10101) select {} } // 一键阅读联盟邮件 func TestLeagueMailFastRead(t *testing.T) { robot := testLcsSetup() // 读取法令邮件 robot.LeagueMailFastRead(1) select {} } // 阅读联盟邮件 func TestLeagueMailRead(t *testing.T) { robot := testLcsSetup() // 读取法令邮件 robot.LeagueMailRead(1, 1) select {} } // 联盟发送邮件 func TestLeagueSendMail(t *testing.T) { robot := testLcsSetup() // 发送法令邮件 上限10封 最后一封会失败 BatchLeagueSendMail(robot, "法令", 1, 11) // 更新法令邮件 //robot.LeagueSendMail(0, 1, title, content, false) //发送同盟邮件 检测删除旧的同盟邮件 暂时设置最多4封 理论上最开始那封会被删除掉 BatchLeagueSendMail(robot, "同盟", 2, 5) // 发送指挥邮件 也是暂时最多4封 理论上最开始那封会被删除掉 BatchLeagueSendMail(robot, "指挥", 3, 5) select {} } // 批量发送联盟邮件 func BatchLeagueSendMail(robot *cli.Robot, mailName string, mailType int32, count int) { for i := 0; i < count; i++ { title := fmt.Sprintf("%v测试邮件%d", mailName, i) content := fmt.Sprintf("%v邮件%d", mailName, i) robot.LeagueMailSend(0, mailType, title, content, false) time.Sleep(500 * time.Microsecond) } } // 删除联盟邮件 func TestLeagueDeleteMail(t *testing.T) { robot := testLcsSetup() // 删除法令邮件邮件 robot.LeagueMailDel(7, 1) time.Sleep(500 * time.Microsecond) // 删除同盟邮件邮件 robot.LeagueMailDel(15, 2) time.Sleep(500 * time.Microsecond) // 删除指挥邮件邮件 robot.LeagueMailDel(19, 3) time.Sleep(500 * time.Microsecond) select {} } // 置顶联盟邮件 func TestLeagueTopMail(t *testing.T) { robot := testLcsSetup() // 置顶法令邮件 robot.LeagueMailTop(1, 1) time.Sleep(500 * time.Microsecond) // 取消置顶法令邮件 //robot.LeagueTopMail(1, 1) // 置顶同盟邮件 理论上是不行的 robot.LeagueMailTop(11, 2) select {} } func TestLcsMain(t *testing.T) { robot := testLcsSetup() //领取邮件奖励 robot.TakeMailReward(1) // 一键阅读/领取邮件奖励 robot.TakeAllMailReward() select {} } func TestMailRead(t *testing.T) { robot := testLcsSetup() //读取指定邮件 robot.MailRead(2) select {} } func TestDelete(t *testing.T) { robot := testLcsSetup() //删除指定邮件 robot.MailDelete(1) //删除所有邮件 robot.MailDelete(0) select {} } // 招募 func TestRecruit(t *testing.T) { robot := testLcsSetup() //招募池子1 5次 robot.Recruit(1, 5) select {} } // 英雄升星 func TestHeroStarUp(t *testing.T) { robot := testLcsSetup() robot.HeroStar(1050199) } // 英雄技能升级 func TestHeroSkillLevelUp(t *testing.T) { robot := testLcsSetup() //英雄 1048578 升级天赋技能2 //robot.HeroSkillUp(1048578, 3999901) //英雄1 升级主动技能3 robot.HeroSkillUp(1048707, 10103) //英雄 1 升级被动技能4 //robot.HeroSkillUp(1048578, 3999903) select {} } // 道具合成 func TestItemCraft(t *testing.T) { robot := testLcsSetup() req := &pb.I32I32List{} req.List = append(req.List, &pb.I32I32{ Key: 103011, Value: 1, }) req.List = append(req.List, &pb.I32I32{ Key: 103014, Value: 1, }) // 合成矿石 robot.ItemCraft(req) select {} } func TestLeague(t *testing.T) { robot := testLcsSetup() // 查看联盟列表 //robot.GetLeagueInfo(1876) // 更改联盟名称 //robot.LeagueNameChange("不知道") // 更改联盟简称 //robot.LeagueAbbNameChange("不知道") // 设置联盟申请需要审核 //robot.LeagueJoinApprovalSet() // 加入联盟 //robot.JoinLeague(1882) // 获取申请列表 //robot.LeagueApplyList() // 通过申请 //robot.LeagueApplyOption(1048591, true) // 清除申请列表 //robot.LeagueClearApplyList() // 设置联盟加入所需主城等级 //robot.LeagueJoinLevelSet(50) // 设置联盟公告 //robot.LeagueNoticeSet("不知道") // 设置联盟旗帜 robot.LeagueFlagSet(102, 202) select {} } // 创建联盟 func TestCreateLeague(t *testing.T) { robot := testLcsSetup() //robot.CreateLeague("", "我不知道.423d") //robot.CreateLeague("我不知道.423d", "") //robot.CreateLeague("哈哈哈哈哈哈哈哈哈哈哈", "不知道") robot.CreateLeague("硅基1", "konw1", 101, 201) //创建相同联盟名称/联盟简称 //robot.CreateLeague("硅基", "konw1") //robot.CreateLeague("硅基1", "konw") select {} } // 加入联盟 func TestJoinLeague(t *testing.T) { robot := testLcsSetup() //加入不存在联盟 //robot.JoinLeague(1887) //加入联盟 robot.JoinLeague(1876) select {} //检测重复加入 //robot.JoinLeague(1886) } // 获取联盟成员列表 func TestGetLeagueMembers(t *testing.T) { robot := testLcsSetup() //未加入/加入联盟联盟测试 robot.GetLeagueMembers() select {} } // 获取推荐联盟列表 func TestLeagueList(t *testing.T) { robot := testLcsSetup() //查看联盟列表 robot.GetLeagueList() select {} } // 查询联盟列表 func TestSearchLeague(t *testing.T) { robot := testLcsSetup() //获取联盟列表 robot.SearchLeague("硅") //通过联盟id获取联盟列表 //robot.SearchLeague("1886") //搜索不存在联盟名称 //robot.SearchLeague("硅基1") //robot.SearchLeague("1895") select {} } // 入会申请处理 func TestLeagueApplyOption(t *testing.T) { robot := testLcsSetup() // 拒绝入会申请 //robot.LeagueApplyOption(1048587, false) // 同意入会申请 robot.LeagueApplyOption(1048594, true) select {} } // 离开联盟 func TestLeagueQuit(t *testing.T) { robot := testLcsSetup() robot.LeagueQuit() select {} } // 踢出联盟 func TestKickLeague(t *testing.T) { robot := testLcsSetup() // 踢自己出联盟 //robot.KickLeague(1048594) // 踢出存在联盟成员 robot.KickLeague(1048609) select {} } // 英雄上阵 // func TestTeamUp(t *testing.T) { robot := testLcsSetup() // 上阵队伍位置下表错误 //robot.TeamUp(1050058, 1, 0) //robot.TeamUp(1050058, 1, 10) // 上阵队伍正确 robot.TeamUp(1048876, 1, 1, 1) time.Sleep(500 * time.Microsecond) robot.TeamUp(1048889, 1, 2, 3) time.Sleep(500 * time.Microsecond) robot.TeamUp(1048898, 1, 3, 5) time.Sleep(500 * time.Microsecond) // 同英雄上阵同一位置 //robot.TeamUp(1050058, 1, 1) // 不同英雄上阵存在的位置 //robot.TeamUp(1050060, 1, 1) // //上阵相同英雄到不同位置 //robot.TeamUp(1050059, 1, 2) // 上阵满英雄 // robot.TeamUp(1050078, 1, 6) // robot.TeamUp(1050068, 1, 3) // robot.TeamUp(1050069, 1, 4) // robot.TeamUp(1050062, 1, 5) select {} } // 英雄下阵 func TestTeamLeave(t *testing.T) { robot := testLcsSetup() // 下阵队伍错误 robot.TeamLeave(0, 0) // 下阵位置错误 robot.TeamLeave(1, 0) // 下阵正确 robot.TeamLeave(1, 1) robot.TeamLeave(1, 3) select {} } // 英雄换阵 func TestTeamChange(t *testing.T) { robot := testLcsSetup() // 换阵队伍&位置不变 robot.TeamChange(1, 1, 1, 1, 1) // 换阵错误 robot.TeamChange(1, 1, 0, 1, 1) robot.TeamChange(1, 1, 0, 0, 1) // 换阵正确 // 同队伍换位置 robot.TeamChange(1, 2, 1, 3, 6) robot.TeamChange(1, 3, 1, 4, 4) // 不同队伍换位置 robot.TeamChange(1, 4, 1, 3, 3) select {} } // 同队伍英雄换阵 func TestTeamInnerChange(t *testing.T) { robot := testLcsSetup() // 换阵队伍&位置不变 robot.TeamInnerChange(1, 1, 1) time.Sleep(500 * time.Millisecond) // 换阵错误 robot.TeamInnerChange(1, 1, 0) time.Sleep(500 * time.Millisecond) robot.TeamInnerChange(1, 1, 4) time.Sleep(500 * time.Millisecond) // 换阵正确 // 同队伍换位置 robot.TeamInnerChange(1, 2, 1) time.Sleep(500 * time.Millisecond) robot.TeamInnerChange(1, 3, 1) time.Sleep(500 * time.Millisecond) select {} } // 阵容设置 func TestTeamLineup(t *testing.T) { robot := testLcsSetup() // 阵容位置错误 robot.TeamLineup(1, 0, 1) robot.TeamLineup(1, 1, 0) robot.TeamLineup(1, 1, 1) // 切换到无人的位置 robot.TeamLineup(1, 1, 2) // 切换到有人的位置 互换 robot.TeamLineup(1, 3, 2) // 切换到无人的位置上 robot.TeamLineup(1, 3, 7) select {} } // 队伍补兵 func TestTeamTroops(t *testing.T) { robot := testLcsSetup() // 补单个英雄 memberTroops := []*pb.TeamMemberTroops{} memberTroops = append(memberTroops, &pb.TeamMemberTroops{TeamIndex: 1, TroopsID: 201, TroopsNum: 100}) robot.TeamTroops(1, memberTroops) // 再次补兵 超出上限 //robot.TeamTroops(1, 201, memberTroops) // 补多个英雄(附带超出队伍上限) // memberTroops = append(memberTroops, &pb.I32I32{Key: 1, Value: -410}) // memberTroops = append(memberTroops, &pb.I32I32{Key: 2, Value: 410}) // memberTroops = append(memberTroops, &pb.I32I32{Key: 3, Value: 100}) // memberTroops = append(memberTroops, &pb.I32I32{Key: 4, Value: 300}) // memberTroops = append(memberTroops, &pb.I32I32{Key: 5, Value: 2000}) // memberTroops = append(memberTroops, &pb.I32I32{Key: 6, Value: 1000}) // robot.TeamTroops(1, 201, memberTroops) // // //补充不存在的队伍 // robot.TeamTroops(8, 201, memberTroops) select {} } func TestTeamAutoTroops(t *testing.T) { robot := testLcsSetup() // 自动补兵 未解锁的队伍 //robot.TeamAutoTroops(5) // 正常补兵队伍设置自动补兵 重复 robot.TeamAutoTroops(1) time.Sleep(500 * time.Millisecond) // 正常取消自动补兵 //robot.TeamAutoTroops(1) select {} } // 队伍成员体力恢复 func TestTeamEnergyRecovery(t *testing.T) { robot := testLcsSetup() // 队伍体力恢复 robot.TeamEnergyRecovery(1) time.Sleep(500 * time.Millisecond) select {} } // 兵营-征兵 func TestConscript(t *testing.T) { robot := testLcsSetup() // 征兵 //robot.ConscriptBegin(201, 1000) //time.Sleep(500 * time.Millisecond) // 士兵升级 //robot.ConscriptUp(201, 202, 200) //time.Sleep(500 * time.Millisecond) // 取消征兵 //robot.ConscriptCancel() //time.Sleep(500 * time.Millisecond) // 取消士兵升级 //robot.ConscriptUpCancel() //time.Sleep(500 * time.Millisecond) // 士兵升级 //robot.ConscriptUp(202, 100, 203) //time.Sleep(500 * time.Millisecond) // 取消士兵升级 //robot.ConscriptUpCancel() //time.Sleep(500 * time.Millisecond) // 设置自动征兵 robot.ConscriptAuto(202) time.Sleep(500 * time.Millisecond) //robot.ConscriptAuto(0) //time.Sleep(500 * time.Millisecond) select {} } // 阵容英雄上阵 func TestLineupUp(t *testing.T) { robot := testLcsSetup() robot.LineupUp(1, 1048977, 1, 1) time.Sleep(500 * time.Millisecond) robot.LineupUp(1, 1048975, 1, 2) time.Sleep(500 * time.Millisecond) robot.LineupUp(1, 1048983, 1, 1) time.Sleep(500 * time.Millisecond) robot.LineupUp(1, 1048975, 2, 2) time.Sleep(500 * time.Millisecond) robot.LineupUp(1, 1048983, 2, 2) time.Sleep(500 * time.Millisecond) robot.LineupUp(1, 1048983, 2, 2) select {} } // 阵容英雄下阵 func TestLineupLeave(t *testing.T) { robot := testLcsSetup() robot.LineupLeave(1, 1, 1) time.Sleep(500 * time.Millisecond) robot.LineupLeave(1, 1, 2) time.Sleep(500 * time.Millisecond) robot.LineupLeave(1, 2, 2) select {} } // 阵容换阵 func TestLineupChange(t *testing.T) { robot := testLcsSetup() robot.LineupChange(1, 1, 5, 1, 5) time.Sleep(500 * time.Millisecond) robot.LineupChange(1, 1, 5, 1, 2) time.Sleep(500 * time.Millisecond) robot.LineupChange(1, 1, 2, 2, 2) select {} } // 阵容调整 func TestLineupAdjust(t *testing.T) { robot := testLcsSetup() robot.LineupAdjust(1, 1, 1, 1) time.Sleep(500 * time.Millisecond) robot.LineupAdjust(1, 1, 1, 10) time.Sleep(500 * time.Millisecond) robot.LineupAdjust(1, 1, 1, 5) select {} } // 探险 func TestChapter(t *testing.T) { robot := testLcsSetup() // 获取最近一次精力恢复时间戳 单位秒 //robot.ChapterLastRecoverTime() //time.Sleep(500 * time.Millisecond) // 取出精力 robot.ChapterTaskOutStamina(100) time.Sleep(500 * time.Millisecond) select {} } // 探险扫荡 func TestChapterLevelSweep(t *testing.T) { robot := testLcsSetup() // 扫荡一次 robot.ChapterLevelSweep(101, 1) time.Sleep(500 * time.Millisecond) // 扫荡次数超出上限 robot.ChapterLevelSweep(101, 3) time.Sleep(500 * time.Millisecond) // 未解锁关卡 robot.ChapterLevelSweep(102, 1) time.Sleep(500 * time.Millisecond) select {} } // 章节累计星级奖励领取 func TestChapterStarReward(t *testing.T) { robot := testLcsSetup() // 领取累计6星奖励 robot.ChapterStarReward(101, 6) time.Sleep(500 * time.Millisecond) // 领取奖励不够的奖励 robot.ChapterStarReward(101, 12) time.Sleep(500 * time.Millisecond) // 领取不存在的星级奖励 robot.ChapterStarReward(101, 1) time.Sleep(500 * time.Millisecond) // 领取未解锁章节奖励 robot.ChapterStarReward(102, 6) time.Sleep(500 * time.Millisecond) select {} } // 探险次数购买 func TestChapterTimesBuy(t *testing.T) { robot := testLcsSetup() // 购买一次 robot.ChapterTimesBuy(101, 1) time.Sleep(500 * time.Millisecond) // 购买次数超出上限 robot.ChapterTimesBuy(101, 3) time.Sleep(500 * time.Millisecond) // 未解锁关卡 robot.ChapterTimesBuy(102, 1) time.Sleep(500 * time.Millisecond) select {} }