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
29
30
31
32
|
package game
import (
"fmt"
"sort"
"strings"
"thehouseoficarus/internal/net"
"thehouseoficarus/internal/player"
)
func (g *Game) executeWho(sess *net.Session, args []string, rawInput string) {
myP := sess.Player
var players []*player.Player
for _, other := range g.Hub.AllSessions() {
if other.Player == nil {
continue
}
players = append(players, other.Player)
}
sort.Slice(players, func(i, j int) bool {
return strings.ToLower(players[i].Name) < strings.ToLower(players[j].Name)
})
sess.WriteLine(fmt.Sprintf("Players online (%d):", len(players)))
for _, p := range players {
lvl := p.CombatLevel()
levelStr := g.levelColorize(sess, myP.CombatLevel(), lvl, fmt.Sprintf("(level %d)", lvl))
sess.WriteLine(fmt.Sprintf(" %s %s", p.Name, levelStr))
}
}
|