[FIX]王者荣耀队员信息错误,经济差、经验差重复问题
This commit is contained in:
parent
6264449c55
commit
a82f17f11a
|
@ -7,7 +7,7 @@ import (
|
||||||
"gitee.com/risewinter/sheep/modules/series"
|
"gitee.com/risewinter/sheep/modules/series"
|
||||||
"gitee.com/risewinter/sheep/modules/team"
|
"gitee.com/risewinter/sheep/modules/team"
|
||||||
"gitee.com/risewinter/sheep/util"
|
"gitee.com/risewinter/sheep/util"
|
||||||
"github.com/montanaflynn/stats"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Match struct {
|
type Match struct {
|
||||||
|
@ -148,51 +148,6 @@ func (match *Match) BuildMatch(buildMatch aov.Match) (BuilderMatch aov.Match, bu
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(match.Stats.Xp) != 10 {
|
|
||||||
buildErr = errors.New("比赛统计信息经验值数组异常!")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if len(match.Stats.PosX) != 10 {
|
|
||||||
buildErr = errors.New("比赛统计信息玩家x坐标数组异常!")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if len(match.Stats.PosY) != 10 {
|
|
||||||
buildErr = errors.New("比赛统计信息玩家y坐标数组异常!")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if len(match.Stats.Kills) != 10 {
|
|
||||||
buildErr = errors.New("比赛统计信息玩家击杀数数组异常!")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if len(match.Stats.Deaths) != 10 {
|
|
||||||
buildErr = errors.New("比赛统计信息玩家死亡数数组异常!")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if len(match.Stats.Assists) != 10 {
|
|
||||||
buildErr = errors.New("比赛统计信息玩家助攻数数组异常!")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if len(match.Stats.Networth) != 10 {
|
|
||||||
buildErr = errors.New("比赛统计信息玩家总经济数组异常!")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if len(match.Stats.PlayerName) != 10 {
|
|
||||||
buildErr = errors.New("比赛统计信息玩家名字数组异常!")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if len(match.Stats.Players) != 10 {
|
|
||||||
buildErr = errors.New("比赛统计信息玩家信息数组异常!")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if len(match.Stats.RespawnTime) != 10 {
|
|
||||||
buildErr = errors.New("比赛统计信息玩家复活倒计时数组异常!")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if len(match.Stats.Items) != 10 {
|
|
||||||
buildErr = errors.New("比赛统计信息玩家装备数组异常!")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 匹配a队为左队或者右队,填充team和player
|
// 匹配a队为左队或者右队,填充team和player
|
||||||
if match.TeamA.RwID > 0 {
|
if match.TeamA.RwID > 0 {
|
||||||
if mTeam, err := team.FindTeamByRwID(match.TeamA.RwID); err != nil {
|
if mTeam, err := team.FindTeamByRwID(match.TeamA.RwID); err != nil {
|
||||||
|
@ -201,70 +156,20 @@ func (match *Match) BuildMatch(buildMatch aov.Match) (BuilderMatch aov.Match, bu
|
||||||
} else {
|
} else {
|
||||||
if match.TeamA.Colour == "red" {
|
if match.TeamA.Colour == "red" {
|
||||||
buildMatch.RightTeamID = mTeam.ID
|
buildMatch.RightTeamID = mTeam.ID
|
||||||
var teamPlayers []aov.Player
|
|
||||||
for i := 0; i < 5; i++ {
|
|
||||||
teamPlayers = append(teamPlayers, aov.Player{
|
|
||||||
RwID: match.Stats.Players[i].RwID,
|
|
||||||
Name: match.Stats.Players[i].Name,
|
|
||||||
PlayerName: match.Stats.PlayerName[i],
|
|
||||||
Xp: match.Stats.Xp[i],
|
|
||||||
PosX: match.Stats.PosX[i],
|
|
||||||
PosY: match.Stats.PosY[i],
|
|
||||||
Kills: match.Stats.Kills[i],
|
|
||||||
Deaths: match.Stats.Deaths[i],
|
|
||||||
Assists: match.Stats.Assists[i],
|
|
||||||
Gold: match.Stats.Networth[i],
|
|
||||||
RespawnTime: match.Stats.RespawnTime[i],
|
|
||||||
EquipmentNames: match.Stats.Items[i],
|
|
||||||
RwRoleId: match.Red.RwRoleIDs[i],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
buildMatch.RightTeam.Site = match.TeamA.Site
|
buildMatch.RightTeam.Site = match.TeamA.Site
|
||||||
buildMatch.RightTeam.Name = match.TeamA.Name
|
buildMatch.RightTeam.Name = match.TeamA.Name
|
||||||
buildMatch.RightTeam.Score = match.TeamA.Score
|
buildMatch.RightTeam.Score = match.TeamA.Score
|
||||||
teamKills, _ := stats.Sum(stats.LoadRawData(match.Stats.Kills[:5]))
|
|
||||||
buildMatch.RightTeam.Kills = int(teamKills)
|
|
||||||
teamGold, _ := stats.Sum(stats.LoadRawData(match.Stats.Networth[:5]))
|
|
||||||
buildMatch.RightTeam.Gold = int(teamGold)
|
|
||||||
teamXp, _ := stats.Sum(stats.LoadRawData(match.Stats.Xp[:5]))
|
|
||||||
buildMatch.RightTeam.Gold = int(teamXp)
|
|
||||||
buildMatch.RightTeam.BanRwRoleIDs = match.Red.BanRwRoleIDs
|
buildMatch.RightTeam.BanRwRoleIDs = match.Red.BanRwRoleIDs
|
||||||
buildMatch.RightTeam.PickRwRoleIDs = match.Red.PickRwRoleIDs
|
buildMatch.RightTeam.PickRwRoleIDs = match.Red.PickRwRoleIDs
|
||||||
buildMatch.RightTeam.Tower = match.Red.Tower
|
buildMatch.RightTeam.Tower = match.Red.Tower
|
||||||
buildMatch.RightTeam.Players = teamPlayers
|
|
||||||
} else {
|
} else {
|
||||||
buildMatch.LeftTeamID = mTeam.ID
|
buildMatch.LeftTeamID = mTeam.ID
|
||||||
var teamPlayers []aov.Player
|
|
||||||
for i := 0; i < 5; i++ {
|
|
||||||
teamPlayers = append(teamPlayers, aov.Player{
|
|
||||||
RwID: match.Stats.Players[i].RwID,
|
|
||||||
Name: match.Stats.Players[i].Name,
|
|
||||||
PlayerName: match.Stats.PlayerName[i],
|
|
||||||
Xp: match.Stats.Xp[i],
|
|
||||||
PosX: match.Stats.PosX[i],
|
|
||||||
PosY: match.Stats.PosY[i],
|
|
||||||
Kills: match.Stats.Kills[i],
|
|
||||||
Deaths: match.Stats.Deaths[i],
|
|
||||||
Assists: match.Stats.Assists[i],
|
|
||||||
Gold: match.Stats.Networth[i],
|
|
||||||
RespawnTime: match.Stats.RespawnTime[i],
|
|
||||||
EquipmentNames: match.Stats.Items[i],
|
|
||||||
RwRoleId: match.Blue.RwRoleIDs[i],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
buildMatch.LeftTeam.Site = match.TeamA.Site
|
buildMatch.LeftTeam.Site = match.TeamA.Site
|
||||||
buildMatch.LeftTeam.Name = match.TeamA.Name
|
buildMatch.LeftTeam.Name = match.TeamA.Name
|
||||||
buildMatch.LeftTeam.Score = match.TeamA.Score
|
buildMatch.LeftTeam.Score = match.TeamA.Score
|
||||||
teamKills, _ := stats.Sum(stats.LoadRawData(match.Stats.Kills[:5]))
|
|
||||||
buildMatch.LeftTeam.Kills = int(teamKills)
|
|
||||||
teamGold, _ := stats.Sum(stats.LoadRawData(match.Stats.Networth[:5]))
|
|
||||||
buildMatch.LeftTeam.Gold = int(teamGold)
|
|
||||||
teamXp, _ := stats.Sum(stats.LoadRawData(match.Stats.Xp[:5]))
|
|
||||||
buildMatch.LeftTeam.Gold = int(teamXp)
|
|
||||||
buildMatch.LeftTeam.BanRwRoleIDs = match.Blue.BanRwRoleIDs
|
buildMatch.LeftTeam.BanRwRoleIDs = match.Blue.BanRwRoleIDs
|
||||||
buildMatch.LeftTeam.PickRwRoleIDs = match.Blue.PickRwRoleIDs
|
buildMatch.LeftTeam.PickRwRoleIDs = match.Blue.PickRwRoleIDs
|
||||||
buildMatch.LeftTeam.Tower = match.Blue.Tower
|
buildMatch.LeftTeam.Tower = match.Blue.Tower
|
||||||
buildMatch.LeftTeam.Players = teamPlayers
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -280,72 +185,20 @@ func (match *Match) BuildMatch(buildMatch aov.Match) (BuilderMatch aov.Match, bu
|
||||||
} else {
|
} else {
|
||||||
if match.TeamB.Colour == "blue" {
|
if match.TeamB.Colour == "blue" {
|
||||||
buildMatch.LeftTeamID = mTeam.ID
|
buildMatch.LeftTeamID = mTeam.ID
|
||||||
var teamPlayers []aov.Player
|
|
||||||
for i := 0; i < 5; i++ {
|
|
||||||
addI := i + 5
|
|
||||||
teamPlayers = append(teamPlayers, aov.Player{
|
|
||||||
RwID: match.Stats.Players[addI].RwID,
|
|
||||||
Name: match.Stats.Players[addI].Name,
|
|
||||||
PlayerName: match.Stats.PlayerName[addI],
|
|
||||||
Xp: match.Stats.Xp[addI],
|
|
||||||
PosX: match.Stats.PosX[addI],
|
|
||||||
PosY: match.Stats.PosY[addI],
|
|
||||||
Kills: match.Stats.Kills[addI],
|
|
||||||
Deaths: match.Stats.Deaths[addI],
|
|
||||||
Assists: match.Stats.Assists[addI],
|
|
||||||
Gold: match.Stats.Networth[addI],
|
|
||||||
RespawnTime: match.Stats.RespawnTime[addI],
|
|
||||||
EquipmentNames: match.Stats.Items[addI],
|
|
||||||
RwRoleId: match.Blue.RwRoleIDs[i],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
buildMatch.LeftTeam.Site = match.TeamB.Site
|
buildMatch.LeftTeam.Site = match.TeamB.Site
|
||||||
buildMatch.LeftTeam.Name = match.TeamB.Name
|
buildMatch.LeftTeam.Name = match.TeamB.Name
|
||||||
buildMatch.LeftTeam.Score = match.TeamB.Score
|
buildMatch.LeftTeam.Score = match.TeamB.Score
|
||||||
teamKills, _ := stats.Sum(stats.LoadRawData(match.Stats.Kills[5:]))
|
|
||||||
buildMatch.LeftTeam.Kills = int(teamKills)
|
|
||||||
teamGold, _ := stats.Sum(stats.LoadRawData(match.Stats.Networth[5:]))
|
|
||||||
buildMatch.LeftTeam.Gold = int(teamGold)
|
|
||||||
teamXp, _ := stats.Sum(stats.LoadRawData(match.Stats.Xp[5:]))
|
|
||||||
buildMatch.LeftTeam.Gold = int(teamXp)
|
|
||||||
buildMatch.LeftTeam.BanRwRoleIDs = match.Blue.BanRwRoleIDs
|
buildMatch.LeftTeam.BanRwRoleIDs = match.Blue.BanRwRoleIDs
|
||||||
buildMatch.LeftTeam.PickRwRoleIDs = match.Blue.PickRwRoleIDs
|
buildMatch.LeftTeam.PickRwRoleIDs = match.Blue.PickRwRoleIDs
|
||||||
buildMatch.LeftTeam.Tower = match.Blue.Tower
|
buildMatch.LeftTeam.Tower = match.Blue.Tower
|
||||||
buildMatch.LeftTeam.Players = teamPlayers
|
|
||||||
} else {
|
} else {
|
||||||
buildMatch.RightTeamID = mTeam.ID
|
buildMatch.RightTeamID = mTeam.ID
|
||||||
var teamPlayers []aov.Player
|
|
||||||
for i := 0; i < 5; i++ {
|
|
||||||
addI := i + 5
|
|
||||||
teamPlayers = append(teamPlayers, aov.Player{
|
|
||||||
RwID: match.Stats.Players[addI].RwID,
|
|
||||||
Name: match.Stats.Players[addI].Name,
|
|
||||||
PlayerName: match.Stats.PlayerName[addI],
|
|
||||||
Xp: match.Stats.Xp[addI],
|
|
||||||
PosX: match.Stats.PosX[addI],
|
|
||||||
PosY: match.Stats.PosY[addI],
|
|
||||||
Kills: match.Stats.Kills[addI],
|
|
||||||
Deaths: match.Stats.Deaths[addI],
|
|
||||||
Assists: match.Stats.Assists[addI],
|
|
||||||
Gold: match.Stats.Networth[addI],
|
|
||||||
RespawnTime: match.Stats.RespawnTime[addI],
|
|
||||||
EquipmentNames: match.Stats.Items[addI],
|
|
||||||
RwRoleId: match.Red.RwRoleIDs[i],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
buildMatch.RightTeam.Site = match.TeamB.Site
|
buildMatch.RightTeam.Site = match.TeamB.Site
|
||||||
buildMatch.RightTeam.Name = match.TeamB.Name
|
buildMatch.RightTeam.Name = match.TeamB.Name
|
||||||
buildMatch.RightTeam.Score = match.TeamB.Score
|
buildMatch.RightTeam.Score = match.TeamB.Score
|
||||||
teamKills, _ := stats.Sum(stats.LoadRawData(match.Stats.Kills[5:]))
|
|
||||||
buildMatch.RightTeam.Kills = int(teamKills)
|
|
||||||
teamGold, _ := stats.Sum(stats.LoadRawData(match.Stats.Networth[5:]))
|
|
||||||
buildMatch.RightTeam.Gold = int(teamGold)
|
|
||||||
teamXp, _ := stats.Sum(stats.LoadRawData(match.Stats.Xp[5:]))
|
|
||||||
buildMatch.RightTeam.Gold = int(teamXp)
|
|
||||||
buildMatch.RightTeam.BanRwRoleIDs = match.Red.BanRwRoleIDs
|
buildMatch.RightTeam.BanRwRoleIDs = match.Red.BanRwRoleIDs
|
||||||
buildMatch.RightTeam.PickRwRoleIDs = match.Red.PickRwRoleIDs
|
buildMatch.RightTeam.PickRwRoleIDs = match.Red.PickRwRoleIDs
|
||||||
buildMatch.RightTeam.Tower = match.Red.Tower
|
buildMatch.RightTeam.Tower = match.Red.Tower
|
||||||
buildMatch.RightTeam.Players = teamPlayers
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -353,6 +206,44 @@ func (match *Match) BuildMatch(buildMatch aov.Match) (BuilderMatch aov.Match, bu
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var leftTeamPlayers, rightTeamPlayers []aov.Player
|
||||||
|
var leftTeamKills, rightTeamKills int
|
||||||
|
var leftTeamGold, rightTeamGold int
|
||||||
|
var leftTeamXp, rightTeamXp int
|
||||||
|
for i, leftCount, rightCount := 0, 0, 0; i < 10; i++ {
|
||||||
|
bPlayer := buildMPlayerByStats(match.Stats, i)
|
||||||
|
if bPlayer.RwID != 0 && strings.HasPrefix(bPlayer.PlayerName, buildMatch.LeftTeam.Name) {
|
||||||
|
if len(match.Blue.RwRoleIDs) == 5 {
|
||||||
|
bPlayer.RwRoleId = match.Blue.RwRoleIDs[leftCount]
|
||||||
|
leftCount++
|
||||||
|
}
|
||||||
|
leftTeamPlayers = append(leftTeamPlayers, bPlayer)
|
||||||
|
leftTeamKills += bPlayer.Kills
|
||||||
|
leftTeamGold += bPlayer.Gold
|
||||||
|
leftTeamXp += bPlayer.Xp
|
||||||
|
}
|
||||||
|
if bPlayer.RwID != 0 && strings.HasPrefix(bPlayer.PlayerName, buildMatch.RightTeam.Name) {
|
||||||
|
if len(match.Red.RwRoleIDs) == 5 {
|
||||||
|
bPlayer.RwRoleId = match.Red.RwRoleIDs[rightCount]
|
||||||
|
rightCount++
|
||||||
|
}
|
||||||
|
rightTeamPlayers = append(rightTeamPlayers, bPlayer)
|
||||||
|
rightTeamKills += bPlayer.Kills
|
||||||
|
rightTeamGold += bPlayer.Gold
|
||||||
|
rightTeamXp += bPlayer.Xp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存队伍队员信息,击杀数,经济,经验
|
||||||
|
buildMatch.LeftTeam.Players = leftTeamPlayers
|
||||||
|
buildMatch.LeftTeam.Kills = leftTeamKills
|
||||||
|
buildMatch.LeftTeam.Gold = leftTeamGold
|
||||||
|
buildMatch.LeftTeam.Xp = leftTeamXp
|
||||||
|
buildMatch.RightTeam.Players = rightTeamPlayers
|
||||||
|
buildMatch.RightTeam.Kills = leftTeamKills
|
||||||
|
buildMatch.RightTeam.Gold = leftTeamGold
|
||||||
|
buildMatch.RightTeam.Xp = rightTeamXp
|
||||||
|
|
||||||
// 得到队伍主客场标志
|
// 得到队伍主客场标志
|
||||||
var siteTeamID int64
|
var siteTeamID int64
|
||||||
var notSiteTeamID int64
|
var notSiteTeamID int64
|
||||||
|
@ -424,11 +315,20 @@ func (match *Match) BuildMatch(buildMatch aov.Match) (BuilderMatch aov.Match, bu
|
||||||
buildMatch.TenKillDuration = int64(match.Flag.TenKill.GameTime)
|
buildMatch.TenKillDuration = int64(match.Flag.TenKill.GameTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if match.Flag.Win.Status == 1 {
|
||||||
|
if match.Flag.Win.Winner == 1 {
|
||||||
|
buildMatch.TenKill = siteTeamID
|
||||||
|
} else {
|
||||||
|
buildMatch.TenKill = notSiteTeamID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buildMatch.StartTime = match.StartTime
|
buildMatch.StartTime = match.StartTime
|
||||||
buildMatch.Duration = match.GameTime
|
buildMatch.Duration = match.GameTime
|
||||||
buildMatch.GameStatus = match.GameStatus
|
buildMatch.GameStatus = match.GameStatus
|
||||||
buildMatch.CourseName = match.CourseName
|
buildMatch.CourseName = match.CourseName
|
||||||
buildMatch.GameNo = match.GameNo
|
buildMatch.GameNo = match.GameNo
|
||||||
|
buildMatch.Kills = buildMatch.LeftTeam.Kills + buildMatch.RightTeam.Kills
|
||||||
|
|
||||||
// 队伍经济差,经验差
|
// 队伍经济差,经验差
|
||||||
var goldDiff aov.GoldDiff
|
var goldDiff aov.GoldDiff
|
||||||
|
@ -438,13 +338,72 @@ func (match *Match) BuildMatch(buildMatch aov.Match) (BuilderMatch aov.Match, bu
|
||||||
xpDiff.Time = match.GameTime
|
xpDiff.Time = match.GameTime
|
||||||
xpDiff.Data = buildMatch.LeftTeam.Xp - buildMatch.RightTeam.Xp
|
xpDiff.Data = buildMatch.LeftTeam.Xp - buildMatch.RightTeam.Xp
|
||||||
|
|
||||||
|
goldDiffList := buildMatch.TeamDiff.GoldDiff
|
||||||
if goldDiff.Data != 0 {
|
if goldDiff.Data != 0 {
|
||||||
buildMatch.TeamDiff.GoldDiff = append(buildMatch.TeamDiff.GoldDiff, goldDiff)
|
if len(goldDiffList) > 0 && goldDiffList[len(goldDiffList)-1].Time == buildMatch.Duration {
|
||||||
|
goldDiffList[len(goldDiffList)-1].Data = goldDiff.Data
|
||||||
|
} else {
|
||||||
|
buildMatch.TeamDiff.GoldDiff = append(buildMatch.TeamDiff.GoldDiff, goldDiff)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xpDiffList := buildMatch.TeamDiff.XpDiff
|
||||||
if xpDiff.Data != 0 {
|
if xpDiff.Data != 0 {
|
||||||
buildMatch.TeamDiff.XpDiff = append(buildMatch.TeamDiff.XpDiff, xpDiff)
|
if len(xpDiffList) > 0 && xpDiffList[len(xpDiffList)-1].Time == buildMatch.Duration {
|
||||||
|
xpDiffList[len(xpDiffList)-1].Data = xpDiff.Data
|
||||||
|
} else {
|
||||||
|
buildMatch.TeamDiff.XpDiff = append(buildMatch.TeamDiff.XpDiff, xpDiff)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return buildMatch, nil
|
return buildMatch, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func buildMPlayerByStats(stats Stats, index int) (builderPlayer aov.Player) {
|
||||||
|
if len(stats.Xp) == 10 {
|
||||||
|
builderPlayer.Xp = stats.Xp[index]
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(stats.PosX) == 10 {
|
||||||
|
builderPlayer.PosX = stats.PosX[index]
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(stats.PosY) == 10 {
|
||||||
|
builderPlayer.PosY = stats.PosY[index]
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(stats.Kills) == 10 {
|
||||||
|
builderPlayer.Kills = stats.Kills[index]
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(stats.Deaths) == 10 {
|
||||||
|
builderPlayer.Deaths = stats.Deaths[index]
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(stats.Assists) == 10 {
|
||||||
|
builderPlayer.Assists = stats.Assists[index]
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(stats.Networth) == 10 {
|
||||||
|
builderPlayer.Gold = stats.Networth[index]
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(stats.PlayerName) == 10 {
|
||||||
|
builderPlayer.PlayerName = stats.PlayerName[index]
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(stats.Players) == 10 {
|
||||||
|
builderPlayer.RwID = stats.Players[index].RwID
|
||||||
|
builderPlayer.Name = stats.Players[index].Name
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(stats.RespawnTime) == 10 {
|
||||||
|
builderPlayer.RespawnTime = stats.RespawnTime[index]
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(stats.Items) == 10 {
|
||||||
|
builderPlayer.EquipmentNames = stats.Items[index]
|
||||||
|
}
|
||||||
|
|
||||||
|
return builderPlayer
|
||||||
|
}
|
||||||
|
|
|
@ -166,16 +166,6 @@ func (match *Match) BuildMatch(buildMatch csgo.Match) (builderMatch csgo.Match,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(match.LeftPlayers) != 5 {
|
|
||||||
buildErr = errors.New("比赛左队选手数据数组异常!")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(match.RightPlayers) != 5 {
|
|
||||||
buildErr = errors.New("比赛右队选手数据数组异常!")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 左队信息
|
// 左队信息
|
||||||
buildMatch.LeftTeam.Name = match.LeftTeam.Name
|
buildMatch.LeftTeam.Name = match.LeftTeam.Name
|
||||||
buildMatch.LeftTeam.Tag = match.LeftTeam.Tag
|
buildMatch.LeftTeam.Tag = match.LeftTeam.Tag
|
||||||
|
@ -208,9 +198,9 @@ func (match *Match) BuildMatch(buildMatch csgo.Match) (builderMatch csgo.Match,
|
||||||
|
|
||||||
buildMatch.LeftTeam.Players = leftTeamPlayers
|
buildMatch.LeftTeam.Players = leftTeamPlayers
|
||||||
leftTeamAdrSum, _ := stats.Sum(leftTeamAdr)
|
leftTeamAdrSum, _ := stats.Sum(leftTeamAdr)
|
||||||
buildMatch.LeftTeam.Adr = strconv.FormatFloat(leftTeamAdrSum/5, 'E', -1, 64)
|
buildMatch.LeftTeam.Adr = strconv.FormatFloat(leftTeamAdrSum/float64(len(leftTeamPlayers)), 'E', -1, 64)
|
||||||
leftTeamRatingSum, _ := stats.Sum(leftTeamRating)
|
leftTeamRatingSum, _ := stats.Sum(leftTeamRating)
|
||||||
buildMatch.LeftTeam.Rating = strconv.FormatFloat(leftTeamRatingSum/5, 'E', -1, 64)
|
buildMatch.LeftTeam.Rating = strconv.FormatFloat(leftTeamRatingSum/float64(len(leftTeamPlayers)), 'E', -1, 64)
|
||||||
|
|
||||||
// 右队信息
|
// 右队信息
|
||||||
buildMatch.RightTeam.Name = match.RightTeam.Name
|
buildMatch.RightTeam.Name = match.RightTeam.Name
|
||||||
|
@ -244,9 +234,9 @@ func (match *Match) BuildMatch(buildMatch csgo.Match) (builderMatch csgo.Match,
|
||||||
|
|
||||||
buildMatch.RightTeam.Players = rightTeamPlayers
|
buildMatch.RightTeam.Players = rightTeamPlayers
|
||||||
rightTeamAdrSum, _ := stats.Sum(rightTeamAdr)
|
rightTeamAdrSum, _ := stats.Sum(rightTeamAdr)
|
||||||
buildMatch.RightTeam.Adr = strconv.FormatFloat(rightTeamAdrSum/5, 'E', -1, 64)
|
buildMatch.RightTeam.Adr = strconv.FormatFloat(rightTeamAdrSum/float64(len(rightTeamPlayers)), 'E', -1, 64)
|
||||||
rightTeamRatingSum, _ := stats.Sum(rightTeamRating)
|
rightTeamRatingSum, _ := stats.Sum(rightTeamRating)
|
||||||
buildMatch.RightTeam.Rating = strconv.FormatFloat(rightTeamRatingSum/5, 'E', -1, 64)
|
buildMatch.RightTeam.Rating = strconv.FormatFloat(rightTeamRatingSum/float64(len(rightTeamPlayers)), 'E', -1, 64)
|
||||||
|
|
||||||
// 场次
|
// 场次
|
||||||
buildMatch.GameNo = match.MatchIndex
|
buildMatch.GameNo = match.MatchIndex
|
||||||
|
|
|
@ -366,12 +366,22 @@ func (match *Match) BuildMatch(buildMatch dota2.Match) (builderMatch dota2.Match
|
||||||
xpDiff.Time = match.GameTime
|
xpDiff.Time = match.GameTime
|
||||||
xpDiff.Data = buildMatch.LeftTeam.Xp - buildMatch.RightTeam.Xp
|
xpDiff.Data = buildMatch.LeftTeam.Xp - buildMatch.RightTeam.Xp
|
||||||
|
|
||||||
|
goldDiffList := buildMatch.TeamDiff.GoldDiff
|
||||||
if goldDiff.Data != 0 {
|
if goldDiff.Data != 0 {
|
||||||
buildMatch.TeamDiff.GoldDiff = append(buildMatch.TeamDiff.GoldDiff, goldDiff)
|
if len(goldDiffList) > 0 && goldDiffList[len(goldDiffList)-1].Time == buildMatch.Duration {
|
||||||
|
goldDiffList[len(goldDiffList)-1].Data = goldDiff.Data
|
||||||
|
} else {
|
||||||
|
buildMatch.TeamDiff.GoldDiff = append(buildMatch.TeamDiff.GoldDiff, goldDiff)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xpDiffList := buildMatch.TeamDiff.XpDiff
|
||||||
if xpDiff.Data != 0 {
|
if xpDiff.Data != 0 {
|
||||||
buildMatch.TeamDiff.XpDiff = append(buildMatch.TeamDiff.XpDiff, xpDiff)
|
if len(xpDiffList) > 0 && xpDiffList[len(xpDiffList)-1].Time == buildMatch.Duration {
|
||||||
|
xpDiffList[len(xpDiffList)-1].Data = xpDiff.Data
|
||||||
|
} else {
|
||||||
|
buildMatch.TeamDiff.XpDiff = append(buildMatch.TeamDiff.XpDiff, xpDiff)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return buildMatch, nil
|
return buildMatch, nil
|
||||||
|
|
|
@ -374,7 +374,14 @@ func (match *Match) BuildMatch(buildMatch lol.Match) (builderMatch lol.Match, bu
|
||||||
goldDiff.Time = match.GameTime
|
goldDiff.Time = match.GameTime
|
||||||
goldDiff.Data = match.BlueGoldDiff
|
goldDiff.Data = match.BlueGoldDiff
|
||||||
|
|
||||||
buildMatch.TeamDiff.GoldDiff = append(buildMatch.TeamDiff.GoldDiff, goldDiff)
|
goldDiffList := buildMatch.TeamDiff.GoldDiff
|
||||||
|
if goldDiff.Data != 0 {
|
||||||
|
if len(goldDiffList) > 0 && goldDiffList[len(goldDiffList)-1].Time == buildMatch.Duration {
|
||||||
|
goldDiffList[len(goldDiffList)-1].Data = goldDiff.Data
|
||||||
|
} else {
|
||||||
|
buildMatch.TeamDiff.GoldDiff = append(buildMatch.TeamDiff.GoldDiff, goldDiff)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return buildMatch, nil
|
return buildMatch, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,10 +52,10 @@ func SyncDB() {
|
||||||
new(models.League),
|
new(models.League),
|
||||||
new(models.Course),
|
new(models.Course),
|
||||||
new(models.Series),
|
new(models.Series),
|
||||||
new(aov.Match),
|
new(aov.Match), new(aov.Event),
|
||||||
new(csgo.Match),
|
new(csgo.Match), new(csgo.Event),
|
||||||
new(dota2.Match),
|
new(dota2.Match),
|
||||||
new(lol.Match),
|
new(lol.Match), new(lol.Event),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package util
|
||||||
|
|
||||||
|
// 三元运算
|
||||||
|
func TernaryIf(condition bool, trueVal, falseVal interface{}) interface{} {
|
||||||
|
if condition {
|
||||||
|
return trueVal
|
||||||
|
}
|
||||||
|
|
||||||
|
return falseVal
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package util
|
||||||
|
|
||||||
import "reflect"
|
import "reflect"
|
||||||
|
|
||||||
|
// struct转换为map
|
||||||
func Struct2Map(obj interface{}) map[string]interface{} {
|
func Struct2Map(obj interface{}) map[string]interface{} {
|
||||||
t := reflect.TypeOf(obj)
|
t := reflect.TypeOf(obj)
|
||||||
v := reflect.ValueOf(obj)
|
v := reflect.ValueOf(obj)
|
||||||
|
|
Loading…
Reference in New Issue