22 lines
626 B
Go
22 lines
626 B
Go
package westworldwithmessaging
|
|
|
|
import "fmt"
|
|
|
|
// entityNames is a temporary stand-in for the book's real name
|
|
// lookup table. We still haven't been shown that table, so this is
|
|
// just a small map we're filling in by hand as we meet entities -
|
|
// the miner (ID 1) and now his wife Elsa (ID 2).
|
|
var entityNames = map[int]string{
|
|
1: "Miner Bob",
|
|
2: "Elsa",
|
|
}
|
|
|
|
// GetNameOfEntity looks up a friendly name for a given entity ID.
|
|
// Anything not in entityNames falls back to printing the raw ID.
|
|
func GetNameOfEntity(id int) string {
|
|
if name, ok := entityNames[id]; ok {
|
|
return name
|
|
}
|
|
return fmt.Sprintf("Entity %d", id)
|
|
}
|