-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworld_func.go
44 lines (38 loc) · 940 Bytes
/
world_func.go
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
33
34
35
36
37
38
39
40
41
42
43
44
package main
import "fmt"
func lookRoom(player *characterData) {
buf := ""
var exitList string
var exitCount int
for _, exit := range player.room.Exits {
if exitCount != 0 {
exitList = exitList + "{x, "
}
exitList = exitList + dirToTextColor[exit.Direction]
exitCount++
}
playersList := ""
if len(player.room.players) > 0 {
playersList = NEWLINE + "Who's here: "
for i, target := range player.room.players {
if i != 0 {
playersList = playersList + ", "
}
playersList = playersList + target.Name
if target.desc == nil || (target.desc != nil && !target.desc.valid) {
playersList = playersList + " (no link)"
}
}
if playersList != "" {
playersList = playersList + NEWLINE
}
}
if exitCount == 0 {
exitList = "None"
}
buf = buf + fmt.Sprintf(
"%v:"+NEWLINE+"%v"+NEWLINE+"%vExits: %v{x",
player.room.Name, player.room.Description,
playersList, exitList)
player.send(buf)
}