diff --git a/app.go b/app.go index 2213496..babc388 100644 --- a/app.go +++ b/app.go @@ -378,14 +378,12 @@ func calcUserGameScore(summonerID int64, gameSummary lcu.GameSummary) (*lcu.Scor userKillRateLoop: for _, killRateConfItem := range calcScoreConf.KillRate { if userKillRate > killRateConfItem.Limit { - killRateConfItemLoop: for _, limitConf := range killRateConfItem.ScoreConf { if userParticipant.Stats.Kills > int(limitConf[0]) { gameScore.Add(limitConf[1], lcu.ScoreOptionKillRate) - break killRateConfItemLoop + break userKillRateLoop } } - break userKillRateLoop } } } @@ -396,14 +394,12 @@ func calcUserGameScore(summonerID int64, gameSummary lcu.GameSummary) (*lcu.Scor userHurtRateLoop: for _, killRateConfItem := range calcScoreConf.HurtRate { if userHurtRate > killRateConfItem.Limit { - hurtRateConfItemLoop: for _, limitConf := range killRateConfItem.ScoreConf { if userParticipant.Stats.Kills > int(limitConf[0]) { gameScore.Add(limitConf[1], lcu.ScoreOptionHurtRate) - break hurtRateConfItemLoop + break userHurtRateLoop } } - break userHurtRateLoop } } } @@ -414,14 +410,12 @@ func calcUserGameScore(summonerID int64, gameSummary lcu.GameSummary) (*lcu.Scor userAssistRateLoop: for _, killRateConfItem := range calcScoreConf.AssistRate { if userAssistRate > killRateConfItem.Limit { - assistRateConfItemLoop: for _, limitConf := range killRateConfItem.ScoreConf { if userParticipant.Stats.Kills > int(limitConf[0]) { gameScore.Add(limitConf[1], lcu.ScoreOptionAssistRate) - break assistRateConfItemLoop + break userAssistRateLoop } } - break userAssistRateLoop } } } diff --git a/bootstrap/init.go b/bootstrap/init.go index 979f5e1..a317a1e 100644 --- a/bootstrap/init.go +++ b/bootstrap/init.go @@ -126,11 +126,11 @@ func initGlobal() { func initAutoReloadCalcConf() { ticker := time.NewTicker(time.Minute) for { - <-ticker.C latestScoreConf, err := buffApi.GetCurrConf() if err == nil && latestScoreConf != nil && latestScoreConf.Enabled { global.SetScoreConf(*latestScoreConf) } + <-ticker.C } } diff --git a/conf/appConf.go b/conf/appConf.go index a73c041..234aeea 100644 --- a/conf/appConf.go +++ b/conf/appConf.go @@ -63,5 +63,6 @@ type ( AssistRate []RateItemConf `json:"assistRate" required:"true"` // 助攻占比 AdjustKDA [2]float64 `json:"adjustKDA" required:"true"` // kda Horse [6]HorseScoreConf `json:"horse" required:"true"` + MergeMsg bool `json:"mergeMsg"` // 是否合并消息为一条 } ) diff --git a/global/global.go b/global/global.go index 0b5d627..e7da29a 100644 --- a/global/global.go +++ b/global/global.go @@ -126,6 +126,7 @@ var ( {Score: 95, Name: "下等马"}, {Score: 0.0001, Name: "牛马"}, }, + MergeMsg: false, }, } userInfo = UserInfo{} diff --git a/prophet.go b/prophet.go index 75a85a6..558de42 100644 --- a/prophet.go +++ b/prophet.go @@ -218,7 +218,7 @@ func (p *Prophet) initGameFlowMonitor(port int, authPwd string) error { } p.lcuActive = true // if global.IsDevMode() { - // lcu.ChampionSelectStart() + // p.ChampionSelectStart() // } _ = c.WriteMessage(websocket.TextMessage, []byte("[5, \"OnJsonApiEvent\"]")) @@ -390,9 +390,12 @@ func (p Prophet) ChampionSelectStart() { scoreCfg := global.GetScoreConf() allMsg := "" + mergedMsg := "" // 发送到选人界面 for _, scoreInfo := range summonerIDMapScore { - time.Sleep(time.Second / 2) + if !scoreCfg.MergeMsg { + time.Sleep(time.Second / 2) + } var horse string horseIdx := 0 for i, v := range scoreCfg.Horse { @@ -414,12 +417,16 @@ func (p Prophet) ChampionSelectStart() { msg := fmt.Sprintf("%s(%d): %s %s -- %s", horse, int(scoreInfo.Score), scoreInfo.SummonerName, currKDAMsg, global.AdaptChatWebsiteTitle) <-sendConversationMsgDelayCtx.Done() + if clientCfg.AutoSendTeamHorse { + mergedMsg += msg + "\n" + } if !clientCfg.AutoSendTeamHorse { - if !clientCfg.ShouldSendSelfHorse && p.currSummoner != nil && + if !scoreCfg.MergeMsg && !clientCfg.ShouldSendSelfHorse && p.currSummoner != nil && scoreInfo.SummonerID == p.currSummoner.SummonerId { continue } allMsg += msg + "\n" + mergedMsg += msg + "\n" continue } if !clientCfg.ShouldSendSelfHorse && p.currSummoner != nil && @@ -429,11 +436,18 @@ func (p Prophet) ChampionSelectStart() { if !clientCfg.ChooseSendHorseMsg[horseIdx] { continue } + if scoreCfg.MergeMsg { + continue + } _ = SendConversationMsg(msg, conversationID) } if !clientCfg.AutoSendTeamHorse { log.Println("已将队伍马匹信息复制到剪切板") _ = clipboard.WriteAll(allMsg) + return + } + if scoreCfg.MergeMsg { + _ = SendConversationMsg(mergedMsg, conversationID) } } func (p Prophet) AcceptGame() { @@ -455,8 +469,12 @@ func (p Prophet) CalcEnemyTeamScore() { selfTeamUsers, enemyTeamUsers := getAllUsersFromSession(selfID, session) _ = selfTeamUsers summonerIDList := enemyTeamUsers + // if !false && global.IsDevMode() { + // summonerIDList = []int64{2964390005, 4103784618, 4132401993, 4118593599, 4019221688} + // // summonerIDList = []int64{4006944917} + // } logger.Debug("敌方队伍人员列表:", zap.Any("summonerIDList", summonerIDList)) - if len(enemyTeamUsers) == 0 { + if len(summonerIDList) == 0 { return } // 查询所有用户的信息并计算得分 diff --git a/version.go b/version.go index d506b81..dcb1425 100644 --- a/version.go +++ b/version.go @@ -3,7 +3,7 @@ package hh_lol_prophet import "github.com/real-web-world/hh-lol-prophet/global" var ( - APPVersion = "0.1.1" + APPVersion = "0.2.0" Commit = "dev" BuildTime = "" BuildUser = ""