Created
September 16, 2016 01:38
-
-
Save macalinao/af1ec5bcf2b9a893a2280dcb2907d58f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func makeMatchAggregateCollections(quot *apb.MatchQuotient) (*apb.MatchAggregateCollections, error) { | |
// derive runes | |
var runes []*apb.MatchAggregateCollections_RuneSet | |
for rs, rstats := range quot.Runes { | |
// rs is rune set string | |
// rstats is rune set subscalars | |
runeSet, err := deserializeBonusSet(rs) | |
if err != nil { | |
return nil, fmt.Errorf("could not deserialize rune set: %v", err) | |
} | |
runes = append(runes, &apb.MatchAggregateCollections_RuneSet{ | |
Runes: runeSet, | |
PickRate: rstats.Plays, | |
WinRate: rstats.Wins, | |
// rederive number of plays. TOOD(igm): preserve original number of matches instead of imprecise floating point bullshit | |
NumMatches: uint32(rstats.Plays * quot.Scalars.Plays), | |
}) | |
} | |
// derive masteries | |
var masteries []*apb.MatchAggregateCollections_MasterySet | |
for ms, mstats := range quot.Masteries { | |
// ms is mastery set string | |
// mstats is mastery set subscalars | |
masterySet, err := deserializeBonusSet(ms) | |
if err != nil { | |
return nil, fmt.Errorf("could not deserialize mastery set: %v", err) | |
} | |
masteries = append(masteries, &apb.MatchAggregateCollections_MasterySet{ | |
Masteries: masterySet, | |
PickRate: mstats.Plays, | |
WinRate: mstats.Wins, | |
// rederive number of plays. TOOD(igm): preserve original number of matches instead of imprecise floating point bullshit | |
NumMatches: uint32(mstats.Plays * quot.Scalars.Plays), | |
}) | |
} | |
// derive keystones | |
var keystones []*apb.MatchAggregateCollections_Keystone | |
for ks, kstats := range quot.Keystones { | |
// ks is keystone string | |
// kstats is keystone subscalars | |
keystone, _, err := deserializeBonusSetElement(ks) | |
if err != nil { | |
return nil, fmt.Errorf("could not deserialize keystone: %v", err) | |
} | |
keystones = append(keystones, &apb.MatchAggregateCollections_Keystone{ | |
Keystone: keystone, | |
PickRate: kstats.Plays, | |
WinRate: kstats.Wins, | |
// rederive number of plays. TOOD(igm): preserve original number of matches instead of imprecise floating point bullshit | |
NumMatches: uint32(kstats.Plays * quot.Scalars.Plays), | |
}) | |
} | |
// derive summoners | |
var summonerSpells []*apb.MatchAggregateCollections_SummonerSet | |
for ss, sstats := range quot.Summoners { | |
// ss is summoner string | |
// sstats is summoner subscalars | |
spell1, spell2, err := deserializeSummoners(ss) | |
if err != nil { | |
return nil, fmt.Errorf("could not deserialize summoners: %v", err) | |
} | |
summonerSpells = append(summonerSpells, &apb.MatchAggregateCollections_SummonerSet{ | |
Spell1: spell1, | |
Spell2: spell2, | |
PickRate: sstats.Plays, | |
WinRate: sstats.Wins, | |
// rederive number of plays. TOOD(igm): preserve original number of matches instead of imprecise floating point bullshit | |
NumMatches: uint32(sstats.Plays * quot.Scalars.Plays), | |
}) | |
} | |
// derive trinkets | |
var trinkets []*apb.MatchAggregateCollections_Trinket | |
for trinket, tstats := range quot.Trinkets { | |
// tstats is trinket subscalars | |
trinkets = append(trinkets, &apb.MatchAggregateCollections_Trinket{ | |
Trinket: trinket, | |
PickRate: tstats.Plays, | |
WinRate: tstats.Wins, | |
// rederive number of plays. TOOD(igm): preserve original number of matches instead of imprecise floating point bullshit | |
NumMatches: uint32(tstats.Plays * quot.Scalars.Plays), | |
}) | |
} | |
return &apb.MatchAggregateCollections{ | |
Runes: runes, | |
Masteries: masteries, | |
Keystones: keystones, | |
SummonerSpells: summonerSpells, | |
Trinkets: trinkets, | |
}, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment