blob: c522ac2f172c57572cd15a5f81e67d4282671bc7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
// Copyright (c) 2016 Florian Fischer. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
package logic
type Player struct {
Name string
Score Score
}
func NewPlayer(name string) Player {
return Player{name, NewScore()}
}
func FindBest(players []Player) ([]Player, int) {
best := []Player{}
max := 0
for _, p := range players {
t := p.Score.Score()
if t > max {
best = []Player{p}
max = t
} else if t == max {
best = append(best, p)
}
}
return best, max
}
|