Skip to content

Instantly share code, notes, and snippets.

@macalinao
Last active November 17, 2016 23:34
Show Gist options
  • Save macalinao/36b8afefd684d03d277504bed3ee823e to your computer and use it in GitHub Desktop.
Save macalinao/36b8afefd684d03d277504bed3ee823e to your computer and use it in GitHub Desktop.
// derive runes
var runes []*apb.MatchAggregateCollections_RuneSet
for rs, rstats := range quot.Runes {
if rstats.Plays < minPlayRate {
continue
}
// 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,
NumMatches: uint32(rstats.PlayCount),
})
}
MatchAggregate.Collections(
runes = quot.runes
.filter(_._2.plays >= minPlayRate) // Ensure minimum play rate is met
.map { case (runeSet, subscalars) =>
MatchAggregate.Collections.RuneSet(
runes = deserializeBonusSet(runeSet),
pickRate = subscalars.plays,
winRate = subscalars.wins,
numMatches = subscalars.playCount.toInt
)
}.toSeq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment