diff options
Diffstat (limited to 'internal/game/look_entities.go')
| -rw-r--r-- | internal/game/look_entities.go | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/internal/game/look_entities.go b/internal/game/look_entities.go index dd2cdf0..4ed47c9 100644 --- a/internal/game/look_entities.go +++ b/internal/game/look_entities.go @@ -5,6 +5,7 @@ import ( "sort" "strings" + "thehouseoficarus/internal/casino" "thehouseoficarus/internal/color" "thehouseoficarus/internal/net" "thehouseoficarus/internal/player" @@ -73,7 +74,7 @@ func (g *Game) showRoomMobs(sess *net.Session, p *player.Player, room *world.Roo func (g *Game) showRoomObjects(sess *net.Session, p *player.Player, room *world.Room) []string { objs := g.World.AllObjInstances(p.RoomID) if len(objs) == 0 { - return g.showFarmPatches(sess, p) + return appendRoomCasinos(g.showFarmPatches(sess, p), g.showRoomCasinos(sess, room)) } var lines []string lines = append(lines, "") @@ -220,9 +221,43 @@ func (g *Game) showRoomObjects(sess *net.Session, p *player.Player, room *world. } lines = append(lines, g.showFarmPatches(sess, p)...) + return appendRoomCasinos(lines, g.showRoomCasinos(sess, room)) +} + +func (g *Game) showRoomCasinos(sess *net.Session, room *world.Room) []string { + if room == nil || (len(room.CasinoTables) == 0 && len(room.CasinoMachines) == 0) { + return nil + } + var lines []string + for _, table := range room.CasinoTables { + name := casinoGameLabel(table.Game) + " table" + lines = append(lines, fmt.Sprintf("A %s is here.", g.colorize(sess, "casino_action", name))) + } + for _, machine := range room.CasinoMachines { + name := casinoGameLabel(machine.Game) + " machine" + lines = append(lines, fmt.Sprintf("A %s is here.", g.colorize(sess, "casino_action", name))) + } return lines } +func appendRoomCasinos(lines, casinos []string) []string { + if len(casinos) == 0 { + return lines + } + if len(lines) == 0 || lines[len(lines)-1] != "" { + lines = append(lines, "") + } + return append(lines, casinos...) +} + +func casinoGameLabel(game casino.GameName) string { + label := strings.ReplaceAll(string(game), "_", " ") + if label == "" { + return "casino" + } + return label +} + func (g *Game) showGroundItems(sess *net.Session, p *player.Player, room *world.Room) []string { ground := g.World.GroundItemsDetailed(p.RoomID) if len(ground) == 0 { |
