aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_map.go
blob: 1c78be312c0ca7b093fd96a2a7abc2d958baf697 (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
29
30
31
32
33
34
35
36
37
package game

import (
	"thehouseoficarus/internal/net"
	"thehouseoficarus/internal/player"
)

func (g *Game) doMap(sess *net.Session) {
	p := sess.Player.(*player.Player)
	mapWidth := p.OptionInt("mapwidth")
	mapHeight := p.OptionInt("mapheight")
	if mapWidth < 5 {
		mapWidth = 5
	}
	if mapHeight < 5 {
		mapHeight = 5
	}

	lines := buildFullMap(g, p.RoomID, mapWidth, mapHeight, mapGlyphsForPlayer(p.OptionBool("unicode")))

	mode := p.OptionString("mappadding")
	if mode == "none" || mode == "x" {
		lines = stripBlankRows(lines)
	}
	if mode == "none" || mode == "y" {
		lines = leftTrimCommon(lines)
	}

	if len(lines) == 0 {
		sess.WriteLine("\nNo map data to display.")
		return
	}
	sess.WriteLine("")
	for _, line := range lines {
		sess.WriteLine(line)
	}
}